@w5s/eslint-config 1.0.0-alpha.9 → 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.
Files changed (58) hide show
  1. package/README.md +7 -7
  2. package/es.js +1 -20
  3. package/ignore.js +1 -3
  4. package/index.js +10 -27
  5. package/jest.js +15 -2
  6. package/json.js +8 -7
  7. package/lib/_rule.d.ts +2 -0
  8. package/lib/_rule.js +7 -0
  9. package/lib/es/base.d.ts +4 -0
  10. package/lib/es/base.js +68 -0
  11. package/lib/es/import.d.ts +3 -0
  12. package/lib/es/import.js +57 -0
  13. package/lib/es/jsdoc.d.ts +3 -0
  14. package/lib/es/jsdoc.js +20 -0
  15. package/lib/es/promise.d.ts +3 -0
  16. package/lib/es/promise.js +12 -0
  17. package/lib/es/unicorn.d.ts +3 -0
  18. package/lib/es/unicorn.js +73 -0
  19. package/lib/es.d.ts +3 -0
  20. package/lib/es.js +15 -0
  21. package/lib/ignore.d.ts +3 -0
  22. package/lib/ignore.js +40 -0
  23. package/lib/jest.d.ts +3 -0
  24. package/lib/jest.js +57 -0
  25. package/lib/jsonc.d.ts +3 -0
  26. package/lib/jsonc.js +183 -0
  27. package/lib/prettier.d.ts +3 -0
  28. package/lib/prettier.js +43 -0
  29. package/lib/typescript.d.ts +3 -0
  30. package/lib/typescript.js +248 -0
  31. package/lib/yml.d.ts +3 -0
  32. package/lib/yml.js +7 -0
  33. package/package.json +58 -39
  34. package/src/_rule.ts +5 -0
  35. package/src/es/base.ts +80 -0
  36. package/src/es/import.ts +61 -0
  37. package/src/es/jsdoc.ts +22 -0
  38. package/src/es/promise.ts +13 -0
  39. package/src/es/unicorn.ts +75 -0
  40. package/src/es.ts +18 -0
  41. package/src/ignore.ts +41 -0
  42. package/src/jest.ts +61 -0
  43. package/src/jsonc.ts +187 -0
  44. package/src/prettier.ts +47 -0
  45. package/{rules/typescript.js → src/typescript.ts} +105 -98
  46. package/src/yml.ts +8 -0
  47. package/ts.js +12 -33
  48. package/yml.js +9 -0
  49. package/functional.js +0 -51
  50. package/react.js +0 -10
  51. package/rules/_rule.js +0 -78
  52. package/rules/base.js +0 -45
  53. package/rules/import.js +0 -23
  54. package/rules/jest.js +0 -41
  55. package/rules/jsdoc.js +0 -9
  56. package/rules/prettier.js +0 -14
  57. package/rules/react.js +0 -176
  58. package/rules/unicorn.js +0 -61
@@ -1,27 +1,33 @@
1
- // Inspired by https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
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
- const { fixme, off, warn, error, concatESConfig } = require('./_rule');
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 pluging seems to modify the rules
8
- const deepClone = (/** @type {Record<string, unknown>} */ anyValue) => JSON.parse(JSON.stringify(anyValue));
9
- const baseRules = deepClone(_baseRules);
10
- const baseImportRules = deepClone(_baseImportRules);
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
- module.exports = concatESConfig(
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,16 @@ 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',
131
137
  },
132
138
  },
133
139
  /**
@@ -135,11 +141,11 @@ module.exports = concatESConfig(
135
141
  */
136
142
  {
137
143
  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,
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',
143
149
  },
144
150
  },
