@smartive/eslint-config 7.0.0 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -3
- package/dist/configs.js +21 -4
- package/package.json +25 -13
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ export default config('typescript');
|
|
|
24
24
|
export default config('react');
|
|
25
25
|
|
|
26
26
|
// .. or Next.js applications
|
|
27
|
-
// make sure to add `eslint-config-next@16`
|
|
27
|
+
// make sure to add `eslint-config-next@16`
|
|
28
28
|
// to your devDependencies
|
|
29
29
|
export default config('nextjs');
|
|
30
30
|
```
|
|
@@ -35,7 +35,22 @@ To use eslint add the following to your package.json:
|
|
|
35
35
|
|
|
36
36
|
```json
|
|
37
37
|
"scripts": {
|
|
38
|
-
"lint": "eslint
|
|
39
|
-
"lint:fix": "eslint
|
|
38
|
+
"lint": "eslint {your source directory}",
|
|
39
|
+
"lint:fix": "eslint {your source directory} --fix"
|
|
40
40
|
}
|
|
41
41
|
```
|
|
42
|
+
|
|
43
|
+
## Development
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
$ npm run check-types # type-check the config sources
|
|
47
|
+
$ npm run prettier # formatting
|
|
48
|
+
$ npm test # build, type-check the tests, then run them
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The tests in `test/` lint the fixtures in `test/fixtures/` with each of the three rule sets and assert that
|
|
52
|
+
a given fixture line is flagged. They deliberately never assert on rule ids, so that swapping out a plugin
|
|
53
|
+
for an equivalent one does not require rewriting them.
|
|
54
|
+
|
|
55
|
+
> `npm test` runs the TypeScript test files directly through Node's type stripping, which needs Node
|
|
56
|
+
> 22.18 or newer.
|
package/dist/configs.js
CHANGED
|
@@ -29,6 +29,18 @@ const baseConfig = {
|
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Type-aware rules cannot run on plain JavaScript.
|
|
34
|
+
*
|
|
35
|
+
* This has to come *after* every block that switches such a rule on — `typescriptRules` in
|
|
36
|
+
* `baseConfig` and `reactRules` both do — because in flat config the later block wins. Applied too
|
|
37
|
+
* early, ESLint fails with "You have used a rule which requires type information" on `.js` files.
|
|
38
|
+
*/
|
|
39
|
+
const jsDisableTypeChecked = {
|
|
40
|
+
name: '@smartive/eslint-config/js-disable-type-checked',
|
|
41
|
+
files: ['**/*.js', '**/*.mjs'],
|
|
42
|
+
rules: tsEslint.configs.disableTypeChecked.rules,
|
|
43
|
+
};
|
|
32
44
|
const reactConfig = { name: '@smartive/eslint-config/react', rules: reactRules };
|
|
33
45
|
export const flatConfigTypescript = (rulesOnly = false) => defineConfig([
|
|
34
46
|
js.configs.recommended,
|
|
@@ -36,6 +48,12 @@ export const flatConfigTypescript = (rulesOnly = false) => defineConfig([
|
|
|
36
48
|
...(rulesOnly
|
|
37
49
|
? [
|
|
38
50
|
{
|
|
51
|
+
// `eslint-config-next` registers this plugin, but only for `**/*.ts` and `**/*.tsx`. Without
|
|
52
|
+
// registering it here, every `@typescript-eslint/*` rule reference — these, plus the ones in
|
|
53
|
+
// `typescriptRules` and `reactRules` — makes ESLint fail with `Could not find plugin` the
|
|
54
|
+
// moment a `.js` file is linted. Registering it twice is harmless: it is the same instance,
|
|
55
|
+
// since npm dedupes `typescript-eslint` between this package and `eslint-config-next`.
|
|
56
|
+
plugins: { '@typescript-eslint': tsEslint.plugin },
|
|
39
57
|
rules: tsEslintConfigs.reduce((combinedRules, { rules }) => ({ ...combinedRules, ...(rules ? rules : {}) }), {}),
|
|
40
58
|
},
|
|
41
59
|
]
|
|
@@ -56,11 +74,8 @@ export const flatConfigTypescript = (rulesOnly = false) => defineConfig([
|
|
|
56
74
|
...tsEslint.configs.recommendedTypeChecked,
|
|
57
75
|
...tsEslint.configs.stylisticTypeChecked,
|
|
58
76
|
]),
|
|
59
|
-
{
|
|
60
|
-
files: ['**/*.js', '**/*.mjs'],
|
|
61
|
-
extends: [tsEslint.configs.disableTypeChecked],
|
|
62
|
-
},
|
|
63
77
|
baseConfig,
|
|
78
|
+
jsDisableTypeChecked,
|
|
64
79
|
]);
|
|
65
80
|
export const flatConfigReact = () => defineConfig([
|
|
66
81
|
...flatConfigTypescript(),
|
|
@@ -68,9 +83,11 @@ export const flatConfigReact = () => defineConfig([
|
|
|
68
83
|
reactPlugin.configs.flat['jsx-runtime'],
|
|
69
84
|
reactHooks.configs.flat.recommended,
|
|
70
85
|
reactConfig,
|
|
86
|
+
jsDisableTypeChecked,
|
|
71
87
|
]);
|
|
72
88
|
export const flatConfigNext = () => defineConfig([
|
|
73
89
|
...createRequire(import.meta.url)('eslint-config-next/core-web-vitals'),
|
|
74
90
|
...flatConfigTypescript(true),
|
|
75
91
|
reactConfig,
|
|
92
|
+
jsDisableTypeChecked,
|
|
76
93
|
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartive/eslint-config",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.2",
|
|
4
4
|
"description": "ESLint configuration by smartive",
|
|
5
5
|
"files": [
|
|
6
6
|
"README.md",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"eslint-plugin-prettier": "^5.5.4",
|
|
36
36
|
"eslint-plugin-react": "^7.37.5",
|
|
37
37
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
38
|
-
"globals": "^
|
|
38
|
+
"globals": "^17.0.0",
|
|
39
39
|
"typescript-eslint": "^8.15.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
@@ -52,29 +52,41 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@commitlint/cli": "
|
|
56
|
-
"@commitlint/config-conventional": "
|
|
57
|
-
"@eslint/js": "
|
|
58
|
-
"@smartive/prettier-config": "
|
|
59
|
-
"@types/node": "
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
55
|
+
"@commitlint/cli": "21.2.2",
|
|
56
|
+
"@commitlint/config-conventional": "21.2.2",
|
|
57
|
+
"@eslint/js": "9.39.5",
|
|
58
|
+
"@smartive/prettier-config": "3.1.2",
|
|
59
|
+
"@types/node": "25.9.5",
|
|
60
|
+
"@types/react": "19.2.18",
|
|
61
|
+
"@types/react-dom": "19.2.5",
|
|
62
|
+
"cz-conventional-changelog": "3.3.0",
|
|
63
|
+
"eslint": "9.39.5",
|
|
64
|
+
"eslint-config-next": "16.3.4",
|
|
65
|
+
"husky": "9.1.7",
|
|
66
|
+
"next": "16.3.4",
|
|
67
|
+
"prettier": "3.9.6",
|
|
68
|
+
"react": "19.2.8",
|
|
69
|
+
"react-dom": "19.2.8",
|
|
70
|
+
"typescript": "6.0.3"
|
|
65
71
|
},
|
|
66
72
|
"engines": {
|
|
67
73
|
"node": "^20.19.0 || >=22.12"
|
|
68
74
|
},
|
|
69
75
|
"scripts": {
|
|
70
76
|
"tsc": "tsc",
|
|
77
|
+
"prettier": "prettier --check . --ignore-path .prettierignore-cli",
|
|
78
|
+
"check-types": "tsc --noEmit",
|
|
71
79
|
"build": "rm -rf dist && tsc",
|
|
72
80
|
"commitlint": "commitlint --edit",
|
|
73
|
-
"prepare": "[ ! -f node_modules/.bin/husky ] || husky"
|
|
81
|
+
"prepare": "[ ! -f node_modules/.bin/husky ] || husky",
|
|
82
|
+
"test": "npm run build && tsc --noEmit -p tsconfig.test.json && node --test \"test/**/*.test.ts\""
|
|
74
83
|
},
|
|
75
84
|
"config": {
|
|
76
85
|
"commitizen": {
|
|
77
86
|
"path": "./node_modules/cz-conventional-changelog"
|
|
78
87
|
}
|
|
88
|
+
},
|
|
89
|
+
"allowScripts": {
|
|
90
|
+
"unrs-resolver@1.12.2": true
|
|
79
91
|
}
|
|
80
92
|
}
|