@fullstacksjs/eslint-config 12.0.0 → 12.1.1
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 +1 -4
- package/cjs/index.js +6 -6
- package/cjs/modules/tests.js +3 -1
- package/cjs/modules/typescript.js +4 -2
- package/cjs/option.d.ts +70 -0
- package/package.json +1 -1
- package/src/index.mjs +6 -6
- package/src/modules/tests.mjs +2 -0
- package/src/modules/typescript.mjs +5 -2
- package/src/option.d.ts +70 -0
package/README.md
CHANGED
|
@@ -57,10 +57,7 @@ You can fine-tune module detection by overriding it, the `defineConfig` function
|
|
|
57
57
|
```typescript
|
|
58
58
|
interface Options {
|
|
59
59
|
react?: boolean; // controls react, react-hooks, jsx/a11y plugins
|
|
60
|
-
typescript?:
|
|
61
|
-
projectService?: boolean | ProjectService; tsconfigRootDir: string; cacheLifetime?: number; // https://typescript-eslint.io/packages/parser#projectservice
|
|
62
|
-
tsconfigRootDir?: string // https://typescript-eslint.io/packages/parser#tsconfigrootdir
|
|
63
|
-
};
|
|
60
|
+
typescript?: ParserOptions // https://typescript-eslint.io/packages/parser#configuration
|
|
64
61
|
node?: boolean; // controls node plugin
|
|
65
62
|
sort?: boolean; // controls perfectionist plugin
|
|
66
63
|
strict?: boolean; // controls strict rules
|
package/cjs/index.js
CHANGED
|
@@ -97,17 +97,17 @@ function defineConfig(initOptions = {}, ...extend) {
|
|
|
97
97
|
if (enableSort) rules.push((0, _perfectionist.default)(options));
|
|
98
98
|
if (enableImport) rules.push((0, _imports.default)(options));
|
|
99
99
|
if (enableTailwind) rules.push((0, _tailwind.default)(options));
|
|
100
|
-
if (enableTest) rules.push((0, _tests.default)(options));
|
|
101
100
|
if (enableNode) rules.push((0, _node.default)(options));
|
|
102
|
-
if (enableJest) rules.push((0, _jest.default)(options));
|
|
103
|
-
if (enableVitest) rules.push((0, _vitest.default)(options));
|
|
104
|
-
if (enableCypress) rules.push((0, _cypress.default)(options));
|
|
105
101
|
if (enableReact) rules.push((0, _react.default)(options));
|
|
106
102
|
if (enableStorybook) rules.push((0, _storybook.default)(options));
|
|
107
103
|
if (enableTypescript) rules.push((0, _typescript.default)(options));
|
|
108
|
-
if (
|
|
109
|
-
if (enableNext && enableNext) rules.push((0, _next.default)(options));
|
|
104
|
+
if (enableNext) rules.push((0, _next.default)(options));
|
|
110
105
|
if (enablePrettier) rules.push((0, _prettier.default)(options));
|
|
106
|
+
if (enableJest) rules.push((0, _jest.default)(options));
|
|
107
|
+
if (enableVitest) rules.push((0, _vitest.default)(options));
|
|
108
|
+
if (enableTest) rules.push((0, _tests.default)(options));
|
|
109
|
+
if (enableCypress) rules.push((0, _cypress.default)(options));
|
|
110
|
+
if (enablePlaywright) rules.push((0, _playwright.default)(options));
|
|
111
111
|
if (Object.keys(eslintOptions).length > 0) rules.push(eslintOptions);
|
|
112
112
|
if (extend) Array.prototype.push.apply(rules, extend);
|
|
113
113
|
return (0, _config.defineConfig)(rules);
|
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
|
};
|
|
@@ -13,6 +13,7 @@ var _namingConvention = require("../utils/naming-convention.js");
|
|
|
13
13
|
* @return { import('eslint').Linter.Config }
|
|
14
14
|
*/
|
|
15
15
|
function typescript(options = {}) {
|
|
16
|
+
const projectService = options.typescript && options.typescript.tsconfigRootDir && options.typescript.projectService;
|
|
16
17
|
return {
|
|
17
18
|
files: [_globs.globs.ts, _globs.globs.tsx],
|
|
18
19
|
plugins: {
|
|
@@ -55,7 +56,7 @@ function typescript(options = {}) {
|
|
|
55
56
|
'@typescript-eslint/member-naming': 'off',
|
|
56
57
|
'@typescript-eslint/member-ordering': 'off',
|
|
57
58
|
'@typescript-eslint/method-signature-style': ['warn', 'property'],
|
|
58
|
-
'@typescript-eslint/naming-convention': ['warn', ..._namingConvention.namingConvention, ...(
|
|
59
|
+
'@typescript-eslint/naming-convention': ['warn', ..._namingConvention.namingConvention, ...(projectService ? [{
|
|
59
60
|
selector: 'variable',
|
|
60
61
|
types: ['boolean'],
|
|
61
62
|
format: ['PascalCase'],
|
|
@@ -160,7 +161,7 @@ function typescript(options = {}) {
|
|
|
160
161
|
}],
|
|
161
162
|
'@typescript-eslint/unified-signatures': 'error',
|
|
162
163
|
'@typescript-eslint/key-spacing': 'off',
|
|
163
|
-
...(0, _conditions.predicate)(
|
|
164
|
+
...(0, _conditions.predicate)(projectService, {
|
|
164
165
|
'@typescript-eslint/await-thenable': 'error',
|
|
165
166
|
'@typescript-eslint/consistent-return': 'off',
|
|
166
167
|
'@typescript-eslint/consistent-type-exports': 'warn',
|
|
@@ -246,6 +247,7 @@ function typescript(options = {}) {
|
|
|
246
247
|
// Need useless-fragment for JSX return type
|
|
247
248
|
|
|
248
249
|
// Conflicts with @typescript-eslint
|
|
250
|
+
'no-empty-function': 'off',
|
|
249
251
|
'default-case': 'off',
|
|
250
252
|
'import/named': 'off',
|
|
251
253
|
'import/namespace': 'off',
|
package/cjs/option.d.ts
CHANGED
|
@@ -8,23 +8,93 @@ interface ProjectService {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
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
|
+
*/
|
|
11
15
|
react?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
12
19
|
sort?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @default true if you have `next` in your dependencies
|
|
22
|
+
* Controls next plugin.
|
|
23
|
+
*/
|
|
13
24
|
next?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @default true if you have `tailwind` in your dependencies
|
|
27
|
+
* Controls tailwind plugin.
|
|
28
|
+
*/
|
|
14
29
|
tailwind?: boolean | { callees: string[] };
|
|
30
|
+
/**
|
|
31
|
+
* @default false
|
|
32
|
+
* Controls [node plugin](https://www.npmjs.com/package/eslint-plugin-n).
|
|
33
|
+
*/
|
|
15
34
|
node?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @default false
|
|
37
|
+
* Enables all strict rules.
|
|
38
|
+
*/
|
|
16
39
|
strict?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* @default true
|
|
42
|
+
* Controls [import plugin](https://www.npmjs.com/package/eslint-plugin-import-x).
|
|
43
|
+
*/
|
|
17
44
|
import?: boolean | { internalRegExp?: string; lifetime?: number; projects?: string | string[] };
|
|
45
|
+
/**
|
|
46
|
+
* @default true if you have `type: module` in your `package.json`.
|
|
47
|
+
*/
|
|
18
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
|
+
*/
|
|
19
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
|
+
*/
|
|
20
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
|
+
*/
|
|
21
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
|
+
*/
|
|
22
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
|
+
*/
|
|
23
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
|
+
*/
|
|
24
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
|
+
*/
|
|
25
83
|
playwright?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* @default true if you have `typescript` in your dependencies.
|
|
86
|
+
* Controls [typescript plugin](https://www.npmjs.com/package/typescript-eslint).
|
|
87
|
+
*/
|
|
26
88
|
typescript?: { projectService?: boolean | ProjectService; tsconfigRootDir: string; cacheLifetime?: number };
|
|
89
|
+
/**
|
|
90
|
+
* @default false
|
|
91
|
+
* Disables expensive rules.
|
|
92
|
+
*/
|
|
27
93
|
disableExpensiveRules?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* @default []
|
|
96
|
+
* List of globs to ignore.
|
|
97
|
+
*/
|
|
28
98
|
ignores?: string[];
|
|
29
99
|
}
|
|
30
100
|
|
package/package.json
CHANGED
package/src/index.mjs
CHANGED
|
@@ -92,17 +92,17 @@ export function defineConfig(initOptions = {}, ...extend) {
|
|
|
92
92
|
if (enableSort) rules.push(perfectionist(options));
|
|
93
93
|
if (enableImport) rules.push(imports(options));
|
|
94
94
|
if (enableTailwind) rules.push(tailwind(options));
|
|
95
|
-
if (enableTest) rules.push(tests(options));
|
|
96
95
|
if (enableNode) rules.push(node(options));
|
|
97
|
-
if (enableJest) rules.push(jest(options));
|
|
98
|
-
if (enableVitest) rules.push(vitest(options));
|
|
99
|
-
if (enableCypress) rules.push(cypress(options));
|
|
100
96
|
if (enableReact) rules.push(react(options));
|
|
101
97
|
if (enableStorybook) rules.push(storybook(options));
|
|
102
98
|
if (enableTypescript) rules.push(typescript(options));
|
|
103
|
-
if (
|
|
104
|
-
if (enableNext && enableNext) rules.push(next(options));
|
|
99
|
+
if (enableNext) rules.push(next(options));
|
|
105
100
|
if (enablePrettier) rules.push(prettier(options));
|
|
101
|
+
if (enableJest) rules.push(jest(options));
|
|
102
|
+
if (enableVitest) rules.push(vitest(options));
|
|
103
|
+
if (enableTest) rules.push(tests(options));
|
|
104
|
+
if (enableCypress) rules.push(cypress(options));
|
|
105
|
+
if (enablePlaywright) rules.push(playwright(options));
|
|
106
106
|
|
|
107
107
|
if (Object.keys(eslintOptions).length > 0) rules.push(eslintOptions);
|
|
108
108
|
if (extend) Array.prototype.push.apply(rules, extend);
|
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
|
};
|
|
@@ -9,6 +9,8 @@ import { namingConvention } from '../utils/naming-convention.mjs';
|
|
|
9
9
|
* @return { import('eslint').Linter.Config }
|
|
10
10
|
*/
|
|
11
11
|
function typescript(options = {}) {
|
|
12
|
+
const projectService = options.typescript && options.typescript.tsconfigRootDir && options.typescript.projectService;
|
|
13
|
+
|
|
12
14
|
return {
|
|
13
15
|
files: [globs.ts, globs.tsx],
|
|
14
16
|
plugins: { '@typescript-eslint': plugin },
|
|
@@ -54,7 +56,7 @@ function typescript(options = {}) {
|
|
|
54
56
|
'@typescript-eslint/naming-convention': [
|
|
55
57
|
'warn',
|
|
56
58
|
...namingConvention,
|
|
57
|
-
...(
|
|
59
|
+
...(projectService
|
|
58
60
|
? [
|
|
59
61
|
{
|
|
60
62
|
selector: 'variable',
|
|
@@ -142,7 +144,7 @@ function typescript(options = {}) {
|
|
|
142
144
|
'@typescript-eslint/unified-signatures': 'error',
|
|
143
145
|
'@typescript-eslint/key-spacing': 'off',
|
|
144
146
|
|
|
145
|
-
...predicate(
|
|
147
|
+
...predicate(projectService, {
|
|
146
148
|
'@typescript-eslint/await-thenable': 'error',
|
|
147
149
|
'@typescript-eslint/consistent-return': 'off',
|
|
148
150
|
'@typescript-eslint/consistent-type-exports': 'warn',
|
|
@@ -218,6 +220,7 @@ function typescript(options = {}) {
|
|
|
218
220
|
'react/jsx-no-useless-fragment': 'off', // Need useless-fragment for JSX return type
|
|
219
221
|
|
|
220
222
|
// Conflicts with @typescript-eslint
|
|
223
|
+
'no-empty-function': 'off',
|
|
221
224
|
'default-case': 'off',
|
|
222
225
|
'import/named': 'off',
|
|
223
226
|
'import/namespace': 'off',
|
package/src/option.d.ts
CHANGED
|
@@ -8,23 +8,93 @@ interface ProjectService {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
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
|
+
*/
|
|
11
15
|
react?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
12
19
|
sort?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @default true if you have `next` in your dependencies
|
|
22
|
+
* Controls next plugin.
|
|
23
|
+
*/
|
|
13
24
|
next?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @default true if you have `tailwind` in your dependencies
|
|
27
|
+
* Controls tailwind plugin.
|
|
28
|
+
*/
|
|
14
29
|
tailwind?: boolean | { callees: string[] };
|
|
30
|
+
/**
|
|
31
|
+
* @default false
|
|
32
|
+
* Controls [node plugin](https://www.npmjs.com/package/eslint-plugin-n).
|
|
33
|
+
*/
|
|
15
34
|
node?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @default false
|
|
37
|
+
* Enables all strict rules.
|
|
38
|
+
*/
|
|
16
39
|
strict?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* @default true
|
|
42
|
+
* Controls [import plugin](https://www.npmjs.com/package/eslint-plugin-import-x).
|
|
43
|
+
*/
|
|
17
44
|
import?: boolean | { internalRegExp?: string; lifetime?: number; projects?: string | string[] };
|
|
45
|
+
/**
|
|
46
|
+
* @default true if you have `type: module` in your `package.json`.
|
|
47
|
+
*/
|
|
18
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
|
+
*/
|
|
19
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
|
+
*/
|
|
20
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
|
+
*/
|
|
21
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
|
+
*/
|
|
22
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
|
+
*/
|
|
23
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
|
+
*/
|
|
24
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
|
+
*/
|
|
25
83
|
playwright?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* @default true if you have `typescript` in your dependencies.
|
|
86
|
+
* Controls [typescript plugin](https://www.npmjs.com/package/typescript-eslint).
|
|
87
|
+
*/
|
|
26
88
|
typescript?: { projectService?: boolean | ProjectService; tsconfigRootDir: string; cacheLifetime?: number };
|
|
89
|
+
/**
|
|
90
|
+
* @default false
|
|
91
|
+
* Disables expensive rules.
|
|
92
|
+
*/
|
|
27
93
|
disableExpensiveRules?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* @default []
|
|
96
|
+
* List of globs to ignore.
|
|
97
|
+
*/
|
|
28
98
|
ignores?: string[];
|
|
29
99
|
}
|
|
30
100
|
|