@w5s/eslint-config 1.0.0-alpha.4 → 1.0.0-alpha.41
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/es.js +2 -2
- package/functional.js +1 -1
- package/ignore.js +40 -0
- package/index.js +35 -3
- package/json.js +186 -5
- package/package.json +56 -30
- package/rules/_rule.js +2 -2
- package/rules/base.js +28 -3
- package/rules/import.js +10 -1
- package/rules/jest.js +13 -16
- package/rules/jsdoc.js +13 -13
- package/rules/prettier.js +38 -8
- package/rules/promise.js +11 -0
- package/rules/react.js +1 -1
- package/rules/typescript.js +16 -4
- package/rules/unicorn.js +5 -1
- package/ts.js +0 -1
- package/yml.js +11 -0
package/es.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
module.exports = {
|
|
3
3
|
extends: [
|
|
4
4
|
require.resolve('./rules/base'),
|
|
5
|
+
require.resolve('./rules/promise'),
|
|
5
6
|
require.resolve('./rules/jsdoc'),
|
|
6
7
|
require.resolve('./rules/import'),
|
|
7
8
|
require.resolve('./rules/unicorn'),
|
|
8
|
-
'prettier',
|
|
9
9
|
require.resolve('./rules/prettier'),
|
|
10
10
|
],
|
|
11
11
|
parser: '@babel/eslint-parser',
|
|
12
12
|
parserOptions: {
|
|
13
13
|
babelOptions: {
|
|
14
|
-
plugins: [
|
|
14
|
+
plugins: [],
|
|
15
15
|
},
|
|
16
16
|
ecmaFeatures: {
|
|
17
17
|
jsx: true,
|
package/functional.js
CHANGED
package/ignore.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const findUp = require('find-up');
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
const parseGitignore = require('parse-gitignore');
|
|
6
|
+
|
|
7
|
+
const getGitignore = () => {
|
|
8
|
+
const found = findUp.sync('.gitignore');
|
|
9
|
+
if (found) {
|
|
10
|
+
return parseGitignore.parse(fs.readFileSync(found)).patterns;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return [];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
ignorePatterns: [
|
|
18
|
+
'!.*',
|
|
19
|
+
'.yarn',
|
|
20
|
+
'.common/',
|
|
21
|
+
'.config/package-lock.json',
|
|
22
|
+
'.config/yarn.lock',
|
|
23
|
+
'.go/',
|
|
24
|
+
'.modules/',
|
|
25
|
+
'.pnpm-store/',
|
|
26
|
+
'.venv/',
|
|
27
|
+
'deprecated/',
|
|
28
|
+
'angular.json',
|
|
29
|
+
'esbuild.js',
|
|
30
|
+
'package-lock.json',
|
|
31
|
+
'pnpm-lock.yaml',
|
|
32
|
+
'slim.report.json',
|
|
33
|
+
'test-output/',
|
|
34
|
+
'venv/',
|
|
35
|
+
'yarn.lock',
|
|
36
|
+
'_generated_/',
|
|
37
|
+
'*.toml',
|
|
38
|
+
...getGitignore(),
|
|
39
|
+
],
|
|
40
|
+
};
|
package/index.js
CHANGED
|
@@ -1,11 +1,38 @@
|
|
|
1
1
|
// http://eslint.org/docs/user-guide/configuring
|
|
2
|
+
/**
|
|
3
|
+
* @param {string} name
|
|
4
|
+
*/
|
|
5
|
+
function tryResolve(name) {
|
|
6
|
+
try {
|
|
7
|
+
require.resolve(name);
|
|
8
|
+
return true;
|
|
9
|
+
} catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @template T
|
|
16
|
+
* @param {boolean} condition
|
|
17
|
+
* @param {T} value
|
|
18
|
+
*/
|
|
19
|
+
function includeIf(condition, value) {
|
|
20
|
+
return condition ? [value] : [];
|
|
21
|
+
}
|
|
22
|
+
|
|
2
23
|
module.exports = {
|
|
3
|
-
extends: [
|
|
24
|
+
extends: [
|
|
25
|
+
require.resolve('./ignore'),
|
|
26
|
+
require.resolve('./es'),
|
|
27
|
+
require.resolve('./json'),
|
|
28
|
+
require.resolve('./yml'),
|
|
29
|
+
...includeIf(tryResolve('react'), require.resolve('./react')),
|
|
30
|
+
],
|
|
4
31
|
overrides: [
|
|
5
|
-
{
|
|
32
|
+
...includeIf(tryResolve('typescript'), {
|
|
6
33
|
extends: [require.resolve('./ts')],
|
|
7
34
|
files: ['*.+(ts|tsx)'],
|
|
8
|
-
},
|
|
35
|
+
}),
|
|
9
36
|
{
|
|
10
37
|
extends: [require.resolve('./jest')],
|
|
11
38
|
files: [
|
|
@@ -13,6 +40,11 @@ module.exports = {
|
|
|
13
40
|
'**/__tests__/**/*.+(ts|tsx|js|jsx)',
|
|
14
41
|
'**/?(*.)+(spec|test).+(ts|tsx|js|jsx)',
|
|
15
42
|
],
|
|
43
|
+
settings: {
|
|
44
|
+
jest: {
|
|
45
|
+
version: 'latest',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
16
48
|
},
|
|
17
49
|
],
|
|
18
50
|
root: true,
|
package/json.js
CHANGED
|
@@ -1,8 +1,189 @@
|
|
|
1
|
+
/* cspell:disable */
|
|
2
|
+
// https://github.com/keithamus/sort-package-json/blob/master/defaultRules.md
|
|
1
3
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
extends: ['plugin:jsonc/recommended-with-jsonc', 'plugin:jsonc/prettier'],
|
|
5
|
+
overrides: [
|
|
6
|
+
{
|
|
7
|
+
files: ['*.json', '*.json5', '*.jsonc'],
|
|
8
|
+
parser: 'jsonc-eslint-parser',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
files: ['tsconfig*.json'],
|
|
12
|
+
rules: {
|
|
13
|
+
'jsonc/sort-keys': [
|
|
14
|
+
'error',
|
|
15
|
+
{
|
|
16
|
+
order: ['$schema', 'display', 'extends', 'compilerOptions', 'include', 'exclude', 'files', 'references'],
|
|
17
|
+
pathPattern: '^$',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
order: { type: 'asc' },
|
|
21
|
+
pathPattern: '.*',
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
files: ['package.json'],
|
|
28
|
+
parser: 'jsonc-eslint-parser',
|
|
29
|
+
rules: {
|
|
30
|
+
'jsonc/sort-keys': [
|
|
31
|
+
'error',
|
|
32
|
+
{
|
|
33
|
+
order: [
|
|
34
|
+
'$schema',
|
|
35
|
+
'name',
|
|
36
|
+
'displayName',
|
|
37
|
+
'version',
|
|
38
|
+
'private',
|
|
39
|
+
'description',
|
|
40
|
+
'categories',
|
|
41
|
+
'keywords',
|
|
42
|
+
'homepage',
|
|
43
|
+
'bugs',
|
|
44
|
+
'repository',
|
|
45
|
+
'funding',
|
|
46
|
+
'license',
|
|
47
|
+
'qna',
|
|
48
|
+
'author',
|
|
49
|
+
'maintainers', // Key order (per item): name, email, url
|
|
50
|
+
'contributors', // Key order (per item): name, email, url
|
|
51
|
+
'publisher',
|
|
52
|
+
'sideEffects',
|
|
53
|
+
'type',
|
|
54
|
+
'imports',
|
|
55
|
+
'exports',
|
|
56
|
+
'main',
|
|
57
|
+
'svelte',
|
|
58
|
+
'umd:main',
|
|
59
|
+
'jsdelivr',
|
|
60
|
+
'unpkg',
|
|
61
|
+
'module',
|
|
62
|
+
'source',
|
|
63
|
+
'jsnext:main',
|
|
64
|
+
'browser',
|
|
65
|
+
'react-native',
|
|
66
|
+
'types',
|
|
67
|
+
'typesVersions',
|
|
68
|
+
'typings',
|
|
69
|
+
'style',
|
|
70
|
+
'example',
|
|
71
|
+
'examplestyle',
|
|
72
|
+
'assets',
|
|
73
|
+
'bin',
|
|
74
|
+
'man',
|
|
75
|
+
'directories', // Key order: lib, bin, man, doc, example, test
|
|
76
|
+
'files', // Unique items
|
|
77
|
+
'workspaces',
|
|
78
|
+
'binary', // Key order: module_name, module_path, remote_path, package_name, host
|
|
79
|
+
'scripts', // Script sort
|
|
80
|
+
'betterScripts', // Script sort
|
|
81
|
+
'contributes',
|
|
82
|
+
'activationEvents', // Unique items
|
|
83
|
+
'husky', // Sorts the hooks field using git hook sort
|
|
84
|
+
'simple-git-hooks', // Key sort using git hook sort
|
|
85
|
+
'pre-commit',
|
|
86
|
+
'commitlint',
|
|
87
|
+
'lint-staged',
|
|
88
|
+
'config',
|
|
89
|
+
'nodemonConfig',
|
|
90
|
+
'browserify',
|
|
91
|
+
'babel',
|
|
92
|
+
'browserslist',
|
|
93
|
+
'xo',
|
|
94
|
+
'prettier', // Prettier sort
|
|
95
|
+
'eslintConfig', // ESLint sort
|
|
96
|
+
'eslintIgnore',
|
|
97
|
+
'npmpackagejsonlint', // Key sort (also recognizes: npmPackageJsonLintConfig, npmpkgjsonlint)
|
|
98
|
+
'release',
|
|
99
|
+
'remarkConfig',
|
|
100
|
+
'stylelint',
|
|
101
|
+
'ava',
|
|
102
|
+
'jest',
|
|
103
|
+
'mocha',
|
|
104
|
+
'nyc',
|
|
105
|
+
'tap',
|
|
106
|
+
'resolutions',
|
|
107
|
+
'dependencies',
|
|
108
|
+
'devDependencies',
|
|
109
|
+
'dependenciesMeta', // Key sort (deep)
|
|
110
|
+
'peerDependencies',
|
|
111
|
+
'peerDependenciesMeta', // Key sort (deep)
|
|
112
|
+
'optionalDependencies',
|
|
113
|
+
'bundledDependencies',
|
|
114
|
+
'bundleDependencies',
|
|
115
|
+
'extensionPack',
|
|
116
|
+
'extensionDependencies',
|
|
117
|
+
'flat',
|
|
118
|
+
'packageManager',
|
|
119
|
+
'engines',
|
|
120
|
+
'engineStrict',
|
|
121
|
+
'volta', // Key order: node, npm, yarn
|
|
122
|
+
'languageName',
|
|
123
|
+
'os',
|
|
124
|
+
'cpu',
|
|
125
|
+
'preferGlobal',
|
|
126
|
+
'publishConfig',
|
|
127
|
+
'icon',
|
|
128
|
+
'badges', // Key order (per item): description, url, href
|
|
129
|
+
'galleryBanner',
|
|
130
|
+
'preview',
|
|
131
|
+
'markdown',
|
|
132
|
+
],
|
|
133
|
+
pathPattern: '^$',
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
order: ['url', 'email'],
|
|
137
|
+
pathPattern: `^bugs$`,
|
|
138
|
+
},
|
|
139
|
+
...['repository', 'funding', 'license', 'author'].map((key) => ({
|
|
140
|
+
order: ['type', 'name', 'email', 'url'],
|
|
141
|
+
pathPattern: `^${key}$`,
|
|
142
|
+
})),
|
|
143
|
+
...['scripts', 'betterScripts'].map((key) => ({
|
|
144
|
+
order: { type: 'asc' },
|
|
145
|
+
pathPattern: `^${key}$`,
|
|
146
|
+
})),
|
|
147
|
+
...[
|
|
148
|
+
'bin',
|
|
149
|
+
'contributes',
|
|
150
|
+
'commitlint',
|
|
151
|
+
'config',
|
|
152
|
+
'nodemonConfig',
|
|
153
|
+
'browserify',
|
|
154
|
+
'babel',
|
|
155
|
+
'xo',
|
|
156
|
+
'release',
|
|
157
|
+
'remarkConfig',
|
|
158
|
+
'ava',
|
|
159
|
+
'jest',
|
|
160
|
+
'mocha',
|
|
161
|
+
'nyc',
|
|
162
|
+
'tap',
|
|
163
|
+
'resolutions',
|
|
164
|
+
'engines',
|
|
165
|
+
'engineStrict',
|
|
166
|
+
'preferGlobal',
|
|
167
|
+
'publishConfig',
|
|
168
|
+
'galleryBanner',
|
|
169
|
+
].map((key) => ({
|
|
170
|
+
order: { type: 'asc' },
|
|
171
|
+
pathPattern: `^${key}$`,
|
|
172
|
+
})),
|
|
173
|
+
{
|
|
174
|
+
order: { type: 'asc' },
|
|
175
|
+
pathPattern: '^(?:dev|peer|optional|bundled|extension)?[Dd]ependencies$',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
order: ['types', 'require', 'import'],
|
|
179
|
+
pathPattern: '^exports.*$',
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
plugins: ['jsonc'],
|
|
186
|
+
rules: {
|
|
187
|
+
// 'jsonc/sort-keys': 'error',
|
|
7
188
|
},
|
|
8
189
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/eslint-config",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.41",
|
|
4
4
|
"description": "ESLint configuration presets",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -13,23 +13,30 @@
|
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "
|
|
16
|
+
"url": "git@github.com:w5s/project-config.git",
|
|
17
17
|
"directory": "packages/eslint-config"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"author": "Julien Polo <julien.polo@gmail.com>",
|
|
21
|
+
"type": "commonjs",
|
|
21
22
|
"main": "index.js",
|
|
22
23
|
"files": [
|
|
23
24
|
"*.js",
|
|
24
25
|
"rules/*.js"
|
|
25
26
|
],
|
|
26
27
|
"scripts": {
|
|
27
|
-
"build": "npm
|
|
28
|
-
"
|
|
28
|
+
"build": "concurrently \"npm:build:*\" \":\"",
|
|
29
|
+
"clean": "concurrently \"npm:clean:*\" \":\"",
|
|
29
30
|
"docs": "md-magic --path '**/*.md' --ignore='node_modules'",
|
|
30
|
-
"format": "
|
|
31
|
-
"
|
|
32
|
-
"
|
|
31
|
+
"format": "concurrently \"npm:format:*\" \":\"",
|
|
32
|
+
"format:src": "eslint . --fix --ext=mjs,cjs,js,jsx,ts,tsx,json,jsonc,json5,yml,yaml",
|
|
33
|
+
"lint": "concurrently \"npm:lint:*\" \":\"",
|
|
34
|
+
"lint:src": "eslint . --ext=mjs,cjs,js,jsx,ts,tsx,json,jsonc,json5,yml,yaml",
|
|
35
|
+
"prepare": "concurrently \"npm:prepare:*\" \":\"",
|
|
36
|
+
"spellcheck": "cspell --no-progress '**'",
|
|
37
|
+
"test": "concurrently \"npm:test:*\" ",
|
|
38
|
+
"test:src": "scripts/test",
|
|
39
|
+
"test_:rule-coverage": "eslint-find-rules --unused"
|
|
33
40
|
},
|
|
34
41
|
"eslintConfig": {
|
|
35
42
|
"rules": {
|
|
@@ -37,45 +44,64 @@
|
|
|
37
44
|
}
|
|
38
45
|
},
|
|
39
46
|
"eslintIgnore": [
|
|
40
|
-
"
|
|
47
|
+
"_tests"
|
|
41
48
|
],
|
|
49
|
+
"jest": {
|
|
50
|
+
"testPathIgnorePatterns": [
|
|
51
|
+
"node_modules",
|
|
52
|
+
"_tests"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
42
55
|
"dependencies": {
|
|
43
|
-
"@babel/
|
|
44
|
-
"@babel/
|
|
45
|
-
"@
|
|
56
|
+
"@babel/core": "*",
|
|
57
|
+
"@babel/eslint-parser": "*",
|
|
58
|
+
"@rushstack/eslint-patch": "^1.1.0",
|
|
46
59
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
47
60
|
"@typescript-eslint/parser": "^5.0.0",
|
|
61
|
+
"@w5s/prettier-config": "^1.0.4",
|
|
48
62
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
49
63
|
"eslint-config-prettier": "^8.0.0",
|
|
50
64
|
"eslint-plugin-functional": "^4.2.0",
|
|
51
65
|
"eslint-plugin-import": "^2.25.0",
|
|
52
|
-
"eslint-plugin-jest": "^
|
|
53
|
-
"eslint-plugin-jsdoc": "^
|
|
54
|
-
"eslint-plugin-
|
|
66
|
+
"eslint-plugin-jest": "^27.0.0",
|
|
67
|
+
"eslint-plugin-jsdoc": "^39.0.0",
|
|
68
|
+
"eslint-plugin-jsonc": "^2.4.0",
|
|
55
69
|
"eslint-plugin-prettier": "^4.0.0",
|
|
70
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
56
71
|
"eslint-plugin-react": "^7.28.0",
|
|
57
|
-
"eslint-plugin-total-functions": "^
|
|
58
|
-
"eslint-plugin-unicorn": "^
|
|
72
|
+
"eslint-plugin-total-functions": "^6.0.0",
|
|
73
|
+
"eslint-plugin-unicorn": "^45.0.0",
|
|
74
|
+
"eslint-plugin-yml": "^1.1.0",
|
|
75
|
+
"find-up": "^5.0.0",
|
|
76
|
+
"parse-gitignore": "^2.0.0"
|
|
59
77
|
},
|
|
60
78
|
"devDependencies": {
|
|
61
|
-
"@babel/eslint-parser": "7.
|
|
62
|
-
"@types/eslint": "8.4.
|
|
63
|
-
"@types/eslint-plugin-prettier": "
|
|
64
|
-
"@types/prettier": "2.
|
|
65
|
-
"@types/react": "
|
|
66
|
-
"@typescript-eslint/parser": "5.
|
|
67
|
-
"eslint": "8.
|
|
68
|
-
"eslint-config-prettier": "8.
|
|
69
|
-
"eslint-
|
|
70
|
-
"prettier": "2.
|
|
71
|
-
"react": "
|
|
79
|
+
"@babel/eslint-parser": "7.19.1",
|
|
80
|
+
"@types/eslint": "8.4.10",
|
|
81
|
+
"@types/eslint-plugin-prettier": "3.1.0",
|
|
82
|
+
"@types/prettier": "2.7.1",
|
|
83
|
+
"@types/react": "18.0.26",
|
|
84
|
+
"@typescript-eslint/parser": "5.46.0",
|
|
85
|
+
"eslint": "8.29.0",
|
|
86
|
+
"eslint-config-prettier": "8.5.0",
|
|
87
|
+
"eslint-find-rules": "4.1.0",
|
|
88
|
+
"prettier": "2.8.1",
|
|
89
|
+
"react": "18.2.0"
|
|
72
90
|
},
|
|
73
91
|
"peerDependencies": {
|
|
74
|
-
"eslint": "
|
|
75
|
-
"
|
|
92
|
+
"eslint": "8.x",
|
|
93
|
+
"typescript": "4.x"
|
|
94
|
+
},
|
|
95
|
+
"peerDependenciesMeta": {
|
|
96
|
+
"typescript": {
|
|
97
|
+
"optional": true
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"engines": {
|
|
101
|
+
"node": ">=16.0.0"
|
|
76
102
|
},
|
|
77
103
|
"publishConfig": {
|
|
78
104
|
"access": "public"
|
|
79
105
|
},
|
|
80
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "452324f365d1201adbbe7d6f4a140139adde5874"
|
|
81
107
|
}
|
package/rules/_rule.js
CHANGED
|
@@ -28,7 +28,7 @@ const off = 'off';
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* @template T
|
|
31
|
-
|
|
31
|
+
@type {(value: T[]|T|undefined) => T[]} */
|
|
32
32
|
function toArray(value) {
|
|
33
33
|
if (value == null) {
|
|
34
34
|
return [];
|
|
@@ -72,7 +72,7 @@ module.exports = {
|
|
|
72
72
|
concatESConfig,
|
|
73
73
|
error,
|
|
74
74
|
// eslint-disable-next-line no-unused-vars
|
|
75
|
-
fixme: (/** @type {'off'|'warn'|'error'} */ _status) => off,
|
|
75
|
+
fixme: (/** @type {'off'|'warn'|'error'|undefined} */ _status) => off,
|
|
76
76
|
off,
|
|
77
77
|
warn,
|
|
78
78
|
};
|
package/rules/base.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
const { concatESConfig, off } = require('./_rule');
|
|
1
|
+
const { concatESConfig, off, error } = require('./_rule.js');
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// Fix eslint shareable config (https://github.com/eslint/eslint/issues/3458)
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
require('@rushstack/eslint-patch/modern-module-resolution.js');
|
|
6
|
+
|
|
7
|
+
const baseConfig = concatESConfig(
|
|
4
8
|
// @ts-ignore
|
|
5
9
|
require('eslint-config-airbnb-base/rules/best-practices'),
|
|
6
10
|
// @ts-ignore
|
|
@@ -16,13 +20,34 @@ module.exports = concatESConfig(
|
|
|
16
20
|
// @ts-ignore
|
|
17
21
|
require('eslint-config-airbnb-base/rules/style'),
|
|
18
22
|
// @ts-ignore
|
|
19
|
-
require('eslint-config-airbnb-base/rules/variables')
|
|
23
|
+
require('eslint-config-airbnb-base/rules/variables')
|
|
24
|
+
);
|
|
20
25
|
|
|
26
|
+
module.exports = concatESConfig(
|
|
27
|
+
baseConfig,
|
|
21
28
|
// overrides
|
|
22
29
|
{
|
|
23
30
|
rules: {
|
|
31
|
+
// Annoying because it is not always wanted
|
|
32
|
+
'default-case': off,
|
|
33
|
+
// We do not want console.* in production. Disable this rule on a per line basis if needed
|
|
34
|
+
'no-console': error,
|
|
24
35
|
// Often useful in jsx
|
|
25
36
|
'no-nested-ternary': off,
|
|
37
|
+
// Too strict, for pure code prefer the functional plugin
|
|
38
|
+
'no-param-reassign': [error, { props: false }],
|
|
39
|
+
// Allow for-of syntax
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
'no-restricted-syntax': baseConfig.rules['no-restricted-syntax'].filter(
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
({ selector }) => selector !== 'ForOfStatement'
|
|
44
|
+
),
|
|
45
|
+
// underscore is often used (mongodb, etc)
|
|
46
|
+
'no-underscore-dangle': off,
|
|
47
|
+
// Ignore underscore case arguments
|
|
48
|
+
'no-unused-vars': [error, { argsIgnorePattern: '^_' }],
|
|
49
|
+
// Allow in some cases https://github.com/airbnb/javascript/issues/1089#issuecomment-1024351821
|
|
50
|
+
'no-use-before-define': [error, 'nofunc'],
|
|
26
51
|
},
|
|
27
52
|
}
|
|
28
53
|
);
|
package/rules/import.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { off, warn, error, concatESConfig, fixme } = require('./_rule');
|
|
1
|
+
const { off, warn, error, concatESConfig, fixme } = require('./_rule.js');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#eslint-plugin-import
|
|
@@ -13,6 +13,15 @@ module.exports = concatESConfig(
|
|
|
13
13
|
// Overrides
|
|
14
14
|
{
|
|
15
15
|
rules: {
|
|
16
|
+
'import/extensions': [
|
|
17
|
+
error,
|
|
18
|
+
'ignorePackages',
|
|
19
|
+
{
|
|
20
|
+
// js: 'never',
|
|
21
|
+
// jsx: 'never',
|
|
22
|
+
// mjs: 'never',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
16
25
|
'import/no-deprecated': performanceIssue(warn),
|
|
17
26
|
'import/no-named-as-default': performanceIssue(error),
|
|
18
27
|
'import/no-unused-modules': performanceIssue(error),
|
package/rules/jest.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { off, error, concatESConfig } = require('./_rule');
|
|
1
|
+
const { off, error, concatESConfig } = require('./_rule.js');
|
|
2
2
|
|
|
3
3
|
module.exports = concatESConfig(
|
|
4
4
|
{
|
|
@@ -8,33 +8,30 @@ module.exports = concatESConfig(
|
|
|
8
8
|
extends: ['plugin:jest/recommended'],
|
|
9
9
|
plugins: ['jest'],
|
|
10
10
|
rules: {
|
|
11
|
+
'jest/consistent-test-it': error,
|
|
11
12
|
'jest/expect-expect': off, // Disabled because it does not handle functions that does the expect
|
|
12
13
|
'jest/no-alias-methods': error,
|
|
13
|
-
'jest/no-commented-out-tests': error,
|
|
14
|
-
'jest/no-deprecated-functions': off,
|
|
15
|
-
'jest/no-disabled-tests': off,
|
|
16
|
-
'jest/no-done-callback': error,
|
|
17
|
-
'jest/no-export': off,
|
|
18
|
-
'jest/no-focused-tests': error,
|
|
19
|
-
'jest/no-identical-title': error,
|
|
20
|
-
'jest/no-restricted-matchers': [
|
|
21
|
-
error,
|
|
22
|
-
{
|
|
23
|
-
toBeFalsy: 'Avoid `toBeFalsy`',
|
|
24
|
-
toBeTruthy: 'Avoid `toBeTruthy`',
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
14
|
'jest/prefer-spy-on': error,
|
|
28
15
|
'jest/prefer-to-contain': error,
|
|
29
|
-
'jest/valid-expect': error,
|
|
30
16
|
'jest/valid-title': [error, { ignoreTypeOfDescribeName: true }],
|
|
31
17
|
},
|
|
32
18
|
},
|
|
19
|
+
/**
|
|
20
|
+
* Unicorn less strict to help writing tests
|
|
21
|
+
*/
|
|
22
|
+
{
|
|
23
|
+
rules: {
|
|
24
|
+
'unicorn/consistent-function-scoping': off,
|
|
25
|
+
'unicorn/no-useless-undefined': off,
|
|
26
|
+
'unicorn/prefer-module': off,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
33
29
|
/**
|
|
34
30
|
* Typescript config is set to be less strict because we often have "hack", "mock" in tests
|
|
35
31
|
*/
|
|
36
32
|
{
|
|
37
33
|
rules: {
|
|
34
|
+
'@typescript-eslint/no-non-null-assertion': off,
|
|
38
35
|
'@typescript-eslint/no-unsafe-assignment': off,
|
|
39
36
|
'@typescript-eslint/no-unsafe-call': off,
|
|
40
37
|
'@typescript-eslint/no-unsafe-member-access': off,
|
package/rules/jsdoc.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
const { off,
|
|
1
|
+
const { off, error, warn } = require('./_rule.js');
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
+
extends: ['plugin:jsdoc/recommended'],
|
|
4
5
|
plugins: ['jsdoc'],
|
|
5
6
|
rules: {
|
|
6
|
-
'jsdoc/
|
|
7
|
-
'jsdoc/
|
|
8
|
-
'jsdoc/
|
|
9
|
-
'jsdoc/newline-after-description': [warn, 'always'],
|
|
10
|
-
'jsdoc/require-description': off,
|
|
11
|
-
'jsdoc/require-description-complete-sentence': off,
|
|
12
|
-
'jsdoc/require-hyphen-before-param-description': off,
|
|
13
|
-
'jsdoc/require-param': off,
|
|
7
|
+
'jsdoc/no-undefined-types': off, // https://github.com/gajus/eslint-plugin-jsdoc/issues/839
|
|
8
|
+
'jsdoc/require-hyphen-before-param-description': [warn, 'always'],
|
|
9
|
+
'jsdoc/require-jsdoc': off,
|
|
14
10
|
'jsdoc/require-param-description': off,
|
|
15
|
-
'jsdoc/require-
|
|
16
|
-
'jsdoc/
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
'jsdoc/require-returns': off,
|
|
12
|
+
'jsdoc/valid-types': off, // FIXME: reports lots of false positive
|
|
13
|
+
strict: [error, 'safe'],
|
|
14
|
+
},
|
|
15
|
+
settings: {
|
|
16
|
+
jsdoc: {
|
|
17
|
+
mode: 'typescript',
|
|
18
|
+
},
|
|
19
19
|
},
|
|
20
20
|
};
|
package/rules/prettier.js
CHANGED
|
@@ -1,14 +1,44 @@
|
|
|
1
|
-
const { error } = require('./_rule');
|
|
1
|
+
const { error } = require('./_rule.js');
|
|
2
|
+
|
|
3
|
+
const getPackageScope = () => {
|
|
4
|
+
try {
|
|
5
|
+
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
6
|
+
const { name } = require('../package.json');
|
|
7
|
+
const prefixMatch = (name || '').match(/(@\w+)\//);
|
|
8
|
+
const packageScope = prefixMatch ? prefixMatch[1] : undefined;
|
|
9
|
+
return packageScope;
|
|
10
|
+
} catch (error_) {
|
|
11
|
+
// eslint-disable-next-line no-console
|
|
12
|
+
console.warn(error_);
|
|
13
|
+
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const getPrettierConfig = (/** @type {string} */ moduleName) => {
|
|
18
|
+
try {
|
|
19
|
+
/** @type {import('prettier').Config} */
|
|
20
|
+
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
21
|
+
const moduleConfig = require(moduleName);
|
|
22
|
+
return moduleConfig;
|
|
23
|
+
} catch {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Try require '@my-organization/prettier-config'
|
|
29
|
+
const getPrettierConfigDefault = () => {
|
|
30
|
+
/** @type {import('prettier').Config} */
|
|
31
|
+
const defaultConfig = {
|
|
32
|
+
trailingComma: 'es5',
|
|
33
|
+
};
|
|
34
|
+
const packageScope = getPackageScope();
|
|
35
|
+
return getPrettierConfig(`${packageScope}/prettier-config`) || defaultConfig;
|
|
36
|
+
};
|
|
2
37
|
|
|
3
38
|
module.exports = {
|
|
39
|
+
extends: ['prettier'],
|
|
4
40
|
plugins: ['prettier'],
|
|
5
41
|
rules: {
|
|
6
|
-
'prettier/prettier': [
|
|
7
|
-
error,
|
|
8
|
-
{
|
|
9
|
-
singleQuote: true,
|
|
10
|
-
trailingComma: 'es5',
|
|
11
|
-
},
|
|
12
|
-
],
|
|
42
|
+
'prettier/prettier': [error, getPrettierConfigDefault()],
|
|
13
43
|
},
|
|
14
44
|
};
|
package/rules/promise.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const { concatESConfig, error, fixme } = require('./_rule.js');
|
|
2
|
+
|
|
3
|
+
module.exports = concatESConfig({
|
|
4
|
+
extends: ['plugin:promise/recommended'],
|
|
5
|
+
plugins: ['promise'],
|
|
6
|
+
rules: {
|
|
7
|
+
// https://github.com/xjamundx/eslint-plugin-promise/issues/212
|
|
8
|
+
'promise/prefer-await-to-callbacks': fixme(error),
|
|
9
|
+
'promise/prefer-await-to-then': error,
|
|
10
|
+
},
|
|
11
|
+
});
|
package/rules/react.js
CHANGED
package/rules/typescript.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Inspired by https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
2
2
|
|
|
3
|
-
const { fixme, off, warn, error, concatESConfig } = require('./_rule');
|
|
4
|
-
const { rules: _baseRules } = require('./base');
|
|
5
|
-
const { rules: _baseImportRules } = require('./import');
|
|
3
|
+
const { fixme, off, warn, error, concatESConfig } = require('./_rule.js');
|
|
4
|
+
const { rules: _baseRules } = require('./base.js');
|
|
5
|
+
const { rules: _baseImportRules } = require('./import.js');
|
|
6
6
|
|
|
7
7
|
// Fix Hack : TS pluging seems to modify the rules
|
|
8
8
|
const deepClone = (/** @type {Record<string, unknown>} */ anyValue) => JSON.parse(JSON.stringify(anyValue));
|
|
@@ -130,6 +130,18 @@ module.exports = concatESConfig(
|
|
|
130
130
|
'@typescript-eslint/type-annotation-spacing': error,
|
|
131
131
|
},
|
|
132
132
|
},
|
|
133
|
+
/**
|
|
134
|
+
* JSDoc overrides
|
|
135
|
+
*/
|
|
136
|
+
{
|
|
137
|
+
rules: {
|
|
138
|
+
'jsdoc/no-types': error,
|
|
139
|
+
'jsdoc/require-param': off,
|
|
140
|
+
'jsdoc/require-param-type': off,
|
|
141
|
+
'jsdoc/require-returns': off,
|
|
142
|
+
'jsdoc/require-returns-type': off,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
133
145
|
/**
|
|
134
146
|
* Import overrides
|
|
135
147
|
*/
|
|
@@ -214,7 +226,7 @@ module.exports = concatESConfig(
|
|
|
214
226
|
'no-undef': off,
|
|
215
227
|
'no-unreachable': off,
|
|
216
228
|
'no-unsafe-negation': off,
|
|
217
|
-
'no-unused-
|
|
229
|
+
'no-unused-expressions': off,
|
|
218
230
|
'no-unused-vars': off,
|
|
219
231
|
'no-use-before-define': off,
|
|
220
232
|
'no-useless-constructor': off,
|
package/rules/unicorn.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { off, warn, error, concatESConfig } = require('./_rule');
|
|
1
|
+
const { off, warn, error, concatESConfig } = require('./_rule.js');
|
|
2
2
|
|
|
3
3
|
module.exports = concatESConfig(
|
|
4
4
|
{
|
|
@@ -49,7 +49,11 @@ module.exports = concatESConfig(
|
|
|
49
49
|
{
|
|
50
50
|
rules: {
|
|
51
51
|
'unicorn/consistent-destructuring': off,
|
|
52
|
+
'unicorn/consistent-function-scoping': off, // Too many false positive
|
|
53
|
+
'unicorn/no-array-callback-reference': off, // Many false positive reported
|
|
52
54
|
'unicorn/no-array-for-each': off, // This rule could change browser compatibility
|
|
55
|
+
'unicorn/no-array-method-this-argument': off, // Many false positive reported
|
|
56
|
+
'unicorn/no-array-reduce': off, // Array#reduce can be used
|
|
53
57
|
'unicorn/no-object-as-default-parameter': off,
|
|
54
58
|
'unicorn/prefer-default-parameters': off,
|
|
55
59
|
'unicorn/prevent-abbreviations': off, // This rule is so dangerous : it potentially break code while fixing in many cases !!
|
package/ts.js
CHANGED