@perfective/eslint-config 0.30.0 → 0.31.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.adoc +185 -60
- package/README.md +53 -40
- package/config/array-func/array-func-config.d.ts +2 -0
- package/config/array-func/array-func-config.js +16 -0
- package/config/cypress/cypress-config.d.ts +10 -0
- package/config/cypress/cypress-config.js +38 -0
- package/config/cypress/index.d.ts +1 -0
- package/config/cypress/index.js +1 -0
- package/config/eslint/eslint-config.d.ts +2 -0
- package/config/eslint/eslint-config.js +8 -0
- package/config/eslint/layout-formatting-rules.d.ts +2 -0
- package/config/eslint/possible-problems-rules.d.ts +2 -0
- package/config/eslint/suggestions-rules.d.ts +2 -0
- package/config/eslint-comments/best-practices-rules.d.ts +2 -0
- package/config/eslint-comments/eslint-comments-config.d.ts +2 -0
- package/config/eslint-comments/eslint-comments-config.js +11 -0
- package/config/eslint-comments/stylistic-issues-rules.d.ts +2 -0
- package/config/import/helpful-warnings-rules.d.ts +2 -0
- package/config/import/import-config.d.ts +4 -0
- package/config/import/import-config.js +46 -0
- package/config/import/index.d.ts +1 -0
- package/config/import/index.js +1 -0
- package/config/import/module-systems-rules.d.ts +2 -0
- package/config/import/rules/no-extraneous-dependencies.d.ts +15 -0
- package/config/import/rules/no-extraneous-dependencies.js +8 -0
- package/config/import/static-analysis-rules.d.ts +2 -0
- package/config/import/style-guide-rules.d.ts +2 -0
- package/config/jest/index.d.ts +1 -0
- package/config/jest/index.js +1 -0
- package/config/jest/jest-config.d.ts +8 -0
- package/config/jest/jest-config.js +128 -0
- package/config/jest/typescript-eslint-jest-rules.d.ts +2 -0
- package/config/jest-dom/index.d.ts +1 -0
- package/config/jest-dom/index.js +1 -0
- package/config/jest-dom/jest-dom-config.d.ts +8 -0
- package/config/jest-dom/jest-dom-config.js +23 -0
- package/config/jsdoc/jsdoc-config.d.ts +3 -0
- package/config/jsdoc/jsdoc-config.js +179 -0
- package/config/node/node-config.d.ts +2 -0
- package/config/node/node-config.js +66 -0
- package/config/perfective-eslint-config.d.ts +6 -0
- package/config/perfective-eslint-config.js +45 -0
- package/config/prefer-arrow/prefer-arrow-config.d.ts +2 -0
- package/config/prefer-arrow/prefer-arrow-config.js +16 -0
- package/config/promise/promise-config.d.ts +2 -0
- package/config/promise/promise-config.js +37 -0
- package/config/rxjs/index.d.ts +1 -0
- package/config/rxjs/index.js +1 -0
- package/config/rxjs/rxjs-config.d.ts +8 -0
- package/config/rxjs/rxjs-config.js +67 -0
- package/config/security/security-config.d.ts +2 -0
- package/config/security/security-config.js +24 -0
- package/config/simple-import-sort/index.d.ts +1 -0
- package/config/simple-import-sort/index.js +1 -0
- package/{rules → config}/simple-import-sort/rules/imports.d.ts +11 -2
- package/config/simple-import-sort/simple-import-sort-config.d.ts +2 -0
- package/config/simple-import-sort/simple-import-sort-config.js +13 -0
- package/config/stylistic/js/stylistic-js-config.d.ts +2 -0
- package/config/stylistic/js/stylistic-js-config.js +200 -0
- package/config/stylistic/jsx/stylistic-jsx-config.d.ts +2 -0
- package/config/stylistic/jsx/stylistic-jsx-config.js +87 -0
- package/config/stylistic/plus/stylistic-plus-config.d.ts +2 -0
- package/config/stylistic/plus/stylistic-plus-config.js +16 -0
- package/config/stylistic/ts/stylistic-ts-config.d.ts +2 -0
- package/config/stylistic/ts/stylistic-ts-config.js +141 -0
- package/config/testing-library/index.d.ts +1 -0
- package/config/testing-library/index.js +1 -0
- package/config/testing-library/testing-library-config.d.ts +8 -0
- package/config/testing-library/testing-library-config.js +45 -0
- package/config/typescript-eslint/extension-rules.d.ts +2 -0
- package/config/typescript-eslint/index.d.ts +1 -0
- package/config/typescript-eslint/index.js +1 -0
- package/{rules → config}/typescript-eslint/rules/typescript-eslint-naming-convention.d.ts +35 -1
- package/config/typescript-eslint/supported-rules.d.ts +2 -0
- package/{rules → config}/typescript-eslint/supported-rules.js +6 -2
- package/config/typescript-eslint/typescript-eslint-config.d.ts +2 -0
- package/config/typescript-eslint/typescript-eslint-config.js +15 -0
- package/config/unicorn/index.d.ts +1 -0
- package/config/unicorn/index.js +1 -0
- package/{rules → config}/unicorn/rules/prevent-abbreviations.d.ts +14 -2
- package/config/unicorn/unicorn-config.d.ts +2 -0
- package/config/unicorn/unicorn-config.js +185 -0
- package/index.d.ts +5 -1766
- package/index.js +5 -102
- package/linter/glob.d.ts +59 -0
- package/linter/glob.js +8 -0
- package/linter/language-options.d.ts +25 -0
- package/linter/language-options.js +45 -0
- package/linter/linter-config.d.ts +13 -0
- package/linter/linter-config.js +6 -0
- package/{config → linter}/node.d.ts +3 -1
- package/{config → linter}/plugin.d.ts +6 -2
- package/package.json +37 -38
- package/config.d.ts +0 -1
- package/config.js +0 -1
- package/cypress.d.ts +0 -6
- package/cypress.js +0 -31
- package/jest-dom.d.ts +0 -1
- package/jest-dom.js +0 -8
- package/jest.d.ts +0 -7
- package/jest.js +0 -29
- package/rules/array-func/index.d.ts +0 -13
- package/rules/array-func/index.js +0 -14
- package/rules/cypress/index.d.ts +0 -29
- package/rules/cypress/index.js +0 -23
- package/rules/eslint/index.d.ts +0 -339
- package/rules/eslint/index.js +0 -6
- package/rules/eslint/layout-formatting.d.ts +0 -64
- package/rules/eslint/possible-problems.d.ts +0 -96
- package/rules/eslint/suggestions.d.ts +0 -181
- package/rules/eslint-comments/best-practices.d.ts +0 -8
- package/rules/eslint-comments/index.d.ts +0 -20
- package/rules/eslint-comments/index.js +0 -9
- package/rules/eslint-comments/stylistic-issues.d.ts +0 -9
- package/rules/import/helpful-warnings.d.ts +0 -10
- package/rules/import/index.d.ts +0 -78
- package/rules/import/index.js +0 -11
- package/rules/import/module-systems.d.ts +0 -10
- package/rules/import/rules/no-extraneous-dependencies.d.ts +0 -14
- package/rules/import/rules/no-extraneous-dependencies.js +0 -23
- package/rules/import/static-analysis.d.ts +0 -26
- package/rules/import/style-guide.d.ts +0 -33
- package/rules/jest/index.d.ts +0 -124
- package/rules/jest/index.js +0 -98
- package/rules/jest/typescript-eslint.d.ts +0 -5
- package/rules/jest-dom/index.d.ts +0 -32
- package/rules/jest-dom/index.js +0 -19
- package/rules/jsdoc/index.d.ts +0 -134
- package/rules/jsdoc/index.js +0 -161
- package/rules/n/index.d.ts +0 -66
- package/rules/n/index.js +0 -64
- package/rules/prefer-arrow/index.d.ts +0 -13
- package/rules/prefer-arrow/index.js +0 -14
- package/rules/promise/index.d.ts +0 -34
- package/rules/promise/index.js +0 -35
- package/rules/rxjs/index.d.ts +0 -60
- package/rules/rxjs/index.js +0 -60
- package/rules/security/index.d.ts +0 -21
- package/rules/security/index.js +0 -22
- package/rules/simple-import-sort/index.d.ts +0 -10
- package/rules/simple-import-sort/index.js +0 -12
- package/rules/stylistic/js/index.d.ts +0 -204
- package/rules/stylistic/js/index.js +0 -198
- package/rules/stylistic/jsx/index.d.ts +0 -87
- package/rules/stylistic/jsx/index.js +0 -81
- package/rules/stylistic/plus/index.d.ts +0 -18
- package/rules/stylistic/plus/index.js +0 -14
- package/rules/stylistic/ts/index.d.ts +0 -141
- package/rules/stylistic/ts/index.js +0 -135
- package/rules/testing-library/index.d.ts +0 -62
- package/rules/testing-library/index.js +0 -41
- package/rules/typescript-eslint/extension-rules.d.ts +0 -113
- package/rules/typescript-eslint/index.d.ts +0 -371
- package/rules/typescript-eslint/index.js +0 -9
- package/rules/typescript-eslint/supported-rules.d.ts +0 -255
- package/rules/unicorn/index.d.ts +0 -183
- package/rules/unicorn/index.js +0 -178
- package/rules.d.ts +0 -4
- package/rules.js +0 -4
- package/rxjs.d.ts +0 -6
- package/rxjs.js +0 -22
- package/testing-library.d.ts +0 -1
- package/testing-library.js +0 -8
- /package/{rules/eslint/layout-formatting.js → config/eslint/layout-formatting-rules.js} +0 -0
- /package/{rules/eslint/possible-problems.js → config/eslint/possible-problems-rules.js} +0 -0
- /package/{rules/eslint/suggestions.js → config/eslint/suggestions-rules.js} +0 -0
- /package/{rules/eslint-comments/best-practices.js → config/eslint-comments/best-practices-rules.js} +0 -0
- /package/{rules/eslint-comments/stylistic-issues.js → config/eslint-comments/stylistic-issues-rules.js} +0 -0
- /package/{rules/import/helpful-warnings.js → config/import/helpful-warnings-rules.js} +0 -0
- /package/{rules/import/module-systems.js → config/import/module-systems-rules.js} +0 -0
- /package/{rules/import/static-analysis.js → config/import/static-analysis-rules.js} +0 -0
- /package/{rules/import/style-guide.js → config/import/style-guide-rules.js} +0 -0
- /package/{rules/jest/typescript-eslint.js → config/jest/typescript-eslint-jest-rules.js} +0 -0
- /package/{rules → config}/simple-import-sort/rules/imports.js +0 -0
- /package/{rules → config}/typescript-eslint/extension-rules.js +0 -0
- /package/{rules → config}/typescript-eslint/rules/typescript-eslint-naming-convention.js +0 -0
- /package/{rules → config}/unicorn/rules/prevent-abbreviations.js +0 -0
- /package/{config → linter}/node.js +0 -0
- /package/{config → linter}/plugin.js +0 -0
package/README.adoc
CHANGED
|
@@ -12,7 +12,7 @@ and https://eslint.style[ESLint Stylistic] plugin rules,
|
|
|
12
12
|
|
|
13
13
|
* `link:https://github.com/freaktechnik/eslint-plugin-array-func[eslint-plugin-array-func]`;
|
|
14
14
|
* `link:https://github.com/cypress-io/eslint-plugin-cypress[eslint-plugin-cypress]` _(optional)_;
|
|
15
|
-
* `link:https://
|
|
15
|
+
* `link:https://eslint-community.github.io/eslint-plugin-eslint-comments/[@eslint-community/eslint-plugin-eslint-comments]`;
|
|
16
16
|
* `link:https://github.com/import-js/eslint-plugin-import[eslint-plugin-import]`;
|
|
17
17
|
* `link:https://github.com/jest-community/eslint-plugin-jest[eslint-plugin-jest]` _(optional)_;
|
|
18
18
|
* `link:https://github.com/testing-library/eslint-plugin-jest-dom[eslint-plugin-jest-dom]` _(optional)_;
|
|
@@ -20,7 +20,7 @@ and https://eslint.style[ESLint Stylistic] plugin rules,
|
|
|
20
20
|
* `link:https://github.com/eslint-community/eslint-plugin-n[eslint-plugin-n]`;
|
|
21
21
|
* `link:https://github.com/TristonJ/eslint-plugin-prefer-arrow[eslint-plugin-prefer-arrow]`;
|
|
22
22
|
* `link:https://github.com/eslint-community/eslint-plugin-promise[eslint-plugin-promise]`;
|
|
23
|
-
* `link:https://github.com/
|
|
23
|
+
* `link:https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x[eslint-plugin-rxjs-x]` _(optional)_;
|
|
24
24
|
* `link:https://github.com/eslint-community/eslint-plugin-security[eslint-plugin-security]`;
|
|
25
25
|
* `link:https://github.com/lydell/eslint-plugin-simple-import-sort[eslint-plugin-simple-import-sort]`;
|
|
26
26
|
* `link:https://github.com/testing-library/eslint-plugin-testing-library[eslint-plugin-testing-library]` _(optional)_;
|
|
@@ -34,63 +34,47 @@ from issues that will be fixed automatically.
|
|
|
34
34
|
|
|
35
35
|
== Setup
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
IMPORTANT: `@perfective/eslint-config` only support ES module syntax.
|
|
38
|
+
If your project uses CommonJS by default
|
|
39
|
+
you need to use `eslint.config.mjs` file instead of `eslint.config.js` to run it in ESM mode.
|
|
40
|
+
|
|
41
|
+
. Install `@perfective/eslint-config` as a dev dependency:
|
|
38
42
|
+
|
|
39
43
|
[source,bash]
|
|
40
44
|
----
|
|
41
|
-
npm install --save-dev
|
|
42
|
-
@perfective/eslint-config \
|
|
43
|
-
@stylistic/eslint-plugin \
|
|
44
|
-
@stylistic/eslint-plugin-js \
|
|
45
|
-
@stylistic/eslint-plugin-jsx \
|
|
46
|
-
@stylistic/eslint-plugin-ts \
|
|
47
|
-
@stylistic/eslint-plugin-plus \
|
|
48
|
-
eslint \
|
|
49
|
-
eslint-import-resolver-typescript \
|
|
50
|
-
eslint-plugin-array-func \
|
|
51
|
-
eslint-plugin-eslint-comments \
|
|
52
|
-
eslint-plugin-import \
|
|
53
|
-
eslint-plugin-jsdoc \
|
|
54
|
-
eslint-plugin-n \
|
|
55
|
-
eslint-plugin-prefer-arrow \
|
|
56
|
-
eslint-plugin-promise \
|
|
57
|
-
eslint-plugin-security \
|
|
58
|
-
eslint-plugin-simple-import-sort \
|
|
59
|
-
eslint-plugin-unicorn \
|
|
60
|
-
typescript-eslint
|
|
45
|
+
npm install --save-dev @perfective/eslint-config
|
|
61
46
|
----
|
|
62
47
|
+
|
|
63
|
-
|
|
48
|
+
Required peer dependencies are installed automatically.
|
|
49
|
+
+
|
|
50
|
+
. Import `perfectiveEslintConfig` to `eslint.config.js`.
|
|
64
51
|
+
|
|
65
52
|
[source,javascript]
|
|
66
53
|
----
|
|
67
|
-
|
|
54
|
+
import { perfectiveEslintConfig } from '@perfective/eslint-config';
|
|
55
|
+
|
|
56
|
+
const eslintConfig = perfectiveEslintConfig();
|
|
68
57
|
|
|
69
|
-
|
|
58
|
+
export default eslintConfig;
|
|
70
59
|
----
|
|
71
60
|
+
|
|
72
|
-
.
|
|
73
|
-
`node_modules` and dot-files are ignored by the `eslint`.
|
|
74
|
-
If more directories or file types need to be ignored, see the
|
|
75
|
-
`link:https://eslint.org/docs/user-guide/configuring/ignoring-code#the-eslintignore-file[.eslintignore]` file docs.
|
|
76
|
-
+
|
|
77
|
-
. Install optional peer dependencies that add linting rules for the tools you use.
|
|
61
|
+
. _Optional_ Install optional peer dependencies to add tool-specific linting rules.
|
|
78
62
|
+
|
|
79
63
|
[source,bash]
|
|
80
64
|
----
|
|
81
65
|
npm install --save-dev \
|
|
82
|
-
@smarttools/eslint-plugin-rxjs \
|
|
83
66
|
eslint-plugin-cypress \
|
|
84
67
|
eslint-plugin-jest \
|
|
85
68
|
eslint-plugin-jest-dom \
|
|
69
|
+
eslint-plugin-rxjs-x \
|
|
86
70
|
eslint-plugin-testing-library
|
|
87
71
|
----
|
|
88
72
|
+
|
|
89
|
-
|
|
73
|
+
Import configurations to `eslint.config.js`.
|
|
90
74
|
+
|
|
91
75
|
[source,javascript]
|
|
92
76
|
----
|
|
93
|
-
import perfectiveEslintConfig from '@perfective/eslint-config';
|
|
77
|
+
import { perfectiveEslintConfig } from '@perfective/eslint-config';
|
|
94
78
|
|
|
95
79
|
// Optional dependencies.
|
|
96
80
|
import { cypressConfig } from '@perfective/eslint-config/cypress';
|
|
@@ -99,19 +83,51 @@ import { jestDomConfig } from '@perfective/eslint-config/jest-dom';
|
|
|
99
83
|
import { rxjsConfig } from '@perfective/eslint-config/rxjs';
|
|
100
84
|
import { testingLibraryConfig } from '@perfective/eslint-config/testing-library';
|
|
101
85
|
|
|
102
|
-
const eslintConfig = [
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
];
|
|
86
|
+
const eslintConfig = perfectiveEslintConfig([
|
|
87
|
+
cypressConfig,
|
|
88
|
+
jestConfig,
|
|
89
|
+
jestDomConfig,
|
|
90
|
+
rxjsConfig,
|
|
91
|
+
testingLibraryConfig,
|
|
92
|
+
]);
|
|
110
93
|
|
|
111
94
|
export default eslintConfig;
|
|
112
95
|
----
|
|
96
|
+
+
|
|
97
|
+
. _Optional_ Customize configuration rules in `eslint.config.js`
|
|
98
|
+
+
|
|
99
|
+
[source,javascript]
|
|
100
|
+
----
|
|
101
|
+
import { perfectiveEslintConfig, typescriptFiles } from '@perfective/eslint-config'; // <.>
|
|
113
102
|
|
|
114
|
-
|
|
103
|
+
const eslintConfig = perfectiveEslintConfig([
|
|
104
|
+
// ...Optional configurations...
|
|
105
|
+
{
|
|
106
|
+
// These rules are overridden to all files
|
|
107
|
+
rules: {
|
|
108
|
+
'@stylistic/js/indent': ['warn', 2],
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
// These rules are overridden to TypeScript files only
|
|
113
|
+
files: typescriptFiles,
|
|
114
|
+
rules: {
|
|
115
|
+
'@stylistic/ts/indent': ['warn', 2],
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
]);
|
|
119
|
+
|
|
120
|
+
export default eslintConfig;
|
|
121
|
+
----
|
|
122
|
+
<.> See the list of available globs below.
|
|
123
|
+
|
|
124
|
+
NOTE: `*.d.ts` files and `dist` directories are ignored by the configuration.
|
|
125
|
+
`node_modules` and dot-files are ignored by the `eslint`.
|
|
126
|
+
If more directories or file types need to be ignored, see the
|
|
127
|
+
`link:https://eslint.org/docs/latest/use/configure/ignore#the-eslintignore-file[.eslintignore]` file docs.
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
== Rules configuration functions
|
|
115
131
|
|
|
116
132
|
Some rules have complex configuration objects or arrays
|
|
117
133
|
that are not merged but are completely overridden by ESLint.
|
|
@@ -119,7 +135,7 @@ Therefore, it requires copying and pasting a rule config instead of just extendi
|
|
|
119
135
|
Maintaining rules updates is challenging
|
|
120
136
|
and is simplified by the custom config functions.
|
|
121
137
|
|
|
122
|
-
These functions and related types are exported
|
|
138
|
+
These functions and related types are exported from the link:#_packages[subpackages]
|
|
123
139
|
and match the rule name in `camelCase`.
|
|
124
140
|
If you need an extended configuration,
|
|
125
141
|
you can use these functions in the `eslint.config.js` file:
|
|
@@ -127,19 +143,18 @@ you can use these functions in the `eslint.config.js` file:
|
|
|
127
143
|
[source,javascript]
|
|
128
144
|
----
|
|
129
145
|
import perfectiveEslintConfig from '@perfective/eslint-config';
|
|
130
|
-
import { simpleImportSortImports } from '@perfective/eslint-config/
|
|
146
|
+
import { simpleImportSortImports } from '@perfective/eslint-config/simple-import-sort'; // <.>
|
|
131
147
|
|
|
132
|
-
const eslintConfig = [
|
|
133
|
-
...
|
|
148
|
+
const eslintConfig = perfectiveEslintConfig([
|
|
149
|
+
// ...Optional configurations...
|
|
134
150
|
{
|
|
135
|
-
files: ['**/*.[jt]s?(x)'],
|
|
136
151
|
rules: {
|
|
137
|
-
'simple-import-sort/imports': ['warn',
|
|
152
|
+
'simple-import-sort/imports': ['warn', simpleImportSortImports([
|
|
138
153
|
'@perfective',
|
|
139
154
|
])],
|
|
140
155
|
},
|
|
141
156
|
},
|
|
142
|
-
];
|
|
157
|
+
]);
|
|
143
158
|
|
|
144
159
|
export default eslintConfig;
|
|
145
160
|
----
|
|
@@ -147,13 +162,123 @@ export default eslintConfig;
|
|
|
147
162
|
So rules should be required from those packages for correct `node_modules` resolution.
|
|
148
163
|
|
|
149
164
|
|
|
150
|
-
|
|
165
|
+
== Packages [#packages]
|
|
166
|
+
|
|
167
|
+
The following is the list of available packages and their exports.
|
|
168
|
+
|
|
169
|
+
=== `@perfective/eslint-config`
|
|
170
|
+
|
|
171
|
+
* `perfectiveEslintConfig`
|
|
172
|
+
— a function that creates an array of flat configs.
|
|
173
|
+
+
|
|
174
|
+
* `type Glob = string`
|
|
175
|
+
a nominal type for glob patterns.
|
|
176
|
+
** `javascriptFiles: Glob[]`
|
|
177
|
+
— a list of glob patterns for JS and JSX files.
|
|
178
|
+
** `jsxFiles: Glob`
|
|
179
|
+
— a glob pattern for JSX files.
|
|
180
|
+
** `typescriptFiles: Glob[]`
|
|
181
|
+
— a list of glob patterns for TypeScript source files.
|
|
182
|
+
** `tsxFiles: Glob`
|
|
183
|
+
— a glob pattern for TSX files.
|
|
184
|
+
** `typescriptDeclarationFiles: Glob`
|
|
185
|
+
— a glob pattern for TypeScript declaration files.
|
|
186
|
+
** `configurationFiles: Glob`
|
|
187
|
+
— a glob pattern for JavaScript tools configuration files.
|
|
188
|
+
** `jestFiles: Glob[]`
|
|
189
|
+
— the link:https://jestjs.io/docs/configuration#testmatch-arraystring[default] glob patterns
|
|
190
|
+
Jest uses to find test files.
|
|
191
|
+
** `cypressFiles: Glob`
|
|
192
|
+
— the link:https://docs.cypress.io/app/references/configuration#e2e[default] glob pattern
|
|
193
|
+
Cypress uses to load test files.
|
|
194
|
+
+
|
|
195
|
+
* ESLint language options:
|
|
196
|
+
** `languageOptions(): Linter.LanguageOptions`
|
|
197
|
+
— creates ESLint `languageOptions` object for all files.
|
|
198
|
+
** `javascriptLanguageOptions(): Linter.LanguageOptions`
|
|
199
|
+
— creates ESLint `languageOptions` object for JavaScript files.
|
|
200
|
+
** `typescriptLanguageOptions(): Linter.LanguageOptions`
|
|
201
|
+
— creates ESLint `languageOptions` object for TypeScript files.
|
|
202
|
+
+
|
|
203
|
+
* `type LinterConfig = Linter.Config | (() => Linter.Config)`
|
|
204
|
+
— an ESLint flat config or a function that returns one.
|
|
205
|
+
** `linterConfig(config: LinterConfig): Linter.Config`
|
|
206
|
+
— a function to instantiate ESLint flat config.
|
|
207
|
+
+
|
|
208
|
+
* Optional plugins:
|
|
209
|
+
** `hasEslintPlugin`
|
|
210
|
+
— returns true if a given ESLint plugin exists.
|
|
211
|
+
** `optionalRule(rule: string, config: unknown): Record<string, unknown>`
|
|
212
|
+
— returns an object with rule as a key
|
|
213
|
+
and its config as a value,
|
|
214
|
+
if a given rule belongs to an installed ESLint plugin.
|
|
215
|
+
|
|
216
|
+
=== `@perfective/eslint-config/cypress`
|
|
217
|
+
|
|
218
|
+
* `cypressConfig(files: Glob[] = [cypressFiles]): Linter.Config`
|
|
219
|
+
— creates a flat config for `eslint-plugin-cypress`
|
|
220
|
+
for a given list of files globs.
|
|
221
|
+
Overrides some rules for `perfectiveEslintConfig` for compatibility with Cypress.
|
|
222
|
+
|
|
223
|
+
=== `@perfective/eslint-config/import`
|
|
224
|
+
|
|
225
|
+
* `interface ImportNoExtraneousDependencies`
|
|
226
|
+
— configuration options for the `import/no-extraneous-dependencies` rule.
|
|
227
|
+
** `importNoExtraneousDependencies(overrides: Partial<ImportNoExtraneousDependencies> = {}): ImportNoExtraneousDependencies`
|
|
228
|
+
— returns configuration options for the `import/no-extraneous-dependencies` rule.
|
|
229
|
+
|
|
230
|
+
=== `@perfective/eslint-config/jest`
|
|
231
|
+
|
|
232
|
+
* `jestConfig(files: Glob[] = jestFiles): Linter.Config`
|
|
233
|
+
— creates a flat config for `eslint-plugin-jest` for a given list of files globs.
|
|
234
|
+
|
|
235
|
+
=== `@perfective/eslint-config/jest-dom`
|
|
236
|
+
|
|
237
|
+
* `jestDomConfig(files: Glob[] = jestFiles): Linter.Config`
|
|
238
|
+
— creates a flat config for `eslint-plugin-jest-dom` for a given list of files globs.
|
|
239
|
+
|
|
240
|
+
=== `@perfective/eslint-config/rxjs`
|
|
241
|
+
|
|
242
|
+
* `rxjsConfig(files: Glob[] = typescriptFiles): Linter.Config`
|
|
243
|
+
— creates a flat config for `eslint-plugin-rxjs-x` for a given list of files globs.
|
|
244
|
+
|
|
245
|
+
=== `@perfective/eslint-config/simple-import-sort`
|
|
246
|
+
|
|
247
|
+
* `interface SimpleImportSortImports`
|
|
248
|
+
— configuration options for the `simple-import-sort/imports` rule.
|
|
249
|
+
** `simpleImportSortImports(internal: string[] = []): SimpleImportSortImports`
|
|
250
|
+
— creates configuration for the `simple-import-sort/imports` ESLint rule.
|
|
251
|
+
Allows to splice `internal` scope packages imports between the global and relative imports.
|
|
252
|
+
|
|
253
|
+
=== `@perfective/eslint-config/testing-library`
|
|
254
|
+
|
|
255
|
+
* `testingLibraryConfig(files: Glob[] = jestFiles): Linter.Config`
|
|
256
|
+
— creates a flat config for `eslint-plugin-testing-library` for a given list of files globs.
|
|
257
|
+
|
|
258
|
+
=== `@perfective/eslint-config/typescript-eslint`
|
|
259
|
+
|
|
260
|
+
* `interface TypescriptEslintNamingConvention`
|
|
261
|
+
— configuration options for the
|
|
262
|
+
`link:https://typescript-eslint.io/rules/naming-convention/[@typescript-eslint/naming-convention]` rule.
|
|
263
|
+
** `type TypescriptEslintNamingConventionSelector`
|
|
264
|
+
— values for the `@typescript-eslint/naming-convention` rule `selector` option.
|
|
265
|
+
*** `type TypescriptEslintNamingConventionIndividualSelector`
|
|
266
|
+
— values for individual selectors for the `@typescript-eslint/naming-convention` rule `selector` option.
|
|
267
|
+
*** `type TypescriptEslintNamingConventionGroupSelector`
|
|
268
|
+
— values for grouped of individual selectors for the `@typescript-eslint/naming-convention` rule `selector` option.
|
|
269
|
+
** `type TypescriptEslintNamingConventionFormat`
|
|
270
|
+
— values for the `@typescript-eslint/naming-convention` rule `format` option.
|
|
271
|
+
** `type TypescriptEslintNamingConventionUnderscore`
|
|
272
|
+
— values for the `@typescript-eslint/naming-convention` rule `leadingUnderscore` and `trailingUnderscore` options.
|
|
273
|
+
** `function typescriptEslintNamingConvention(extensions: TypescriptEslintNamingConvention[] = []): TypescriptEslintNamingConvention[]`
|
|
274
|
+
— creates configuration with the given extensions for the `@typescript-eslint/naming-convention` rule.
|
|
275
|
+
|
|
276
|
+
=== `@perfective/eslint-config/unicorn`
|
|
151
277
|
|
|
152
|
-
* `
|
|
153
|
-
—
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
—
|
|
157
|
-
|
|
158
|
-
—
|
|
159
|
-
and `options` for the `unicorn/prevent-abbreviation` rule.
|
|
278
|
+
* `interface UnicornPreventAbbreviations`
|
|
279
|
+
— configuration options for the
|
|
280
|
+
`link:https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prevent-abbreviations.md[unicorn/prevent-abbreviation]` rule.
|
|
281
|
+
** `type UnicornPreventAbbreviationReplacements`
|
|
282
|
+
— nominal type for the `replacements` option of the `unicorn/prevent-abbreviation` rule.
|
|
283
|
+
** `function unicornPreventAbbreviations( replacements: UnicornPreventAbbreviationReplacements = {}, options: Partial<Pick<UnicornPreventAbbreviations, 'checkProperties'>> = {}): UnicornPreventAbbreviations`
|
|
284
|
+
— creates configuration for the `unicorn/prevent-abbreviation` rule with the given replacements and options.
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ and [ESlint Stylistic](https://eslint.style) plugin rules,
|
|
|
12
12
|
|
|
13
13
|
- [`eslint-plugin-array-func`](https://github.com/freaktechnik/eslint-plugin-array-func);
|
|
14
14
|
- [`eslint-plugin-cypress`](https://github.com/cypress-io/eslint-plugin-cypress) _(optional)_;
|
|
15
|
-
- [`eslint-plugin-eslint-comments`](https://
|
|
15
|
+
- [`eslint-plugin-eslint-comments`](https://eslint-community.github.io/eslint-plugin-eslint-comments/);
|
|
16
16
|
- [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import);
|
|
17
17
|
- [`eslint-plugin-jest`](https://github.com/jest-community/eslint-plugin-jest) _(optional)_;
|
|
18
18
|
- [`eslint-plugin-jest-dom`](https://github.com/testing-library/eslint-plugin-jest-dom) _(optional)_;
|
|
@@ -20,7 +20,7 @@ and [ESlint Stylistic](https://eslint.style) plugin rules,
|
|
|
20
20
|
- [`eslint-plugin-n`](https://github.com/eslint-community/eslint-plugin-n);
|
|
21
21
|
- [`eslint-plugin-prefer-arrow`](https://github.com/TristonJ/eslint-plugin-prefer-arrow);
|
|
22
22
|
- [`eslint-plugin-promise`](https://github.com/eslint-community/eslint-plugin-promise);
|
|
23
|
-
- [`eslint-plugin-rxjs`](https://github.com/
|
|
23
|
+
- [`eslint-plugin-rxjs`](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x) _(optional)_;
|
|
24
24
|
- [`eslint-plugin-security`](https://github.com/eslint-community/eslint-plugin-security);
|
|
25
25
|
- [`eslint-plugin-simple-import-sort`](https://github.com/lydell/eslint-plugin-simple-import-sort);
|
|
26
26
|
- [`eslint-plugin-testing-library`](https://github.com/testing-library/eslint-plugin-testing-library) _(optional)_;
|
|
@@ -33,57 +33,44 @@ from issues that will be fixed automatically.
|
|
|
33
33
|
|
|
34
34
|
## Setup
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
`@perfective/eslint-config` only support ES module syntax.
|
|
37
|
+
If your project uses CommonJS by default
|
|
38
|
+
you need to use `eslint.config.mjs` file instead of `eslint.config.js` to run it in ESM mode.
|
|
39
|
+
|
|
40
|
+
1. Install `@perfective/eslint-config` as a dev dependency:
|
|
37
41
|
|
|
38
42
|
```bash
|
|
39
43
|
npm install --save-dev \
|
|
40
|
-
@perfective/eslint-config
|
|
41
|
-
@stylistic/eslint-plugin \
|
|
42
|
-
@stylistic/eslint-plugin-js \
|
|
43
|
-
@stylistic/eslint-plugin-jsx \
|
|
44
|
-
@stylistic/eslint-plugin-ts \
|
|
45
|
-
@stylistic/eslint-plugin-plus \
|
|
46
|
-
eslint \
|
|
47
|
-
eslint-import-resolver-typescript \
|
|
48
|
-
eslint-plugin-array-func \
|
|
49
|
-
eslint-plugin-eslint-comments \
|
|
50
|
-
eslint-plugin-import \
|
|
51
|
-
eslint-plugin-jsdoc \
|
|
52
|
-
eslint-plugin-n \
|
|
53
|
-
eslint-plugin-prefer-arrow \
|
|
54
|
-
eslint-plugin-promise \
|
|
55
|
-
eslint-plugin-security \
|
|
56
|
-
eslint-plugin-simple-import-sort \
|
|
57
|
-
eslint-plugin-unicorn \
|
|
58
|
-
typescript-eslint
|
|
44
|
+
@perfective/eslint-config
|
|
59
45
|
```
|
|
60
46
|
|
|
61
|
-
|
|
47
|
+
Required peer dependencies are installed automatically.
|
|
48
|
+
|
|
49
|
+
2. Import `perfectiveEslintConfig` to `eslint.config.js`.
|
|
62
50
|
|
|
63
51
|
```javascript
|
|
64
|
-
import perfectiveEslintConfig from '@perfective/eslint-config';
|
|
52
|
+
import { perfectiveEslintConfig } from '@perfective/eslint-config';
|
|
53
|
+
|
|
54
|
+
const eslintConfig = perfectiveEslintConfig();
|
|
65
55
|
|
|
66
|
-
export default
|
|
56
|
+
export default eslintConfig;
|
|
67
57
|
```
|
|
68
58
|
|
|
69
|
-
3. Install optional peer dependencies
|
|
59
|
+
3. _Optional_ Install optional peer dependencies to add tool-specific linting rules.
|
|
70
60
|
|
|
71
61
|
```bash
|
|
72
62
|
npm install --save-dev \
|
|
73
|
-
@smarttools/eslint-plugin-rxjs \
|
|
74
63
|
eslint-plugin-cypress \
|
|
75
64
|
eslint-plugin-jest \
|
|
76
65
|
eslint-plugin-jest-dom \
|
|
66
|
+
eslint-plugin-rxjs-x \
|
|
77
67
|
eslint-plugin-testing-library
|
|
78
68
|
```
|
|
79
69
|
|
|
80
|
-
|
|
81
|
-
if the dependency is installed.
|
|
82
|
-
|
|
83
|
-
4. Add optional configurations to your root `eslint.config.js`.
|
|
70
|
+
Import configurations to `eslint.config.js`.
|
|
84
71
|
|
|
85
72
|
```javascript
|
|
86
|
-
import perfectiveEslintConfig from '@perfective/eslint-config';
|
|
73
|
+
import { perfectiveEslintConfig } from '@perfective/eslint-config';
|
|
87
74
|
|
|
88
75
|
// Optional dependencies.
|
|
89
76
|
import { cypressConfig } from '@perfective/eslint-config/cypress';
|
|
@@ -92,14 +79,40 @@ from issues that will be fixed automatically.
|
|
|
92
79
|
import { rxjsConfig } from '@perfective/eslint-config/rxjs';
|
|
93
80
|
import { testingLibraryConfig } from '@perfective/eslint-config/testing-library';
|
|
94
81
|
|
|
95
|
-
const eslintConfig = [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
82
|
+
const eslintConfig = perfectiveEslintConfig([
|
|
83
|
+
cypressConfig,
|
|
84
|
+
jestConfig,
|
|
85
|
+
jestDomConfig,
|
|
86
|
+
rxjsConfig,
|
|
87
|
+
testingLibraryConfig,
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
export default eslintConfig;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
4. _Optional_ Customize configuration rules in `eslint.config.js`
|
|
94
|
+
|
|
95
|
+
```javascript
|
|
96
|
+
import { perfectiveEslintConfig, typescriptFiles } from '@perfective/eslint-config';
|
|
97
|
+
|
|
98
|
+
const eslintConfig = perfectiveEslintConfig([
|
|
99
|
+
// ...Optional configurations...
|
|
100
|
+
{
|
|
101
|
+
// These rules are overridden to all files
|
|
102
|
+
rules: {
|
|
103
|
+
'@stylistic/js/indent': ['warn', 2],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
// These rules are overridden to TypeScript files only
|
|
108
|
+
files: typescriptFiles,
|
|
109
|
+
rules: {
|
|
110
|
+
'@stylistic/ts/indent': ['warn', 2],
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
]);
|
|
103
114
|
|
|
104
115
|
export default eslintConfig;
|
|
105
116
|
```
|
|
117
|
+
|
|
118
|
+
Read full [`documentation`](https://github.com/perfective/eslint-config/blob/main/README.adoc) in the repo.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import eslintPluginArrayFunc from 'eslint-plugin-array-func';
|
|
2
|
+
export function arrayFuncConfig() {
|
|
3
|
+
return {
|
|
4
|
+
plugins: {
|
|
5
|
+
'array-func': eslintPluginArrayFunc
|
|
6
|
+
},
|
|
7
|
+
rules: {
|
|
8
|
+
'array-func/from-map': 'warn',
|
|
9
|
+
'array-func/no-unnecessary-this-arg': 'error',
|
|
10
|
+
'array-func/prefer-array-from': 'warn',
|
|
11
|
+
'array-func/avoid-reverse': 'warn',
|
|
12
|
+
'array-func/prefer-flat-map': 'off',
|
|
13
|
+
'array-func/prefer-flat': 'off'
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Linter } from 'eslint';
|
|
2
|
+
import { Glob } from '../../linter/glob';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a flat config for `eslint-plugin-cypress` for a given list of files globs.
|
|
5
|
+
*
|
|
6
|
+
* Overrides some rules for `perfectiveEslintConfig` for compatibility with Cypress.
|
|
7
|
+
*
|
|
8
|
+
* @since v0.31.0
|
|
9
|
+
*/
|
|
10
|
+
export declare function cypressConfig(files?: Glob[]): Linter.Config;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import eslintPluginCypress from 'eslint-plugin-cypress/flat';
|
|
2
|
+
import { cypressFiles } from "../../linter/glob.js";
|
|
3
|
+
import { importNoExtraneousDependencies } from "../import/rules/no-extraneous-dependencies.js";
|
|
4
|
+
export function cypressConfig(files = [cypressFiles]) {
|
|
5
|
+
return {
|
|
6
|
+
files,
|
|
7
|
+
plugins: {
|
|
8
|
+
cypress: eslintPluginCypress
|
|
9
|
+
},
|
|
10
|
+
rules: Object.assign({
|
|
11
|
+
'cypress/assertion-before-screenshot': 'error',
|
|
12
|
+
'cypress/no-assigning-return-values': 'error',
|
|
13
|
+
'cypress/no-async-before': 'error',
|
|
14
|
+
'cypress/no-async-tests': 'error',
|
|
15
|
+
'cypress/no-chained-get': 'error',
|
|
16
|
+
'cypress/no-debug': 'error',
|
|
17
|
+
'cypress/no-force': 'error',
|
|
18
|
+
'cypress/no-pause': 'error',
|
|
19
|
+
'cypress/no-unnecessary-waiting': 'error',
|
|
20
|
+
'cypress/no-xpath': 'error',
|
|
21
|
+
'cypress/require-data-selectors': 'error',
|
|
22
|
+
'cypress/unsafe-to-chain-command': 'error'
|
|
23
|
+
}, perfectiveRules())
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function perfectiveRules() {
|
|
27
|
+
return {
|
|
28
|
+
'init-declarations': 'off',
|
|
29
|
+
'@typescript-eslint/init-declarations': 'off',
|
|
30
|
+
'import/no-extraneous-dependencies': ['error', importNoExtraneousDependencies({
|
|
31
|
+
devDependencies: [cypressFiles]
|
|
32
|
+
})],
|
|
33
|
+
'max-nested-callbacks': ['error', 4],
|
|
34
|
+
'new-cap': ['error', {
|
|
35
|
+
capIsNewExceptions: ['Given', 'When', 'Then', 'And', 'But', 'Before', 'After']
|
|
36
|
+
}]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cypressConfig } from './cypress-config';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cypressConfig } from "./cypress-config.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { eslintLayoutFormattingRules } from "./layout-formatting-rules.js";
|
|
2
|
+
import { eslintPossibleProblemsRules } from "./possible-problems-rules.js";
|
|
3
|
+
import { eslintSuggestionsRules } from "./suggestions-rules.js";
|
|
4
|
+
export function eslintConfig() {
|
|
5
|
+
return {
|
|
6
|
+
rules: Object.assign(Object.assign(Object.assign({}, eslintPossibleProblemsRules), eslintSuggestionsRules), eslintLayoutFormattingRules)
|
|
7
|
+
};
|
|
8
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import eslintPluginEslintComments from '@eslint-community/eslint-plugin-eslint-comments';
|
|
2
|
+
import { bestPracticesRules } from "./best-practices-rules.js";
|
|
3
|
+
import { stylisticIssuesRules } from "./stylistic-issues-rules.js";
|
|
4
|
+
export function eslintCommentsConfig() {
|
|
5
|
+
return {
|
|
6
|
+
plugins: {
|
|
7
|
+
'eslint-comments': eslintPluginEslintComments
|
|
8
|
+
},
|
|
9
|
+
rules: Object.assign(Object.assign({}, bestPracticesRules), stylisticIssuesRules)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { flatConfigs } from 'eslint-plugin-import';
|
|
2
|
+
import { javascriptFiles, typescriptFiles } from "../../linter/glob.js";
|
|
3
|
+
import { javascriptLanguageOptions, typescriptLanguageOptions } from "../../linter/language-options.js";
|
|
4
|
+
import { helpfulWarningsRules } from "./helpful-warnings-rules.js";
|
|
5
|
+
import { moduleSystemsRules } from "./module-systems-rules.js";
|
|
6
|
+
import { staticAnalysisRules } from "./static-analysis-rules.js";
|
|
7
|
+
import { styleGuideRules } from "./style-guide-rules.js";
|
|
8
|
+
export function importConfig() {
|
|
9
|
+
return {
|
|
10
|
+
plugins: {
|
|
11
|
+
import: flatConfigs.recommended.plugins.import
|
|
12
|
+
},
|
|
13
|
+
rules: Object.assign(Object.assign(Object.assign(Object.assign({}, staticAnalysisRules), helpfulWarningsRules), moduleSystemsRules), styleGuideRules)
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function importJavascriptConfig() {
|
|
17
|
+
return {
|
|
18
|
+
files: javascriptFiles,
|
|
19
|
+
languageOptions: javascriptLanguageOptions(),
|
|
20
|
+
plugins: {},
|
|
21
|
+
settings: {
|
|
22
|
+
'import/extensions': ['.js', '.jsx']
|
|
23
|
+
},
|
|
24
|
+
rules: {
|
|
25
|
+
'import/no-commonjs': 'off',
|
|
26
|
+
'import/unambiguous': 'off'
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function importTypescriptConfig() {
|
|
31
|
+
return {
|
|
32
|
+
files: typescriptFiles,
|
|
33
|
+
languageOptions: typescriptLanguageOptions(),
|
|
34
|
+
settings: {
|
|
35
|
+
'import/parsers': {
|
|
36
|
+
'@typescript-eslint/parser': ['.ts', '.tsx']
|
|
37
|
+
},
|
|
38
|
+
'import/resolver': {
|
|
39
|
+
typescript: {
|
|
40
|
+
alwaysTryTypes: true,
|
|
41
|
+
project: './tsconfig.json'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ImportNoExtraneousDependencies, importNoExtraneousDependencies, } from './rules/no-extraneous-dependencies';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { importNoExtraneousDependencies } from "./rules/no-extraneous-dependencies.js";
|