Skip to content

Commit eec4984

Browse files
committed
eslint
1 parent eb519eb commit eec4984

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ lib/maxmind :
88
.PHONY : fmt
99
fmt :
1010
bun x prettier --write .
11+
bun x eslint --fix .
1112
@ git diff-index --quiet HEAD
1213

1314
.PHONY : test

eslint.config.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// @ts-check
2+
3+
import fs from 'node:fs';
4+
5+
import eslint from '@eslint/js';
6+
import prettierConfig from 'eslint-config-prettier';
7+
import importPlugin from 'eslint-plugin-import';
8+
import jest from 'eslint-plugin-jest';
9+
import react from 'eslint-plugin-react';
10+
import tseslint from 'typescript-eslint';
11+
12+
export default tseslint.config(
13+
{
14+
ignores: ['eslint.config.js'].concat(
15+
fs.readFileSync('.gitignore', 'utf8').split('\n').filter(Boolean),
16+
),
17+
},
18+
19+
eslint.configs.recommended,
20+
...tseslint.configs.strictTypeChecked,
21+
{
22+
languageOptions: {
23+
parserOptions: {
24+
project: true,
25+
ecmaFeatures: { jsx: true },
26+
},
27+
},
28+
},
29+
prettierConfig,
30+
31+
{
32+
linterOptions: {
33+
reportUnusedDisableDirectives: 'error',
34+
},
35+
plugins: {
36+
import: importPlugin,
37+
react,
38+
},
39+
},
40+
41+
{
42+
settings: {
43+
'import/core-modules': ['bun:test'],
44+
},
45+
46+
rules: {
47+
'import/order': [
48+
'error',
49+
{ alphabetize: { order: 'asc' }, 'newlines-between': 'always' },
50+
],
51+
'no-unused-vars': [
52+
'error',
53+
{ varsIgnorePattern: '[iI]gnored', argsIgnorePattern: '^_' },
54+
],
55+
curly: 'error',
56+
'default-case': 'error',
57+
},
58+
},
59+
{
60+
files: ['**/*.ts', '**/*.tsx', '**/*.mts'],
61+
rules: {
62+
'no-unused-vars': 'off',
63+
'@typescript-eslint/no-unused-vars': [
64+
'error',
65+
{ varsIgnorePattern: '[iI]gnored', argsIgnorePattern: '^_' },
66+
],
67+
'no-void': ['error', { allowAsStatement: true }],
68+
},
69+
},
70+
{
71+
files: ['**/*.spec.ts', '**/*.spec.tsx'],
72+
plugins: { jest },
73+
settings: { jest: { version: 29 } },
74+
...jest.configs['flat/recommended'],
75+
},
76+
);

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@
1313
"mmdb-lib": "^2.1.1"
1414
},
1515
"devDependencies": {
16+
"@eslint/js": "^9.4.0",
1617
"@types/bun": "latest",
18+
"@types/eslint__js": "^8.42.3",
19+
"eslint": "^9.4.0",
20+
"eslint-config-prettier": "^9.1.0",
21+
"eslint-plugin-import": "^2.29.1",
22+
"eslint-plugin-jest": "^28.6.0",
23+
"eslint-plugin-react": "^7.34.2",
1724
"prettier": "^3.3.1",
25+
"typescript-eslint": "^7.12.0",
1826
"webpack-cli": "^5.1.4"
1927
},
2028
"peerDependencies": {

0 commit comments

Comments
 (0)