@w5s/eslint-config 1.0.0-alpha.8 → 1.0.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 +7 -7
- package/es.js +1 -20
- package/ignore.js +1 -0
- package/index.js +28 -14
- package/jest.js +15 -2
- package/json.js +8 -6
- package/lib/_rule.d.ts +2 -0
- package/lib/_rule.js +7 -0
- package/lib/es/base.d.ts +4 -0
- package/lib/es/base.js +68 -0
- package/lib/es/import.d.ts +3 -0
- package/lib/es/import.js +57 -0
- package/lib/es/jsdoc.d.ts +3 -0
- package/lib/es/jsdoc.js +20 -0
- package/lib/es/promise.d.ts +3 -0
- package/lib/es/promise.js +12 -0
- package/lib/es/unicorn.d.ts +3 -0
- package/lib/es/unicorn.js +73 -0
- package/lib/es.d.ts +3 -0
- package/lib/es.js +15 -0
- package/lib/ignore.d.ts +3 -0
- package/lib/ignore.js +40 -0
- package/lib/jest.d.ts +3 -0
- package/lib/jest.js +57 -0
- package/lib/jsonc.d.ts +3 -0
- package/lib/jsonc.js +183 -0
- package/lib/prettier.d.ts +3 -0
- package/lib/prettier.js +43 -0
- package/lib/typescript.d.ts +3 -0
- package/lib/typescript.js +248 -0
- package/lib/yml.d.ts +3 -0
- package/lib/yml.js +7 -0
- package/package.json +58 -39
- package/src/_rule.ts +5 -0
- package/src/es/base.ts +80 -0
- package/src/es/import.ts +61 -0
- package/src/es/jsdoc.ts +22 -0
- package/src/es/promise.ts +13 -0
- package/src/es/unicorn.ts +75 -0
- package/src/es.ts +18 -0
- package/src/ignore.ts +41 -0
- package/src/jest.ts +61 -0
- package/src/jsonc.ts +187 -0
- package/src/prettier.ts +47 -0
- package/{rules/typescript.js → src/typescript.ts} +112 -93
- package/src/yml.ts +8 -0
- package/ts.js +12 -33
- package/yml.js +9 -0
- package/functional.js +0 -51
- package/react.js +0 -10
- package/rules/_rule.js +0 -78
- package/rules/base.js +0 -45
- package/rules/import.js +0 -23
- package/rules/jest.js +0 -55
- package/rules/jsdoc.js +0 -20
- package/rules/prettier.js +0 -14
- package/rules/react.js +0 -176
- package/rules/unicorn.js +0 -61
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
import type eslint from 'eslint';
|
|
2
|
+
import { ESLintConfig } from '@w5s/dev';
|
|
3
|
+
import { fixme } from './_rule.js';
|
|
4
|
+
import baseConfig from './es/base.js';
|
|
5
|
+
import importConfig from './es/import.js';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
const { rules: _baseRules } = require('./base');
|
|
5
|
-
const { rules: _baseImportRules } = require('./import');
|
|
7
|
+
// Inspired by https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
6
8
|
|
|
7
|
-
// Fix Hack : TS
|
|
8
|
-
const deepClone = (
|
|
9
|
-
const baseRules = deepClone(
|
|
10
|
-
const baseImportRules = deepClone(
|
|
9
|
+
// Fix Hack : TS plugin seems to modify the rules
|
|
10
|
+
const deepClone = (anyValue: Partial<eslint.Linter.RulesRecord> | undefined) => JSON.parse(JSON.stringify(anyValue));
|
|
11
|
+
const baseRules = deepClone(baseConfig.rules);
|
|
12
|
+
const baseImportRules = deepClone(importConfig.rules);
|
|
11
13
|
|
|
12
|
-
const duplicateTSC = off; // = "off because tsc already checks that"
|
|
14
|
+
const duplicateTSC = 'off'; // = "off because tsc already checks that"
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
const config: eslint.Linter.Config = ESLintConfig.concat(
|
|
15
17
|
/**
|
|
16
18
|
* Plugin rules
|
|
17
19
|
*/
|
|
18
20
|
{
|
|
19
21
|
extends: ['plugin:@typescript-eslint/recommended-requiring-type-checking'],
|
|
22
|
+
parser: '@typescript-eslint/parser',
|
|
23
|
+
parserOptions: {
|
|
24
|
+
sourceType: 'module',
|
|
25
|
+
},
|
|
20
26
|
plugins: ['@typescript-eslint', 'import'],
|
|
21
27
|
rules: {
|
|
22
|
-
'@typescript-eslint/adjacent-overload-signatures': error,
|
|
28
|
+
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
23
29
|
'@typescript-eslint/ban-ts-comment': [
|
|
24
|
-
warn,
|
|
30
|
+
'warn',
|
|
25
31
|
{
|
|
26
32
|
minimumDescriptionLength: 3,
|
|
27
33
|
'ts-check': false,
|
|
@@ -30,7 +36,7 @@ module.exports = concatESConfig(
|
|
|
30
36
|
'ts-nocheck': true,
|
|
31
37
|
},
|
|
32
38
|
],
|
|
33
|
-
'@typescript-eslint/ban-types': error,
|
|
39
|
+
'@typescript-eslint/ban-types': 'error',
|
|
34
40
|
'@typescript-eslint/brace-style': baseRules['brace-style'],
|
|
35
41
|
'@typescript-eslint/comma-dangle': [
|
|
36
42
|
baseRules['comma-dangle'][0],
|
|
@@ -43,20 +49,20 @@ module.exports = concatESConfig(
|
|
|
43
49
|
],
|
|
44
50
|
'@typescript-eslint/comma-spacing': baseRules['comma-spacing'],
|
|
45
51
|
'@typescript-eslint/consistent-type-assertions': [
|
|
46
|
-
error,
|
|
52
|
+
'error',
|
|
47
53
|
{ assertionStyle: 'as', objectLiteralTypeAssertions: 'never' },
|
|
48
54
|
],
|
|
49
55
|
'@typescript-eslint/default-param-last': baseRules['default-param-last'],
|
|
50
56
|
'@typescript-eslint/dot-notation': baseRules['dot-notation'],
|
|
51
|
-
'@typescript-eslint/explicit-function-return-type': off,
|
|
52
|
-
'@typescript-eslint/explicit-module-boundary-types': off,
|
|
57
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
58
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
53
59
|
'@typescript-eslint/func-call-spacing': baseRules['func-call-spacing'],
|
|
54
60
|
'@typescript-eslint/indent': baseRules.indent,
|
|
55
61
|
'@typescript-eslint/keyword-spacing': baseRules['keyword-spacing'],
|
|
56
62
|
'@typescript-eslint/lines-between-class-members': baseRules['lines-between-class-members'],
|
|
57
|
-
'@typescript-eslint/member-delimiter-style': error,
|
|
63
|
+
'@typescript-eslint/member-delimiter-style': 'error',
|
|
58
64
|
'@typescript-eslint/naming-convention': [
|
|
59
|
-
error,
|
|
65
|
+
'error',
|
|
60
66
|
{
|
|
61
67
|
format: ['PascalCase', 'camelCase'],
|
|
62
68
|
leadingUnderscore: 'allow',
|
|
@@ -81,36 +87,36 @@ module.exports = concatESConfig(
|
|
|
81
87
|
},
|
|
82
88
|
],
|
|
83
89
|
'@typescript-eslint/no-array-constructor': baseRules['no-array-constructor'],
|
|
84
|
-
'@typescript-eslint/no-base-to-string': error,
|
|
90
|
+
'@typescript-eslint/no-base-to-string': 'error',
|
|
85
91
|
'@typescript-eslint/no-dupe-class-members': baseRules['no-dupe-class-members'],
|
|
86
92
|
'@typescript-eslint/no-empty-function': baseRules['no-empty-function'],
|
|
87
|
-
'@typescript-eslint/no-empty-interface': [error, { allowSingleExtends: true }],
|
|
88
|
-
'@typescript-eslint/no-explicit-any': off, // if any is explicit then it's wanted
|
|
93
|
+
'@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],
|
|
94
|
+
'@typescript-eslint/no-explicit-any': 'off', // if any is explicit then it's wanted
|
|
89
95
|
'@typescript-eslint/no-extra-parens': baseRules['no-extra-parens'],
|
|
90
96
|
'@typescript-eslint/no-extra-semi': baseRules['no-extra-semi'],
|
|
91
|
-
'@typescript-eslint/no-implicit-any-catch': error,
|
|
92
|
-
'@typescript-eslint/no-inferrable-types': error,
|
|
97
|
+
'@typescript-eslint/no-implicit-any-catch': 'error',
|
|
98
|
+
'@typescript-eslint/no-inferrable-types': 'error',
|
|
93
99
|
'@typescript-eslint/no-loop-func': baseRules['no-loop-func'],
|
|
94
100
|
'@typescript-eslint/no-loss-of-precision': baseRules['no-loss-of-precision'],
|
|
95
101
|
'@typescript-eslint/no-magic-numbers': baseRules['no-magic-numbers'],
|
|
96
|
-
'@typescript-eslint/no-misused-new': error,
|
|
97
|
-
'@typescript-eslint/no-namespace': off, // We don't agree with community, namespaces are great and not deprecated
|
|
98
|
-
'@typescript-eslint/no-non-null-assertion': error,
|
|
102
|
+
'@typescript-eslint/no-misused-new': 'error',
|
|
103
|
+
'@typescript-eslint/no-namespace': 'off', // We don't agree with community, namespaces are great and not deprecated
|
|
104
|
+
'@typescript-eslint/no-non-null-assertion': 'error',
|
|
99
105
|
'@typescript-eslint/no-redeclare': fixme(baseRules['no-redeclare']),
|
|
100
|
-
'@typescript-eslint/no-require-imports': error,
|
|
106
|
+
'@typescript-eslint/no-require-imports': 'error',
|
|
101
107
|
'@typescript-eslint/no-shadow': baseRules['no-shadow'],
|
|
102
|
-
'@typescript-eslint/no-this-alias': error,
|
|
108
|
+
'@typescript-eslint/no-this-alias': 'error',
|
|
103
109
|
'@typescript-eslint/no-throw-literal': baseRules['no-throw-literal'],
|
|
104
|
-
'@typescript-eslint/no-unnecessary-condition': error,
|
|
105
|
-
'@typescript-eslint/no-unsafe-argument': error,
|
|
110
|
+
'@typescript-eslint/no-unnecessary-condition': 'error',
|
|
111
|
+
'@typescript-eslint/no-unsafe-argument': 'error',
|
|
106
112
|
'@typescript-eslint/no-unused-expressions': baseRules['no-unused-expressions'],
|
|
107
113
|
'@typescript-eslint/no-unused-vars': baseRules['no-unused-vars'],
|
|
108
114
|
'@typescript-eslint/no-use-before-define': baseRules['no-use-before-define'],
|
|
109
115
|
'@typescript-eslint/no-useless-constructor': baseRules['no-useless-constructor'],
|
|
110
|
-
'@typescript-eslint/no-var-requires': error,
|
|
116
|
+
'@typescript-eslint/no-var-requires': 'error',
|
|
111
117
|
'@typescript-eslint/object-curly-spacing': baseRules['object-curly-spacing'],
|
|
112
|
-
'@typescript-eslint/prefer-namespace-keyword': error,
|
|
113
|
-
'@typescript-eslint/prefer-reduce-type-parameter': error,
|
|
118
|
+
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
|
119
|
+
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
|
|
114
120
|
'@typescript-eslint/quotes': baseRules.quotes,
|
|
115
121
|
'@typescript-eslint/require-await': baseRules['require-await'],
|
|
116
122
|
'@typescript-eslint/return-await': baseRules['no-return-await'],
|
|
@@ -118,16 +124,28 @@ module.exports = concatESConfig(
|
|
|
118
124
|
'@typescript-eslint/space-before-function-paren': baseRules['space-before-function-paren'],
|
|
119
125
|
'@typescript-eslint/space-infix-ops': baseRules['space-infix-ops'],
|
|
120
126
|
'@typescript-eslint/strict-boolean-expressions': [
|
|
121
|
-
error,
|
|
127
|
+
'error',
|
|
122
128
|
{
|
|
123
129
|
allowNullableObject: false,
|
|
124
130
|
allowNumber: false,
|
|
125
131
|
allowString: false,
|
|
126
132
|
},
|
|
127
133
|
],
|
|
128
|
-
'@typescript-eslint/switch-exhaustiveness-check': error,
|
|
129
|
-
'@typescript-eslint/triple-slash-reference': error,
|
|
130
|
-
'@typescript-eslint/type-annotation-spacing': error,
|
|
134
|
+
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
135
|
+
'@typescript-eslint/triple-slash-reference': 'error',
|
|
136
|
+
'@typescript-eslint/type-annotation-spacing': 'error',
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
/**
|
|
140
|
+
* JSDoc overrides
|
|
141
|
+
*/
|
|
142
|
+
{
|
|
143
|
+
rules: {
|
|
144
|
+
'jsdoc/no-types': 'error',
|
|
145
|
+
'jsdoc/require-param': 'off',
|
|
146
|
+
'jsdoc/require-param-type': 'off',
|
|
147
|
+
'jsdoc/require-returns': 'off',
|
|
148
|
+
'jsdoc/require-returns-type': 'off',
|
|
131
149
|
},
|
|
132
150
|
},
|
|
133
151
|
/**
|
|
@@ -149,7 +167,7 @@ module.exports = concatESConfig(
|
|
|
149
167
|
{
|
|
150
168
|
...baseImportRules['import/no-extraneous-dependencies'][1],
|
|
151
169
|
devDependencies: baseImportRules['import/no-extraneous-dependencies'][1].devDependencies.reduce(
|
|
152
|
-
(
|
|
170
|
+
(result: string[], devDep: string) => {
|
|
153
171
|
const toAppend = [devDep];
|
|
154
172
|
const devDepWithTs = devDep.replace(/\bjs(x?)\b/g, 'ts$1');
|
|
155
173
|
if (devDepWithTs !== devDep) {
|
|
@@ -169,66 +187,67 @@ module.exports = concatESConfig(
|
|
|
169
187
|
{
|
|
170
188
|
// https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#eslint-plugin-import
|
|
171
189
|
rules: {
|
|
172
|
-
'brace-style': off,
|
|
173
|
-
camelcase: off,
|
|
174
|
-
'comma-dangle': off,
|
|
175
|
-
'comma-spacing': off,
|
|
176
|
-
'constructor-super': off,
|
|
177
|
-
'default-param-last': off,
|
|
178
|
-
'dot-notation': off,
|
|
179
|
-
'func-call-spacing': off,
|
|
180
|
-
'getter-return': off,
|
|
190
|
+
'brace-style': 'off',
|
|
191
|
+
camelcase: 'off',
|
|
192
|
+
'comma-dangle': 'off',
|
|
193
|
+
'comma-spacing': 'off',
|
|
194
|
+
'constructor-super': 'off',
|
|
195
|
+
'default-param-last': 'off',
|
|
196
|
+
'dot-notation': 'off',
|
|
197
|
+
'func-call-spacing': 'off',
|
|
198
|
+
'getter-return': 'off',
|
|
181
199
|
'import/default': duplicateTSC,
|
|
182
|
-
'import/export': fixme(error), // https://github.com/benmosher/eslint-plugin-import/issues/1964
|
|
200
|
+
'import/export': fixme('error'), // https://github.com/benmosher/eslint-plugin-import/issues/1964
|
|
183
201
|
'import/named': duplicateTSC,
|
|
184
202
|
'import/namespace': duplicateTSC,
|
|
185
203
|
'import/no-named-as-default-member': duplicateTSC,
|
|
186
204
|
'import/no-unresolved': duplicateTSC,
|
|
187
|
-
indent: off,
|
|
188
|
-
'keyword-spacing': off,
|
|
189
|
-
'lines-between-class-members': off,
|
|
190
|
-
'no-array-constructor': off,
|
|
191
|
-
'no-const-assign': off,
|
|
192
|
-
'no-dupe-args': off,
|
|
193
|
-
'no-dupe-class-members': off,
|
|
194
|
-
'no-dupe-keys': off,
|
|
195
|
-
'no-empty-function': off,
|
|
196
|
-
'no-extra-parens': off,
|
|
197
|
-
'no-extra-semi': off,
|
|
198
|
-
'no-func-assign': off,
|
|
199
|
-
'no-implied-eval': off,
|
|
200
|
-
'no-import-assign': off,
|
|
201
|
-
'no-inner-declarations': fixme(error), // https://github.com/typescript-eslint/typescript-eslint/issues/239
|
|
202
|
-
'no-loop-func': off,
|
|
203
|
-
'no-loss-of-precision': off,
|
|
204
|
-
'no-magic-numbers': off,
|
|
205
|
-
'no-new-func': off,
|
|
206
|
-
'no-new-symbol': off,
|
|
207
|
-
'no-obj-calls': off,
|
|
208
|
-
'no-redeclare': off,
|
|
209
|
-
'no-return-await': off,
|
|
210
|
-
'no-setter-return': off,
|
|
211
|
-
'no-shadow': off,
|
|
212
|
-
'no-this-before-super': off,
|
|
213
|
-
'no-throw-literal': off,
|
|
214
|
-
'no-undef': off,
|
|
215
|
-
'no-unreachable': off,
|
|
216
|
-
'no-unsafe-negation': off,
|
|
217
|
-
'no-unused-expressions': off,
|
|
218
|
-
'no-unused-vars': off,
|
|
219
|
-
'no-use-before-define': off,
|
|
220
|
-
'no-useless-constructor': off,
|
|
221
|
-
'no-var': error,
|
|
222
|
-
'object-curly-spacing': off,
|
|
223
|
-
'prefer-const': error,
|
|
224
|
-
'prefer-rest-params': error,
|
|
225
|
-
'prefer-spread': error,
|
|
226
|
-
quotes: off,
|
|
227
|
-
'require-await': off,
|
|
228
|
-
semi: off,
|
|
229
|
-
'space-before-function-paren': off,
|
|
230
|
-
'space-infix-ops': off,
|
|
231
|
-
'valid-typeof': off,
|
|
205
|
+
indent: 'off',
|
|
206
|
+
'keyword-spacing': 'off',
|
|
207
|
+
'lines-between-class-members': 'off',
|
|
208
|
+
'no-array-constructor': 'off',
|
|
209
|
+
'no-const-assign': 'off',
|
|
210
|
+
'no-dupe-args': 'off',
|
|
211
|
+
'no-dupe-class-members': 'off',
|
|
212
|
+
'no-dupe-keys': 'off',
|
|
213
|
+
'no-empty-function': 'off',
|
|
214
|
+
'no-extra-parens': 'off',
|
|
215
|
+
'no-extra-semi': 'off',
|
|
216
|
+
'no-func-assign': 'off',
|
|
217
|
+
'no-implied-eval': 'off',
|
|
218
|
+
'no-import-assign': 'off',
|
|
219
|
+
'no-inner-declarations': fixme('error'), // https://github.com/typescript-eslint/typescript-eslint/issues/239
|
|
220
|
+
'no-loop-func': 'off',
|
|
221
|
+
'no-loss-of-precision': 'off',
|
|
222
|
+
'no-magic-numbers': 'off',
|
|
223
|
+
'no-new-func': 'off',
|
|
224
|
+
'no-new-symbol': 'off',
|
|
225
|
+
'no-obj-calls': 'off',
|
|
226
|
+
'no-redeclare': 'off',
|
|
227
|
+
'no-return-await': 'off',
|
|
228
|
+
'no-setter-return': 'off',
|
|
229
|
+
'no-shadow': 'off',
|
|
230
|
+
'no-this-before-super': 'off',
|
|
231
|
+
'no-throw-literal': 'off',
|
|
232
|
+
'no-undef': 'off',
|
|
233
|
+
'no-unreachable': 'off',
|
|
234
|
+
'no-unsafe-negation': 'off',
|
|
235
|
+
'no-unused-expressions': 'off',
|
|
236
|
+
'no-unused-vars': 'off',
|
|
237
|
+
'no-use-before-define': 'off',
|
|
238
|
+
'no-useless-constructor': 'off',
|
|
239
|
+
'no-var': 'error',
|
|
240
|
+
'object-curly-spacing': 'off',
|
|
241
|
+
'prefer-const': 'error',
|
|
242
|
+
'prefer-rest-params': 'error',
|
|
243
|
+
'prefer-spread': 'error',
|
|
244
|
+
quotes: 'off',
|
|
245
|
+
'require-await': 'off',
|
|
246
|
+
semi: 'off',
|
|
247
|
+
'space-before-function-paren': 'off',
|
|
248
|
+
'space-infix-ops': 'off',
|
|
249
|
+
'valid-typeof': 'off',
|
|
232
250
|
},
|
|
233
251
|
}
|
|
234
252
|
);
|
|
253
|
+
export = config;
|
package/src/yml.ts
ADDED
package/ts.js
CHANGED
|
@@ -1,36 +1,15 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
extends: [
|
|
4
|
-
require.resolve('./rules/base'),
|
|
5
|
-
require.resolve('./rules/jsdoc'),
|
|
6
|
-
require.resolve('./rules/import'),
|
|
7
|
-
require.resolve('./rules/unicorn'),
|
|
8
|
-
'plugin:import/typescript',
|
|
9
|
-
require.resolve('./rules/typescript'),
|
|
10
|
-
'prettier',
|
|
11
|
-
require.resolve('./rules/prettier'),
|
|
12
|
-
],
|
|
13
|
-
parser: '@typescript-eslint/parser',
|
|
14
|
-
parserOptions: {
|
|
15
|
-
sourceType: 'module',
|
|
16
|
-
},
|
|
17
|
-
settings: {
|
|
18
|
-
// Append 'ts' extensions to Airbnb 'import/extensions' setting
|
|
19
|
-
'import/extensions': ['.js', '.mjs', '.jsx', '.ts', '.tsx', '.d.ts'],
|
|
1
|
+
// eslint-disable-next-line import/no-unresolved
|
|
2
|
+
const { EXTENSIONS_WITHOUT_DOT } = require('@w5s/dev');
|
|
20
3
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
'import/resolver': {
|
|
31
|
-
node: {
|
|
32
|
-
extensions: ['.mjs', '.js', '.json', '.ts', '.d.ts'],
|
|
33
|
-
},
|
|
4
|
+
module.exports = {
|
|
5
|
+
overrides: [
|
|
6
|
+
{
|
|
7
|
+
extends: [
|
|
8
|
+
// require.resolve('./lib/es.js'),
|
|
9
|
+
require.resolve('./lib/typescript.js'),
|
|
10
|
+
require.resolve('./lib/prettier.js'),
|
|
11
|
+
],
|
|
12
|
+
files: [`*.+(${EXTENSIONS_WITHOUT_DOT.filter((_) => _.includes('ts')).join('|')})`],
|
|
34
13
|
},
|
|
35
|
-
|
|
14
|
+
],
|
|
36
15
|
};
|
package/yml.js
ADDED
package/functional.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// @see https://github.com/danielnixon/eslint-config-typed-fp/blob/master/src/index.ts
|
|
2
|
-
|
|
3
|
-
const { off, error } = require('./rules/_rule');
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
overrides: [
|
|
7
|
-
{
|
|
8
|
-
extends: ['plugin:functional/recommended', 'plugin:total-functions/recommended'],
|
|
9
|
-
files: [
|
|
10
|
-
'src/**/!(*.spec|*.ispec).ts',
|
|
11
|
-
// 'src/**/!(*.spec).js'
|
|
12
|
-
],
|
|
13
|
-
rules: {
|
|
14
|
-
'functional/functional-parameters': [
|
|
15
|
-
error,
|
|
16
|
-
{
|
|
17
|
-
allowArgumentsKeyword: false,
|
|
18
|
-
allowRestParameter: false,
|
|
19
|
-
enforceParameterCount: false,
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
|
|
23
|
-
'functional/no-conditional-statement': off,
|
|
24
|
-
'functional/no-method-signature': off,
|
|
25
|
-
'functional/prefer-readonly-type': [
|
|
26
|
-
// @see https://github.com/jonaskello/eslint-plugin-functional/issues/51
|
|
27
|
-
off, // error
|
|
28
|
-
{
|
|
29
|
-
// When you call methods like `filter` and `concat` on an array (_even a readonly_ array) you always get back a mutable array.
|
|
30
|
-
// By default prefer-readonly-type won't catch these cases, but with the checkImplicit option on it will.
|
|
31
|
-
// See https://github.com/jonaskello/eslint-plugin-functional/blob/master/docs/rules/prefer-readonly-type.md#checkimplicit
|
|
32
|
-
// @see also https://github.com/danielnixon/readonly-types/issues/7
|
|
33
|
-
// @see https://github.com/jonaskello/eslint-plugin-functional/issues/153
|
|
34
|
-
checkImplicit: true,
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
'functional/prefer-type-literal': off,
|
|
38
|
-
'total-functions/no-unsafe-readonly-mutable-assignment': [
|
|
39
|
-
// @see https://github.com/danielnixon/eslint-plugin-total-functions/issues?q=is%3Aissue+is%3Aopen+no-unsafe-readonly-mutable-assignment
|
|
40
|
-
off,
|
|
41
|
-
],
|
|
42
|
-
|
|
43
|
-
'total-functions/no-unsafe-type-assertion': [
|
|
44
|
-
// Don't need this given consistent-type-assertions bans type assertions entirely.,
|
|
45
|
-
off,
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
plugins: ['functional', 'total-functions'],
|
|
51
|
-
};
|
package/react.js
DELETED
package/rules/_rule.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/** @type {'error'} */
|
|
2
|
-
const error = 'error';
|
|
3
|
-
|
|
4
|
-
/** @type {'warn'} */
|
|
5
|
-
const warn = 'warn';
|
|
6
|
-
|
|
7
|
-
/** @type {'off'} */
|
|
8
|
-
const off = 'off';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @typedef {{
|
|
12
|
-
* env?: Record<string, boolean>,
|
|
13
|
-
* extends?: string[]|string,
|
|
14
|
-
* plugins?: string[]|string,
|
|
15
|
-
* rules?: Record<string, unknown>,
|
|
16
|
-
* settings?: Record<string, unknown>,
|
|
17
|
-
* }} ESLintConfigInit
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* @typedef {{
|
|
21
|
-
* env: Record<string, boolean>,
|
|
22
|
-
* extends: string[],
|
|
23
|
-
* plugins: string[],
|
|
24
|
-
* rules: Record<string, unknown>,
|
|
25
|
-
* settings: Record<string, unknown>,
|
|
26
|
-
* }} ESLintConfig
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @template T
|
|
31
|
-
* @type {(value: T[]|T|undefined) => T[]} */
|
|
32
|
-
function toArray(value) {
|
|
33
|
-
if (value == null) {
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
if (Array.isArray(value)) {
|
|
37
|
-
return value;
|
|
38
|
-
}
|
|
39
|
-
return [value];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @template T
|
|
44
|
-
* @type {(left: T[]|T|undefined, right:T[]|T|undefined) => T[]}
|
|
45
|
-
*/
|
|
46
|
-
function concatArray(left, right) {
|
|
47
|
-
return toArray(left).concat(toArray(right));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** @type {(...configs: ESLintConfigInit[]) => ESLintConfig} */
|
|
51
|
-
function concatESConfig(...configs) {
|
|
52
|
-
return configs.reduce(
|
|
53
|
-
(/** @type {ESLintConfig} */ returnValue, /** @type {ESLintConfigInit} */ config) =>
|
|
54
|
-
Object.assign({}, returnValue, config, {
|
|
55
|
-
env: Object.assign({}, returnValue.env, config.env),
|
|
56
|
-
extends: concatArray(returnValue.extends, config.extends),
|
|
57
|
-
plugins: concatArray(returnValue.plugins, config.plugins),
|
|
58
|
-
rules: Object.assign({}, returnValue.rules, config.rules),
|
|
59
|
-
settings: Object.assign({}, returnValue.settings, config.settings),
|
|
60
|
-
}),
|
|
61
|
-
{
|
|
62
|
-
env: {},
|
|
63
|
-
extends: [],
|
|
64
|
-
plugins: [],
|
|
65
|
-
rules: {},
|
|
66
|
-
settings: {},
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
module.exports = {
|
|
72
|
-
concatESConfig,
|
|
73
|
-
error,
|
|
74
|
-
// eslint-disable-next-line no-unused-vars
|
|
75
|
-
fixme: (/** @type {'off'|'warn'|'error'|undefined} */ _status) => off,
|
|
76
|
-
off,
|
|
77
|
-
warn,
|
|
78
|
-
};
|
package/rules/base.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const { concatESConfig, off, error } = require('./_rule');
|
|
2
|
-
|
|
3
|
-
const baseConfig = concatESConfig(
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
require('eslint-config-airbnb-base/rules/best-practices'),
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
require('eslint-config-airbnb-base/rules/errors'),
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
require('eslint-config-airbnb-base/rules/es6'),
|
|
10
|
-
/** {@link ./import.js} */
|
|
11
|
-
// require('eslint-config-airbnb-base/rules/imports'),
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
require('eslint-config-airbnb-base/rules/node'),
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
require('eslint-config-airbnb-base/rules/strict'),
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
require('eslint-config-airbnb-base/rules/style'),
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
require('eslint-config-airbnb-base/rules/variables')
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
module.exports = concatESConfig(
|
|
23
|
-
baseConfig,
|
|
24
|
-
// overrides
|
|
25
|
-
{
|
|
26
|
-
rules: {
|
|
27
|
-
// Often useful in jsx
|
|
28
|
-
'no-nested-ternary': off,
|
|
29
|
-
// Too strict, for pure code prefer the functional plugin
|
|
30
|
-
'no-param-reassign': [error, { props: false }],
|
|
31
|
-
// Allow for-of syntax
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
'no-restricted-syntax': baseConfig.rules['no-restricted-syntax'].filter(
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
({ selector }) => selector !== 'ForOfStatement'
|
|
36
|
-
),
|
|
37
|
-
// underscore is often used (mongodb, etc)
|
|
38
|
-
'no-underscore-dangle': off,
|
|
39
|
-
// Ignore underscore case arguments
|
|
40
|
-
'no-unused-vars': [error, { argsIgnorePattern: '^_' }],
|
|
41
|
-
// Allow in some cases https://github.com/airbnb/javascript/issues/1089#issuecomment-1024351821
|
|
42
|
-
'no-use-before-define': [error, 'nofunc'],
|
|
43
|
-
},
|
|
44
|
-
}
|
|
45
|
-
);
|
package/rules/import.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const { off, warn, error, concatESConfig, fixme } = require('./_rule');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#eslint-plugin-import
|
|
5
|
-
* @param {string} _status
|
|
6
|
-
*/
|
|
7
|
-
// eslint-disable-next-line no-unused-vars
|
|
8
|
-
const performanceIssue = (_status) => off;
|
|
9
|
-
|
|
10
|
-
module.exports = concatESConfig(
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
require('eslint-config-airbnb-base/rules/imports'),
|
|
13
|
-
// Overrides
|
|
14
|
-
{
|
|
15
|
-
rules: {
|
|
16
|
-
'import/no-deprecated': performanceIssue(warn),
|
|
17
|
-
'import/no-named-as-default': performanceIssue(error),
|
|
18
|
-
'import/no-unused-modules': performanceIssue(error),
|
|
19
|
-
'import/prefer-default-export': off, // Not aligned, default export does not bring sufficient semantic
|
|
20
|
-
'import/unambiguous': fixme(off), // Disable because proposal still in progress
|
|
21
|
-
},
|
|
22
|
-
}
|
|
23
|
-
);
|
package/rules/jest.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const { off, error, concatESConfig } = require('./_rule');
|
|
2
|
-
|
|
3
|
-
module.exports = concatESConfig(
|
|
4
|
-
{
|
|
5
|
-
env: {
|
|
6
|
-
jest: true,
|
|
7
|
-
},
|
|
8
|
-
extends: ['plugin:jest/recommended'],
|
|
9
|
-
plugins: ['jest'],
|
|
10
|
-
rules: {
|
|
11
|
-
'jest/expect-expect': off, // Disabled because it does not handle functions that does the expect
|
|
12
|
-
'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
|
-
'jest/prefer-spy-on': error,
|
|
28
|
-
'jest/prefer-to-contain': error,
|
|
29
|
-
'jest/valid-expect': error,
|
|
30
|
-
'jest/valid-title': [error, { ignoreTypeOfDescribeName: true }],
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
/**
|
|
34
|
-
* Unicorn less strict to help writing tests
|
|
35
|
-
*/
|
|
36
|
-
{
|
|
37
|
-
rules: {
|
|
38
|
-
'unicorn/consistent-function-scoping': off,
|
|
39
|
-
'unicorn/no-useless-undefined': off,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
/**
|
|
43
|
-
* Typescript config is set to be less strict because we often have "hack", "mock" in tests
|
|
44
|
-
*/
|
|
45
|
-
{
|
|
46
|
-
rules: {
|
|
47
|
-
'@typescript-eslint/no-unsafe-assignment': off,
|
|
48
|
-
'@typescript-eslint/no-unsafe-call': off,
|
|
49
|
-
'@typescript-eslint/no-unsafe-member-access': off,
|
|
50
|
-
'@typescript-eslint/no-unsafe-return': off,
|
|
51
|
-
'@typescript-eslint/restrict-template-expressions': off,
|
|
52
|
-
'@typescript-eslint/unbound-method': off,
|
|
53
|
-
},
|
|
54
|
-
}
|
|
55
|
-
);
|
package/rules/jsdoc.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const { off, warn, error } = require('./_rule');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
plugins: ['jsdoc'],
|
|
5
|
-
rules: {
|
|
6
|
-
'jsdoc/check-param-names': warn,
|
|
7
|
-
'jsdoc/check-tag-names': warn,
|
|
8
|
-
'jsdoc/check-types': warn,
|
|
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,
|
|
14
|
-
'jsdoc/require-param-description': off,
|
|
15
|
-
'jsdoc/require-param-name': error,
|
|
16
|
-
'jsdoc/require-param-type': off,
|
|
17
|
-
'jsdoc/require-returns-description': off,
|
|
18
|
-
'jsdoc/require-returns-type': off,
|
|
19
|
-
},
|
|
20
|
-
};
|