@fullstacksjs/eslint-config 11.10.3 → 12.1.0
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 +26 -27
- package/cjs/index.js +1 -4
- package/cjs/modules/tests.js +3 -1
- package/cjs/modules/typescript.js +2 -6
- package/cjs/option.d.ts +78 -1
- package/package.json +6 -6
- package/src/index.mjs +1 -4
- package/src/modules/tests.mjs +2 -0
- package/src/modules/typescript.mjs +2 -6
- package/src/option.d.ts +78 -1
package/README.md
CHANGED
|
@@ -27,7 +27,11 @@ To use the configuration, all you need is to export the generated config by the
|
|
|
27
27
|
```js
|
|
28
28
|
import { defineConfig } from '@fullstacksjs/eslint-config';
|
|
29
29
|
|
|
30
|
-
export default defineConfig(
|
|
30
|
+
export default defineConfig({
|
|
31
|
+
typescript: {
|
|
32
|
+
tsconfigRootDir: import.meta.dirname, // If you are using TypeScript
|
|
33
|
+
}
|
|
34
|
+
});
|
|
31
35
|
```
|
|
32
36
|
|
|
33
37
|
### CJS
|
|
@@ -35,7 +39,9 @@ export default defineConfig();
|
|
|
35
39
|
```js
|
|
36
40
|
const { defineConfig } = require('@fullstacksjs/eslint-config');
|
|
37
41
|
|
|
38
|
-
module.exports = defineConfig(
|
|
42
|
+
module.exports = defineConfig({
|
|
43
|
+
tsconfigRootDir: import.meta.dirname, // If you are using TypeScript
|
|
44
|
+
});
|
|
39
45
|
```
|
|
40
46
|
|
|
41
47
|
## How Module Detection Works
|
|
@@ -50,30 +56,23 @@ You can fine-tune module detection by overriding it, the `defineConfig` function
|
|
|
50
56
|
|
|
51
57
|
```typescript
|
|
52
58
|
interface Options {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
cypress?: boolean; // controls cypress plugin
|
|
71
|
-
playwright?: boolean // controls playwright plugin
|
|
72
|
-
storybook?: boolean; // controls storybook plugin
|
|
73
|
-
tailwind?: boolean | { callee?: string[] }; // controls tailwindcss plugin
|
|
74
|
-
next?: boolean; // controls next plugin
|
|
75
|
-
prettier?: boolean; // controls prettier plugin
|
|
76
|
-
disableExpensiveRules?: boolean; // controls expensive rules
|
|
59
|
+
react?: boolean; // controls react, react-hooks, jsx/a11y plugins
|
|
60
|
+
typescript?: ParserOptions // https://typescript-eslint.io/packages/parser#configuration
|
|
61
|
+
node?: boolean; // controls node plugin
|
|
62
|
+
sort?: boolean; // controls perfectionist plugin
|
|
63
|
+
strict?: boolean; // controls strict rules
|
|
64
|
+
import?: { internalRegExp?: string; lifetime?: number; }; // controls import plugin
|
|
65
|
+
esm?: boolean; // controls esm plugin
|
|
66
|
+
test?: boolean; // controls test formatting plugin
|
|
67
|
+
jest?: boolean; // controls jest plugin
|
|
68
|
+
vitest?: boolean; // controls vitest plugin
|
|
69
|
+
cypress?: boolean; // controls cypress plugin
|
|
70
|
+
playwright?: boolean // controls playwright plugin
|
|
71
|
+
storybook?: boolean; // controls storybook plugin
|
|
72
|
+
tailwind?: boolean | { callee?: string[] }; // controls tailwindcss plugin
|
|
73
|
+
next?: boolean; // controls next plugin
|
|
74
|
+
prettier?: boolean; // controls prettier plugin
|
|
75
|
+
disableExpensiveRules?: boolean; // controls expensive rules
|
|
77
76
|
}
|
|
78
77
|
```
|
|
79
78
|
|
|
@@ -110,7 +109,7 @@ import { defineConfig } from '@fullstacksjs/eslint-config';
|
|
|
110
109
|
import pluginVue from 'eslint-plugin-vue';
|
|
111
110
|
|
|
112
111
|
export default defineConfig(
|
|
113
|
-
{
|
|
112
|
+
{ /* Options */},
|
|
114
113
|
...pluginVue.configs['flat/recommended']
|
|
115
114
|
)
|
|
116
115
|
```
|
package/cjs/index.js
CHANGED
|
@@ -53,7 +53,7 @@ const defaultOptions = {
|
|
|
53
53
|
// ISSUE: https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/325,
|
|
54
54
|
test: testPackages.some(p => (0, _localPkg.isPackageExists)(p)),
|
|
55
55
|
typescript: (0, _localPkg.isPackageExists)('typescript') ? {
|
|
56
|
-
|
|
56
|
+
projectService: true
|
|
57
57
|
} : false,
|
|
58
58
|
vitest: (0, _localPkg.isPackageExists)('vitest')
|
|
59
59
|
};
|
|
@@ -69,9 +69,6 @@ function defineConfig(initOptions = {}, ...extend) {
|
|
|
69
69
|
if (options.tailwind === true) {
|
|
70
70
|
options.tailwind = {};
|
|
71
71
|
}
|
|
72
|
-
if (options.typescript === true) {
|
|
73
|
-
options.typescript = {};
|
|
74
|
-
}
|
|
75
72
|
if (options.import === true) {
|
|
76
73
|
options.import = {};
|
|
77
74
|
}
|
package/cjs/modules/tests.js
CHANGED
|
@@ -34,6 +34,7 @@ function tests(options = {}) {
|
|
|
34
34
|
'jest-formatting/padding-around-test-blocks': 'warn',
|
|
35
35
|
'max-lines-per-function': 'off',
|
|
36
36
|
'no-sparse-arrays': 'off',
|
|
37
|
+
'no-empty-function': 'off',
|
|
37
38
|
...(0, _conditions.predicate)(options.react, {
|
|
38
39
|
'react/jsx-no-constructed-context-values': 'off'
|
|
39
40
|
}),
|
|
@@ -42,7 +43,8 @@ function tests(options = {}) {
|
|
|
42
43
|
'@typescript-eslint/no-namespace': 'off',
|
|
43
44
|
'@typescript-eslint/unbound-method': 'off',
|
|
44
45
|
'@typescript-eslint/no-empty-function': 'off',
|
|
45
|
-
'@typescript-eslint/no-floating-promises': 'off'
|
|
46
|
+
'@typescript-eslint/no-floating-promises': 'off',
|
|
47
|
+
'@typescript-eslint/prefer-promise-reject-errors': 'off'
|
|
46
48
|
})
|
|
47
49
|
}
|
|
48
50
|
};
|
|
@@ -21,12 +21,7 @@ function typescript(options = {}) {
|
|
|
21
21
|
languageOptions: {
|
|
22
22
|
parser: _typescriptEslint.parser,
|
|
23
23
|
parserOptions: {
|
|
24
|
-
...
|
|
25
|
-
project: options.typescript.projects
|
|
26
|
-
}),
|
|
27
|
-
...(0, _conditions.predicate)(options.typescript && options.typescript.tsconfigRootDir, {
|
|
28
|
-
tsconfigRootDir: options.typescript.tsconfigRootDir
|
|
29
|
-
})
|
|
24
|
+
...options.typescript
|
|
30
25
|
}
|
|
31
26
|
},
|
|
32
27
|
rules: {
|
|
@@ -251,6 +246,7 @@ function typescript(options = {}) {
|
|
|
251
246
|
// Need useless-fragment for JSX return type
|
|
252
247
|
|
|
253
248
|
// Conflicts with @typescript-eslint
|
|
249
|
+
'no-empty-function': 'off',
|
|
254
250
|
'default-case': 'off',
|
|
255
251
|
'import/named': 'off',
|
|
256
252
|
'import/namespace': 'off',
|
package/cjs/option.d.ts
CHANGED
|
@@ -1,23 +1,100 @@
|
|
|
1
1
|
import type { Linter } from 'eslint';
|
|
2
2
|
|
|
3
|
+
interface ProjectService {
|
|
4
|
+
allowDefaultProject: string[];
|
|
5
|
+
defaultProject: string;
|
|
6
|
+
loadTypeScriptPlugins: boolean;
|
|
7
|
+
maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
3
10
|
export interface Options extends Linter.Config {
|
|
11
|
+
/**
|
|
12
|
+
* @default true if you have `react` or `react-dom` in your dependencies
|
|
13
|
+
* Controls react plugin.
|
|
14
|
+
*/
|
|
4
15
|
react?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
5
19
|
sort?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @default true if you have `next` in your dependencies
|
|
22
|
+
* Controls next plugin.
|
|
23
|
+
*/
|
|
6
24
|
next?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @default true if you have `tailwind` in your dependencies
|
|
27
|
+
* Controls tailwind plugin.
|
|
28
|
+
*/
|
|
7
29
|
tailwind?: boolean | { callees: string[] };
|
|
30
|
+
/**
|
|
31
|
+
* @default false
|
|
32
|
+
* Controls [node plugin](https://www.npmjs.com/package/eslint-plugin-n).
|
|
33
|
+
*/
|
|
8
34
|
node?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @default false
|
|
37
|
+
* Enables all strict rules.
|
|
38
|
+
*/
|
|
9
39
|
strict?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* @default true
|
|
42
|
+
* Controls [import plugin](https://www.npmjs.com/package/eslint-plugin-import-x).
|
|
43
|
+
*/
|
|
10
44
|
import?: boolean | { internalRegExp?: string; lifetime?: number; projects?: string | string[] };
|
|
45
|
+
/**
|
|
46
|
+
* @default true if you have `type: module` in your `package.json`.
|
|
47
|
+
*/
|
|
11
48
|
esm?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* @default true if you have one of `jest`, `vitest`, `cypress`, `playwright`, `storybook`, `prettier` in your dependencies.
|
|
51
|
+
* Controls [test plugin](https://www.npmjs.com/package/eslint-plugin-jest-formatting).
|
|
52
|
+
*/
|
|
12
53
|
test?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* @default true if you have `jest` in your dependencies.
|
|
56
|
+
* Controls [jest plugin](https://www.npmjs.com/package/eslint-plugin-jest).
|
|
57
|
+
*/
|
|
13
58
|
jest?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* @default true if you have `vitest` in your dependencies.
|
|
61
|
+
* Controls [vitest plugin](https://www.npmjs.com/package/eslint-plugin-vitest).
|
|
62
|
+
*/
|
|
14
63
|
vitest?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* @default true if you have `cypress` in your dependencies.
|
|
66
|
+
* Controls [cypress plugin](https://www.npmjs.com/package/eslint-plugin-cypress).
|
|
67
|
+
*/
|
|
15
68
|
cypress?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* @default true if you have `storybook` in your dependencies.
|
|
71
|
+
* Controls [storybook plugin](https://www.npmjs.com/package/eslint-plugin-storybook).
|
|
72
|
+
*/
|
|
16
73
|
storybook?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* @default true if you have `prettier` in your dependencies.
|
|
76
|
+
* Controls [prettier plugin](https://www.npmjs.com/package/eslint-plugin-prettier).
|
|
77
|
+
*/
|
|
17
78
|
prettier?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* @default true if you have `playwright` in your dependencies.
|
|
81
|
+
* Controls [playwright plugin](https://www.npmjs.com/package/eslint-plugin-playwright).
|
|
82
|
+
*/
|
|
18
83
|
playwright?: boolean;
|
|
19
|
-
|
|
84
|
+
/**
|
|
85
|
+
* @default true if you have `typescript` in your dependencies.
|
|
86
|
+
* Controls [typescript plugin](https://www.npmjs.com/package/typescript-eslint).
|
|
87
|
+
*/
|
|
88
|
+
typescript?: { projectService?: boolean | ProjectService; tsconfigRootDir: string; cacheLifetime?: number };
|
|
89
|
+
/**
|
|
90
|
+
* @default false
|
|
91
|
+
* Disables expensive rules.
|
|
92
|
+
*/
|
|
20
93
|
disableExpensiveRules?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* @default []
|
|
96
|
+
* List of globs to ignore.
|
|
97
|
+
*/
|
|
21
98
|
ignores?: string[];
|
|
22
99
|
}
|
|
23
100
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fullstacksjs/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "fullstacks <fullstacksjs@gmail.com>",
|
|
6
6
|
"description": "fullstacks eslint config",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"eslint-plugin-vitest": "0.5.4",
|
|
55
55
|
"globals": "16.0.0",
|
|
56
56
|
"local-pkg": "1.1.1",
|
|
57
|
-
"typescript-eslint": "8.
|
|
57
|
+
"typescript-eslint": "8.29.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@eslint/eslintrc": "3.3.1",
|
|
@@ -63,16 +63,16 @@
|
|
|
63
63
|
"@semantic-release/npm": "12.0.1",
|
|
64
64
|
"@semantic-release/release-notes-generator": "14.0.3",
|
|
65
65
|
"@types/eslint": "9.6.1",
|
|
66
|
-
"cspell": "8.
|
|
67
|
-
"eslint": "9.
|
|
66
|
+
"cspell": "8.18.1",
|
|
67
|
+
"eslint": "9.24.0",
|
|
68
68
|
"husky": "9.1.7",
|
|
69
69
|
"jest": "29.7.0",
|
|
70
|
-
"lint-staged": "15.5.
|
|
70
|
+
"lint-staged": "15.5.1",
|
|
71
71
|
"np": "10.2.0",
|
|
72
72
|
"pinst": "3.0.0",
|
|
73
73
|
"prettier": "3.5.3",
|
|
74
74
|
"semantic-release": "24.2.3",
|
|
75
|
-
"typescript": "5.8.
|
|
75
|
+
"typescript": "5.8.3",
|
|
76
76
|
"unbuild": "3.5.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
package/src/index.mjs
CHANGED
|
@@ -45,7 +45,7 @@ const defaultOptions = {
|
|
|
45
45
|
strict: false,
|
|
46
46
|
tailwind: false, // ISSUE: https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/325,
|
|
47
47
|
test: testPackages.some(p => isPackageExists(p)),
|
|
48
|
-
typescript: isPackageExists('typescript') ? {
|
|
48
|
+
typescript: isPackageExists('typescript') ? { projectService: true } : false,
|
|
49
49
|
vitest: isPackageExists('vitest'),
|
|
50
50
|
};
|
|
51
51
|
|
|
@@ -61,9 +61,6 @@ export function defineConfig(initOptions = {}, ...extend) {
|
|
|
61
61
|
if (options.tailwind === true) {
|
|
62
62
|
options.tailwind = {};
|
|
63
63
|
}
|
|
64
|
-
if (options.typescript === true) {
|
|
65
|
-
options.typescript = {};
|
|
66
|
-
}
|
|
67
64
|
if (options.import === true) {
|
|
68
65
|
options.import = {};
|
|
69
66
|
}
|
package/src/modules/tests.mjs
CHANGED
|
@@ -25,6 +25,7 @@ function tests(options = {}) {
|
|
|
25
25
|
|
|
26
26
|
'max-lines-per-function': 'off',
|
|
27
27
|
'no-sparse-arrays': 'off',
|
|
28
|
+
'no-empty-function': 'off',
|
|
28
29
|
|
|
29
30
|
...predicate(options.react, {
|
|
30
31
|
'react/jsx-no-constructed-context-values': 'off',
|
|
@@ -36,6 +37,7 @@ function tests(options = {}) {
|
|
|
36
37
|
'@typescript-eslint/unbound-method': 'off',
|
|
37
38
|
'@typescript-eslint/no-empty-function': 'off',
|
|
38
39
|
'@typescript-eslint/no-floating-promises': 'off',
|
|
40
|
+
'@typescript-eslint/prefer-promise-reject-errors': 'off',
|
|
39
41
|
}),
|
|
40
42
|
},
|
|
41
43
|
};
|
|
@@ -15,12 +15,7 @@ function typescript(options = {}) {
|
|
|
15
15
|
languageOptions: {
|
|
16
16
|
parser,
|
|
17
17
|
parserOptions: {
|
|
18
|
-
...
|
|
19
|
-
project: options.typescript.projects,
|
|
20
|
-
}),
|
|
21
|
-
...predicate(options.typescript && options.typescript.tsconfigRootDir, {
|
|
22
|
-
tsconfigRootDir: options.typescript.tsconfigRootDir,
|
|
23
|
-
}),
|
|
18
|
+
...options.typescript,
|
|
24
19
|
},
|
|
25
20
|
},
|
|
26
21
|
rules: {
|
|
@@ -223,6 +218,7 @@ function typescript(options = {}) {
|
|
|
223
218
|
'react/jsx-no-useless-fragment': 'off', // Need useless-fragment for JSX return type
|
|
224
219
|
|
|
225
220
|
// Conflicts with @typescript-eslint
|
|
221
|
+
'no-empty-function': 'off',
|
|
226
222
|
'default-case': 'off',
|
|
227
223
|
'import/named': 'off',
|
|
228
224
|
'import/namespace': 'off',
|
package/src/option.d.ts
CHANGED
|
@@ -1,23 +1,100 @@
|
|
|
1
1
|
import type { Linter } from 'eslint';
|
|
2
2
|
|
|
3
|
+
interface ProjectService {
|
|
4
|
+
allowDefaultProject: string[];
|
|
5
|
+
defaultProject: string;
|
|
6
|
+
loadTypeScriptPlugins: boolean;
|
|
7
|
+
maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
3
10
|
export interface Options extends Linter.Config {
|
|
11
|
+
/**
|
|
12
|
+
* @default true if you have `react` or `react-dom` in your dependencies
|
|
13
|
+
* Controls react plugin.
|
|
14
|
+
*/
|
|
4
15
|
react?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
5
19
|
sort?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @default true if you have `next` in your dependencies
|
|
22
|
+
* Controls next plugin.
|
|
23
|
+
*/
|
|
6
24
|
next?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @default true if you have `tailwind` in your dependencies
|
|
27
|
+
* Controls tailwind plugin.
|
|
28
|
+
*/
|
|
7
29
|
tailwind?: boolean | { callees: string[] };
|
|
30
|
+
/**
|
|
31
|
+
* @default false
|
|
32
|
+
* Controls [node plugin](https://www.npmjs.com/package/eslint-plugin-n).
|
|
33
|
+
*/
|
|
8
34
|
node?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @default false
|
|
37
|
+
* Enables all strict rules.
|
|
38
|
+
*/
|
|
9
39
|
strict?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* @default true
|
|
42
|
+
* Controls [import plugin](https://www.npmjs.com/package/eslint-plugin-import-x).
|
|
43
|
+
*/
|
|
10
44
|
import?: boolean | { internalRegExp?: string; lifetime?: number; projects?: string | string[] };
|
|
45
|
+
/**
|
|
46
|
+
* @default true if you have `type: module` in your `package.json`.
|
|
47
|
+
*/
|
|
11
48
|
esm?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* @default true if you have one of `jest`, `vitest`, `cypress`, `playwright`, `storybook`, `prettier` in your dependencies.
|
|
51
|
+
* Controls [test plugin](https://www.npmjs.com/package/eslint-plugin-jest-formatting).
|
|
52
|
+
*/
|
|
12
53
|
test?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* @default true if you have `jest` in your dependencies.
|
|
56
|
+
* Controls [jest plugin](https://www.npmjs.com/package/eslint-plugin-jest).
|
|
57
|
+
*/
|
|
13
58
|
jest?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* @default true if you have `vitest` in your dependencies.
|
|
61
|
+
* Controls [vitest plugin](https://www.npmjs.com/package/eslint-plugin-vitest).
|
|
62
|
+
*/
|
|
14
63
|
vitest?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* @default true if you have `cypress` in your dependencies.
|
|
66
|
+
* Controls [cypress plugin](https://www.npmjs.com/package/eslint-plugin-cypress).
|
|
67
|
+
*/
|
|
15
68
|
cypress?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* @default true if you have `storybook` in your dependencies.
|
|
71
|
+
* Controls [storybook plugin](https://www.npmjs.com/package/eslint-plugin-storybook).
|
|
72
|
+
*/
|
|
16
73
|
storybook?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* @default true if you have `prettier` in your dependencies.
|
|
76
|
+
* Controls [prettier plugin](https://www.npmjs.com/package/eslint-plugin-prettier).
|
|
77
|
+
*/
|
|
17
78
|
prettier?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* @default true if you have `playwright` in your dependencies.
|
|
81
|
+
* Controls [playwright plugin](https://www.npmjs.com/package/eslint-plugin-playwright).
|
|
82
|
+
*/
|
|
18
83
|
playwright?: boolean;
|
|
19
|
-
|
|
84
|
+
/**
|
|
85
|
+
* @default true if you have `typescript` in your dependencies.
|
|
86
|
+
* Controls [typescript plugin](https://www.npmjs.com/package/typescript-eslint).
|
|
87
|
+
*/
|
|
88
|
+
typescript?: { projectService?: boolean | ProjectService; tsconfigRootDir: string; cacheLifetime?: number };
|
|
89
|
+
/**
|
|
90
|
+
* @default false
|
|
91
|
+
* Disables expensive rules.
|
|
92
|
+
*/
|
|
20
93
|
disableExpensiveRules?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* @default []
|
|
96
|
+
* List of globs to ignore.
|
|
97
|
+
*/
|
|
21
98
|
ignores?: string[];
|
|
22
99
|
}
|
|
23
100
|
|