145
151
  /**
@@ -161,7 +167,7 @@ module.exports = concatESConfig(
161
167
  {
162
168
  ...baseImportRules['import/no-extraneous-dependencies'][1],
163
169
  devDependencies: baseImportRules['import/no-extraneous-dependencies'][1].devDependencies.reduce(
164
- (/** @type {string[]} */ result, /** @type {string} */ devDep) => {
170
+ (result: string[], devDep: string) => {
165
171
  const toAppend = [devDep];
166
172
  const devDepWithTs = devDep.replace(/\bjs(x?)\b/g, 'ts$1');
167
173
  if (devDepWithTs !== devDep) {
@@ -181,66 +187,67 @@ module.exports = concatESConfig(
181
187
  {
182
188
  // https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#eslint-plugin-import
183
189
  rules: {
184
- 'brace-style': off,
185
- camelcase: off,
186
- 'comma-dangle': off,
187
- 'comma-spacing': off,
188
- 'constructor-super': off,
189
- 'default-param-last': off,
190
- 'dot-notation': off,
191
- 'func-call-spacing': off,
192
- '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',
193
199
  'import/default': duplicateTSC,
194
- '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
195
201
  'import/named': duplicateTSC,
196
202
  'import/namespace': duplicateTSC,
197
203
  'import/no-named-as-default-member': duplicateTSC,
198
204
  'import/no-unresolved': duplicateTSC,
199
- indent: off,
200
- 'keyword-spacing': off,
201
- 'lines-between-class-members': off,
202
- 'no-array-constructor': off,
203
- 'no-const-assign': off,
204
- 'no-dupe-args': off,
205
- 'no-dupe-class-members': off,
206
- 'no-dupe-keys': off,
207
- 'no-empty-function': off,
208
- 'no-extra-parens': off,
209
- 'no-extra-semi': off,
210
- 'no-func-assign': off,
211
- 'no-implied-eval': off,
212
- 'no-import-assign': off,
213
- 'no-inner-declarations': fixme(error), // https://github.com/typescript-eslint/typescript-eslint/issues/239
214
- 'no-loop-func': off,
215
- 'no-loss-of-precision': off,
216
- 'no-magic-numbers': off,
217
- 'no-new-func': off,
218
- 'no-new-symbol': off,
219
- 'no-obj-calls': off,
220
- 'no-redeclare': off,
221
- 'no-return-await': off,
222
- 'no-setter-return': off,
223
- 'no-shadow': off,
224
- 'no-this-before-super': off,
225
- 'no-throw-literal': off,
226
- 'no-undef': off,
227
- 'no-unreachable': off,
228
- 'no-unsafe-negation': off,
229
- 'no-unused-expressions': off,
230
- 'no-unused-vars': off,
231
- 'no-use-before-define': off,
232
- 'no-useless-constructor': off,
233
- 'no-var': error,
234
- 'object-curly-spacing': off,
235
- 'prefer-const': error,
236
- 'prefer-rest-params': error,
237
- 'prefer-spread': error,
238
- quotes: off,
239
- 'require-await': off,
240
- semi: off,
241
- 'space-before-function-paren': off,
242
- 'space-infix-ops': off,
243
- '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',
244
250
  },
245
251
  }
246
252
  );
253
+ export = config;
package/src/yml.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type eslint from 'eslint';
2
+
3
+ const config: eslint.Linter.Config = {
4
+ extends: ['plugin:yml/standard', 'plugin:yml/prettier'],
5
+ parser: 'yaml-eslint-parser',
6
+ plugins: ['yml'],
7
+ };
8
+ export = config;
package/ts.js CHANGED
@@ -1,36 +1,15 @@
1
- // http://eslint.org/docs/user-guide/configuring
2
- module.exports = {
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
- // Resolve type definition packages
22
- 'import/external-module-folders': ['node_modules', 'node_modules/@types'],
23
-
24
- // Apply special parsing for TypeScript files
25
- 'import/parsers': {
26
- '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
27
- },
28
-
29
- // Append 'ts' extensions to Airbnb 'import/resolver' setting
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
@@ -0,0 +1,9 @@
1
+ /* cspell:disable */
2
+ module.exports = {
3
+ overrides: [
4
+ {
5
+ extends: [require.resolve('./lib/yml.js')],
6
+ files: ['*.yml', '*.yaml'],
7
+ },
8
+ ],
9
+ };
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
@@ -1,10 +0,0 @@
1
- // http://eslint.org/docs/user-guide/configuring
2
- module.exports = {
3
- extends: [require.resolve('./rules/react'), 'prettier'],
4
- settings: {
5
- react: {
6
- flowVersion: '0.100',
7
- version: 'detect',
8
- },
9
- },
10
- };
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,41 +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/prefer-spy-on': error,
14
- 'jest/prefer-to-contain': error,
15
- 'jest/valid-title': [error, { ignoreTypeOfDescribeName: true }],
16
- },
17
- },
18
- /**
19
- * Unicorn less strict to help writing tests
20
- */
21
- {
22
- rules: {
23
- 'unicorn/consistent-function-scoping': off,
24
- 'unicorn/no-useless-undefined': off,
25
- 'unicorn/prefer-module': off,
26
- },
27
- },
28
- /**
29
- * Typescript config is set to be less strict because we often have "hack", "mock" in tests
30
- */
31
- {
32
- rules: {
33
- '@typescript-eslint/no-unsafe-assignment': off,
34
- '@typescript-eslint/no-unsafe-call': off,
35
- '@typescript-eslint/no-unsafe-member-access': off,
36
- '@typescript-eslint/no-unsafe-return': off,
37
- '@typescript-eslint/restrict-template-expressions': off,
38
- '@typescript-eslint/unbound-method': off,
39
- },
40
- }
41
- );
package/rules/jsdoc.js DELETED
@@ -1,9 +0,0 @@
1
- const { off } = require('./_rule');
2
-
3
- module.exports = {
4
- extends: ['plugin:jsdoc/recommended'],
5
- plugins: ['jsdoc'],
6
- rules: {
7
- 'jsdoc/require-jsdoc': off,
8
- },
9
- };
package/rules/prettier.js DELETED
@@ -1,14 +0,0 @@
1
- const { error } = require('./_rule');
2
-
3
- module.exports = {
4
- plugins: ['prettier'],
5
- rules: {
6
- 'prettier/prettier': [
7
- error,
8
- {
9
- singleQuote: true,
10
- trailingComma: 'es5',
11
- },
12
- ],
13
- },
14
- };