@w5s/eslint-config 3.10.0 → 3.12.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.
@@ -1,7 +1,9 @@
1
1
  import { interopDefault } from '@w5s/dev';
2
- import { StylisticConfig, type Config, type PluginOptionsBase } from '../type.js';
2
+
3
3
  import type { RuleOptions } from '../typegen/unicorn.js';
4
+
4
5
  import { sourceGlob } from '../glob.js';
6
+ import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
5
7
 
6
8
  const defaultFiles = [sourceGlob];
7
9
 
@@ -18,24 +20,14 @@ export async function unicorn(options: unicorn.Options = {}) {
18
20
  },
19
21
  },
20
22
  {
21
- name: 'w5s/unicorn/rules',
22
23
  files,
24
+ name: 'w5s/unicorn/rules',
23
25
  rules: {
24
- ...(recommended ? unicornPlugin.configs.recommended?.rules : {}),
26
+ ...(recommended && unicornPlugin.configs['unopinionated'].rules),
25
27
  // Disabled for safety
26
- 'unicorn/consistent-destructuring': 'off',
27
- 'unicorn/consistent-function-scoping': 'off', // Too many false positive
28
- 'unicorn/filename-case': 'off',
29
- 'unicorn/import-index': 'off', // Not playing well with ES Module
30
28
  'unicorn/new-for-builtins': 'off', // error, @see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/122
31
- 'unicorn/no-array-callback-reference': 'off', // Many false positive reported
32
- 'unicorn/no-array-for-each': 'off', // This rule could change browser compatibility
33
29
  'unicorn/no-array-method-this-argument': 'off', // Many false positive reported
34
- 'unicorn/no-array-reduce': 'off', // Array#reduce can be used
35
30
  'unicorn/no-console-spaces': 'off',
36
- 'unicorn/no-fn-reference-in-iterator': 'off', // error ?
37
- 'unicorn/no-nested-ternary': 'off',
38
- 'unicorn/no-null': 'off', // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/612
39
31
  'unicorn/no-object-as-default-parameter': 'off',
40
32
  'unicorn/no-process-exit': 'off',
41
33
  'unicorn/no-unreadable-array-destructuring': 'off',
@@ -43,7 +35,6 @@ export async function unicorn(options: unicorn.Options = {}) {
43
35
  'unicorn/prefer-add-event-listener': 'off',
44
36
  'unicorn/prefer-default-parameters': 'off',
45
37
  'unicorn/prefer-set-has': 'off',
46
- 'unicorn/prevent-abbreviations': 'off', // This rule is so dangerous : it potentially break code while fixing in many cases !!
47
38
  'unicorn/throw-new-error': 'off', // Creating errors with call signature is OK
48
39
  ...(stylisticEnabled ? {} : {}),
49
40
  ...rules,
@@ -51,8 +42,8 @@ export async function unicorn(options: unicorn.Options = {}) {
51
42
  },
52
43
  // TODO: move to another file ?
53
44
  {
54
- name: 'w5s/unicorn/overrides',
55
45
  files: ['**/*.config.cjs', '**/*.config.js'],
46
+ name: 'w5s/unicorn/overrides',
56
47
  rules: {
57
48
  'unicorn/prefer-module': 'off',
58
49
  },
@@ -61,7 +52,7 @@ export async function unicorn(options: unicorn.Options = {}) {
61
52
  }
62
53
 
63
54
  export namespace unicorn {
64
- export type Rules = RuleOptions;
65
-
66
55
  export interface Options extends PluginOptionsBase<Rules> {}
56
+
57
+ export type Rules = RuleOptions;
67
58
  }
package/src/config/yml.ts CHANGED
@@ -1,13 +1,16 @@
1
1
  import { interopDefault } from '@w5s/dev';
2
- import { StylisticConfig, type Config, type PluginOptionsBase } from '../type.js';
2
+
3
3
  import type { RuleOptions } from '../typegen/yml.js';
4
+
4
5
  import { ymlSourceGlob } from '../glob.js';
6
+ import { withDefaultFiles } from '../internal/withDefaultFiles.js';
7
+ import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
5
8
 
6
9
  const defaultFiles = [ymlSourceGlob];
7
10
 
8
11
  export async function yml(options: yml.Options = {}) {
9
12
  const [ymlPlugin] = await Promise.all([interopDefault(import('eslint-plugin-yml'))] as const);
10
- const { files = defaultFiles, recommended = true, rules = {}, stylistic = true } = options;
13
+ const { files, recommended = true, rules = {}, stylistic = true } = options;
11
14
  const { enabled: stylisticEnabled, indent, quotes } = StylisticConfig.from(stylistic);
12
15
 
13
16
  return [
@@ -18,7 +21,7 @@ export async function yml(options: yml.Options = {}) {
18
21
  },
19
22
  },
20
23
  {
21
- files,
24
+ files: withDefaultFiles(files, defaultFiles),
22
25
  language: 'yml/yaml',
23
26
  name: 'w5s/yml/rules',
24
27
  rules: {
@@ -56,7 +59,7 @@ export async function yml(options: yml.Options = {}) {
56
59
  }
57
60
 
58
61
  export namespace yml {
59
- export type Rules = RuleOptions;
60
-
61
62
  export interface Options extends PluginOptionsBase<Rules> {}
63
+
64
+ export type Rules = RuleOptions;
62
65
  }
package/src/config.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  export * from './config/e18e.js';
2
2
  export * from './config/es.js';
3
3
  export * from './config/ignores.js';
4
+ export * from './config/imports.js';
4
5
  export * from './config/jsdoc.js';
5
6
  export * from './config/jsonc.js';
6
- export * from './config/imports.js';
7
7
  export * from './config/markdown.js';
8
8
  export * from './config/next.js';
9
9
  export * from './config/node.js';
10
+ export * from './config/perfectionist.js';
10
11
  export * from './config/react.js';
11
12
  export * from './config/stylistic.js';
12
13
  export * from './config/test.js';
@@ -1,4 +1,9 @@
1
+ import type eslint from 'eslint';
2
+
1
3
  import { ESLintConfig } from '@w5s/dev';
4
+
5
+ import type { Config } from './type.js';
6
+
2
7
  import {
3
8
  e18e,
4
9
  es,
@@ -9,6 +14,7 @@ import {
9
14
  markdown,
10
15
  next,
11
16
  node,
17
+ perfectionist,
12
18
  react,
13
19
  stylistic,
14
20
  test,
@@ -16,30 +22,41 @@ import {
16
22
  unicorn,
17
23
  yml,
18
24
  } from './config.js';
19
- import type { Config } from './type.js';
20
25
 
21
26
  export interface DefineConfigOptions extends ignores.Options {
22
- e18e?: boolean | e18e.Options;
23
- es?: boolean | es.Options;
24
- import?: boolean | imports.Options;
25
- markdown?: boolean | markdown.Options;
26
- jsdoc?: boolean | jsdoc.Options;
27
- jsonc?: boolean | jsonc.Options;
28
- next?: boolean | next.Options;
29
- node?: boolean | node.Options;
30
- react?: boolean | react.Options;
31
- stylistic?: boolean | stylistic.Options;
32
- test?: boolean | test.Options;
33
- ts?: boolean | ts.Options;
34
- unicorn?: boolean | unicorn.Options;
35
- yml?: boolean | yml.Options;
27
+ /**
28
+ * Plugins configuration
29
+ */
30
+ plugins?: {
31
+ e18e?: boolean | e18e.Options;
32
+ es?: boolean | es.Options;
33
+ import?: boolean | imports.Options;
34
+ jsdoc?: boolean | jsdoc.Options;
35
+ jsonc?: boolean | jsonc.Options;
36
+ markdown?: boolean | markdown.Options;
37
+ next?: boolean | next.Options;
38
+ node?: boolean | node.Options;
39
+ perfectionist?: boolean | perfectionist.Options;
40
+ react?: boolean | react.Options;
41
+ stylistic?: boolean | stylistic.Options;
42
+ test?: boolean | test.Options;
43
+ ts?: boolean | ts.Options;
44
+ unicorn?: boolean | unicorn.Options;
45
+ yml?: boolean | yml.Options;
46
+ };
47
+
48
+ /**
49
+ * Override rules
50
+ */
51
+ rules?: eslint.Linter.RulesRecord;
36
52
  }
37
53
 
38
54
  export async function defineConfig(options: DefineConfigOptions = {}) {
55
+ const { plugins = {}, rules } = options;
39
56
  const stylisticOptions =
40
- typeof options.stylistic === 'boolean' ? { enabled: options.stylistic } : { enabled: true, ...options.stylistic };
57
+ typeof plugins.stylistic === 'boolean' ? { enabled: plugins.stylistic } : { enabled: true, ...plugins.stylistic };
41
58
  const withDefaultStylistic = <T>(_options: T) => ({ stylistic: stylisticOptions, ..._options });
42
- const toOption = <T extends {}>(optionsOrBoolean: T | boolean | undefined) =>
59
+ const toOption = <T extends {}>(optionsOrBoolean: boolean | T | undefined) =>
43
60
  withDefaultStylistic(
44
61
  (typeof optionsOrBoolean === 'boolean'
45
62
  ? { enabled: optionsOrBoolean }
@@ -49,20 +66,22 @@ export async function defineConfig(options: DefineConfigOptions = {}) {
49
66
  input.enabled ? [factory(input)] : [];
50
67
 
51
68
  return ESLintConfig.concat(
52
- ...includeEnabled(e18e, toOption(options.e18e)),
53
- ...includeEnabled(es, toOption(options.es)),
54
- ...includeEnabled(ts, toOption(options.ts)),
69
+ ...includeEnabled(e18e, toOption(plugins.e18e)),
70
+ ...includeEnabled(es, toOption(plugins.es)),
71
+ ...includeEnabled(ts, toOption(plugins.ts)),
55
72
  ...includeEnabled(ignores, toOption(options)),
56
- ...includeEnabled(jsonc, toOption(options.jsonc)),
57
- ...includeEnabled(jsdoc, toOption(options.jsdoc)),
58
- ...includeEnabled(react, toOption(options.react)),
59
- ...includeEnabled(stylistic, toOption(options.stylistic)),
60
- ...includeEnabled(imports, toOption(options.import)),
61
- ...includeEnabled(markdown, toOption(options.markdown)),
62
- ...includeEnabled(next, toOption(options.next)),
63
- ...includeEnabled(node, toOption(options.node)),
64
- ...includeEnabled(unicorn, toOption(options.unicorn)),
65
- ...includeEnabled(yml, toOption(options.yml)),
66
- ...includeEnabled(test, toOption(options.test)),
73
+ ...includeEnabled(jsonc, toOption(plugins.jsonc)),
74
+ ...includeEnabled(jsdoc, toOption(plugins.jsdoc)),
75
+ ...includeEnabled(react, toOption(plugins.react)),
76
+ ...includeEnabled(stylistic, toOption(plugins.stylistic)),
77
+ ...includeEnabled(imports, toOption(plugins.import)),
78
+ ...includeEnabled(markdown, toOption(plugins.markdown)),
79
+ ...includeEnabled(next, toOption(plugins.next)),
80
+ ...includeEnabled(node, toOption(plugins.node)),
81
+ ...includeEnabled(perfectionist, toOption(plugins.perfectionist)),
82
+ ...includeEnabled(unicorn, toOption(plugins.unicorn)),
83
+ ...includeEnabled(yml, toOption(plugins.yml)),
84
+ ...includeEnabled(test, toOption(plugins.test)),
85
+ ...(rules ? [{ rules }] : []),
67
86
  );
68
87
  }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './defineConfig.js';
2
1
  export * from './config.js';
2
+ export * from './defineConfig.js';
3
+ export { defineConfig as default } from './defineConfig.js';
3
4
  export * from './meta.js';
4
5
  export * from './type.js';
5
- export { defineConfig as default } from './defineConfig.js';
@@ -0,0 +1,12 @@
1
+ import type { PluginOptionsBase } from '../type.js';
2
+
3
+ /**
4
+ * withDefaultFiles
5
+ *
6
+ * @param options The options to process.
7
+ * @param defaultFiles The default files to apply.
8
+ * @returns An array of strings representing the combined files.
9
+ */
10
+ export function withDefaultFiles(options: PluginOptionsBase<any>['files'], defaultFiles: Array<string>): Array<string> {
11
+ return typeof options === 'function' ? options(defaultFiles) : [...(options == null ? [] : options.flat()), ...defaultFiles];
12
+ }
package/src/meta.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export const meta = Object.freeze({
2
+ // @ts-ignore - these variables are injected at build time
3
+ buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,
2
4
  // @ts-ignore - these variables are injected at build time
3
5
  name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,
4
6
  // @ts-ignore - these variables are injected at build time
5
7
  version: (typeof __PACKAGE_VERSION__ === 'undefined' ? '' : __PACKAGE_VERSION__) as string,
6
- // @ts-ignore - these variables are injected at build time
7
- buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,
8
8
  });
@@ -13,16 +13,16 @@ export const bestPractices = () => ({
13
13
  // https://eslint.org/docs/rules/block-scoped-var
14
14
  'block-scoped-var': 'error',
15
15
 
16
- // specify the maximum cyclomatic complexity allowed in a program
17
- // https://eslint.org/docs/rules/complexity
18
- 'complexity': ['off', 20],
19
-
20
16
  // enforce that class methods use "this"
21
17
  // https://eslint.org/docs/rules/class-methods-use-this
22
18
  'class-methods-use-this': ['error', {
23
19
  exceptMethods: [],
24
20
  }],
25
21
 
22
+ // specify the maximum cyclomatic complexity allowed in a program
23
+ // https://eslint.org/docs/rules/complexity
24
+ 'complexity': ['off', 20],
25
+
26
26
  // require return statements to either always or never specify values
27
27
  // https://eslint.org/docs/rules/consistent-return
28
28
  'consistent-return': 'error',
@@ -42,14 +42,14 @@ export const bestPractices = () => ({
42
42
  // https://eslint.org/docs/rules/default-param-last
43
43
  'default-param-last': 'error',
44
44
 
45
- // encourages use of dot notation whenever possible
46
- // https://eslint.org/docs/rules/dot-notation
47
- 'dot-notation': ['error', { allowKeywords: true }],
48
-
49
45
  // enforces consistent newlines before or after dots
50
46
  // https://eslint.org/docs/rules/dot-location
51
47
  'dot-location': ['error', 'property'],
52
48
 
49
+ // encourages use of dot notation whenever possible
50
+ // https://eslint.org/docs/rules/dot-notation
51
+ 'dot-notation': ['error', { allowKeywords: true }],
52
+
53
53
  // require the use of === and !==
54
54
  // https://eslint.org/docs/rules/eqeqeq
55
55
  'eqeqeq': ['error', 'always', { null: 'ignore' }],
@@ -142,17 +142,13 @@ export const bestPractices = () => ({
142
142
  // https://eslint.org/docs/rules/no-global-assign
143
143
  'no-global-assign': ['error', { exceptions: [] }],
144
144
 
145
- // deprecated in favor of no-global-assign
146
- // https://eslint.org/docs/rules/no-native-reassign
147
- 'no-native-reassign': 'off',
148
-
149
145
  // disallow implicit type conversions
150
146
  // https://eslint.org/docs/rules/no-implicit-coercion
151
147
  'no-implicit-coercion': ['off', {
148
+ allow: [],
152
149
  boolean: false,
153
150
  number: true,
154
151
  string: true,
155
- allow: [],
156
152
  }],
157
153
 
158
154
  // disallow var and named functions in global scope
@@ -186,10 +182,10 @@ export const bestPractices = () => ({
186
182
  // disallow magic numbers
187
183
  // https://eslint.org/docs/rules/no-magic-numbers
188
184
  'no-magic-numbers': ['off', {
185
+ detectObjects: false,
186
+ enforceConst: true,
189
187
  ignore: [],
190
188
  ignoreArrayIndexes: true,
191
- enforceConst: true,
192
- detectObjects: false,
193
189
  }],
194
190
 
195
191
  // disallow use of multiple spaces
@@ -202,6 +198,10 @@ export const bestPractices = () => ({
202
198
  // https://eslint.org/docs/rules/no-multi-str
203
199
  'no-multi-str': 'error',
204
200
 
201
+ // deprecated in favor of no-global-assign
202
+ // https://eslint.org/docs/rules/no-native-reassign
203
+ 'no-native-reassign': 'off',
204
+
205
205
  // disallow use of new operator when not part of the assignment or comparison
206
206
  // https://eslint.org/docs/rules/no-new
207
207
  'no-new': 'error',
@@ -236,7 +236,6 @@ export const bestPractices = () => ({
236
236
  // disallow parameter object manipulation except for specific exclusions
237
237
  // rule: https://eslint.org/docs/rules/no-param-reassign.html
238
238
  'no-param-reassign': ['error', {
239
- props: true,
240
239
  ignorePropertyModificationsFor: [
241
240
  'acc', // for reduce accumulators
242
241
  'accumulator', // for reduce accumulators
@@ -250,6 +249,7 @@ export const bestPractices = () => ({
250
249
  '$scope', // for Angular 1 scopes
251
250
  'staticContext', // for ReactRouter context
252
251
  ],
252
+ props: true,
253
253
  }],
254
254
 
255
255
  // disallow usage of __proto__ property
@@ -263,43 +263,43 @@ export const bestPractices = () => ({
263
263
  // disallow certain object properties
264
264
  // https://eslint.org/docs/rules/no-restricted-properties
265
265
  'no-restricted-properties': ['error', {
266
+ message: 'arguments.callee is deprecated',
266
267
  object: 'arguments',
267
268
  property: 'callee',
268
- message: 'arguments.callee is deprecated',
269
269
  }, {
270
+ message: 'Please use Number.isFinite instead',
270
271
  object: 'global',
271
272
  property: 'isFinite',
272
- message: 'Please use Number.isFinite instead',
273
273
  }, {
274
+ message: 'Please use Number.isFinite instead',
274
275
  object: 'self',
275
276
  property: 'isFinite',
276
- message: 'Please use Number.isFinite instead',
277
277
  }, {
278
+ message: 'Please use Number.isFinite instead',
278
279
  object: 'window',
279
280
  property: 'isFinite',
280
- message: 'Please use Number.isFinite instead',
281
281
  }, {
282
+ message: 'Please use Number.isNaN instead',
282
283
  object: 'global',
283
284
  property: 'isNaN',
284
- message: 'Please use Number.isNaN instead',
285
285
  }, {
286
+ message: 'Please use Number.isNaN instead',
286
287
  object: 'self',
287
288
  property: 'isNaN',
288
- message: 'Please use Number.isNaN instead',
289
289
  }, {
290
+ message: 'Please use Number.isNaN instead',
290
291
  object: 'window',
291
292
  property: 'isNaN',
292
- message: 'Please use Number.isNaN instead',
293
293
  }, {
294
- property: '__defineGetter__',
295
294
  message: 'Please use Object.defineProperty instead.',
295
+ property: '__defineGetter__',
296
296
  }, {
297
- property: '__defineSetter__',
298
297
  message: 'Please use Object.defineProperty instead.',
298
+ property: '__defineSetter__',
299
299
  }, {
300
+ message: 'Use the exponentiation operator (**) instead.',
300
301
  object: 'Math',
301
302
  property: 'pow',
302
- message: 'Use the exponentiation operator (**) instead.',
303
303
  }],
304
304
 
305
305
  // disallow use of assignment in return statement
@@ -340,8 +340,8 @@ export const bestPractices = () => ({
340
340
  // https://eslint.org/docs/rules/no-unused-expressions
341
341
  'no-unused-expressions': ['error', {
342
342
  allowShortCircuit: false,
343
- allowTernary: false,
344
343
  allowTaggedTemplates: false,
344
+ allowTernary: false,
345
345
  }],
346
346
 
347
347
  // disallow unused labels
@@ -374,16 +374,12 @@ export const bestPractices = () => ({
374
374
 
375
375
  // disallow usage of configurable warning terms in comments: e.g. todo
376
376
  // https://eslint.org/docs/rules/no-warning-comments
377
- 'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }],
377
+ 'no-warning-comments': ['off', { location: 'start', terms: ['todo', 'fixme', 'xxx'] }],
378
378
 
379
379
  // disallow use of the with statement
380
380
  // https://eslint.org/docs/rules/no-with
381
381
  'no-with': 'error',
382
382
 
383
- // require using Error objects as Promise rejection reasons
384
- // https://eslint.org/docs/rules/prefer-promise-reject-errors
385
- 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
386
-
387
383
  // Suggest using named capture group in regular expression
388
384
  // https://eslint.org/docs/rules/prefer-named-capture-group
389
385
  'prefer-named-capture-group': 'off',
@@ -393,6 +389,10 @@ export const bestPractices = () => ({
393
389
  // TODO: semver-major: enable thus rule, once eslint v8.5.0 is required
394
390
  'prefer-object-has-own': 'off',
395
391
 
392
+ // require using Error objects as Promise rejection reasons
393
+ // https://eslint.org/docs/rules/prefer-promise-reject-errors
394
+ 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
395
+
396
396
  // https://eslint.org/docs/rules/prefer-regex-literals
397
397
  'prefer-regex-literals': ['error', {
398
398
  disallowRedundantWrapping: true,
@@ -71,10 +71,10 @@ export const errors = () => ({
71
71
  // https://eslint.org/docs/rules/no-extra-parens
72
72
  'no-extra-parens': ['off', 'all', {
73
73
  conditionalAssign: true,
74
+ enforceForArrowConditionals: false,
75
+ ignoreJSX: 'all', // delegate to eslint-plugin-react
74
76
  nestedBinaryExpressions: false,
75
77
  returnAssign: false,
76
- ignoreJSX: 'all', // delegate to eslint-plugin-react
77
- enforceForArrowConditionals: false,
78
78
  }],
79
79
 
80
80
  // disallow unnecessary semicolons
@@ -103,14 +103,18 @@ export const errors = () => ({
103
103
  // https://eslint.org/docs/rules/no-misleading-character-class
104
104
  'no-misleading-character-class': 'error',
105
105
 
106
- // disallow the use of object properties of the global object (Math and JSON) as functions
107
- 'no-obj-calls': 'error',
106
+ // disallow negation of the left operand of an in expression
107
+ // deprecated in favor of no-unsafe-negation
108
+ 'no-negated-in-lhs': 'off',
108
109
 
109
110
  // Disallow new operators with global non-constructor functions
110
111
  // https://eslint.org/docs/latest/rules/no-new-native-nonconstructor
111
112
  // TODO: semver-major, enable
112
113
  'no-new-native-nonconstructor': 'off',
113
114
 
115
+ // disallow the use of object properties of the global object (Math and JSON) as functions
116
+ 'no-obj-calls': 'error',
117
+
114
118
  // Disallow returning values from Promise executor functions
115
119
  // https://eslint.org/docs/rules/no-promise-executor-return
116
120
  'no-promise-executor-return': 'error',
@@ -167,10 +171,6 @@ export const errors = () => ({
167
171
  // https://eslint.org/docs/rules/no-useless-backreference
168
172
  'no-useless-backreference': 'error',
169
173
 
170
- // disallow negation of the left operand of an in expression
171
- // deprecated in favor of no-unsafe-negation
172
- 'no-negated-in-lhs': 'off',
173
-
174
174
  // Disallow assignments that can lead to race conditions due to usage of await or yield
175
175
  // https://eslint.org/docs/rules/require-atomic-updates
176
176
  // note: not enabled because it is very buggy
@@ -14,14 +14,14 @@ export const es6 = () => ({
14
14
 
15
15
  // require space before/after arrow function's arrow
16
16
  // https://eslint.org/docs/rules/arrow-spacing
17
- 'arrow-spacing': ['error', { before: true, after: true }],
17
+ 'arrow-spacing': ['error', { after: true, before: true }],
18
18
 
19
19
  // verify super() callings in constructors
20
20
  'constructor-super': 'error',
21
21
 
22
22
  // enforce the spacing around the * in generator functions
23
23
  // https://eslint.org/docs/rules/generator-star-spacing
24
- 'generator-star-spacing': ['error', { before: false, after: true }],
24
+ 'generator-star-spacing': ['error', { after: true, before: false }],
25
25
 
26
26
  // disallow modifying variables of class declarations
27
27
  // https://eslint.org/docs/rules/no-class-assign
@@ -81,8 +81,8 @@ export const es6 = () => ({
81
81
  // https://eslint.org/docs/rules/no-useless-rename
82
82
  'no-useless-rename': ['error', {
83
83
  ignoreDestructuring: false,
84
- ignoreImport: false,
85
84
  ignoreExport: false,
85
+ ignoreImport: false,
86
86
  }],
87
87
 
88
88
  // require let or const instead of var
@@ -91,8 +91,8 @@ export const es6 = () => ({
91
91
  // require method and property shorthand syntax for object literals
92
92
  // https://eslint.org/docs/rules/object-shorthand
93
93
  'object-shorthand': ['error', 'always', {
94
- ignoreConstructors: false,
95
94
  avoidQuotes: true,
95
+ ignoreConstructors: false,
96
96
  }],
97
97
 
98
98
  // suggest using arrow functions as callbacks
@@ -110,14 +110,14 @@ export const es6 = () => ({
110
110
  // Prefer destructuring from arrays and objects
111
111
  // https://eslint.org/docs/rules/prefer-destructuring
112
112
  'prefer-destructuring': ['error', {
113
- VariableDeclarator: {
114
- array: false,
115
- object: true,
116
- },
117
113
  AssignmentExpression: {
118
114
  array: true,
119
115
  object: false,
120
116
  },
117
+ VariableDeclarator: {
118
+ array: false,
119
+ object: true,
120
+ },
121
121
  }, {
122
122
  enforceForRenamedProperties: false,
123
123
  }],
@@ -18,14 +18,14 @@ export const variables = () => ({
18
18
  'no-restricted-globals': [
19
19
  'error',
20
20
  {
21
- name: 'isFinite',
22
21
  message:
23
22
  'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
23
+ name: 'isFinite',
24
24
  },
25
25
  {
26
- name: 'isNaN',
27
26
  message:
28
27
  'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
28
+ name: 'isNaN',
29
29
  },
30
30
  // ...confusingBrowserGlobals.map((g) => ({
31
31
  // name: g,
@@ -51,8 +51,8 @@ export const variables = () => ({
51
51
  'no-undefined': 'off',
52
52
 
53
53
  // disallow declaration of variables that are not used in the code
54
- 'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
54
+ 'no-unused-vars': ['error', { args: 'after-used', ignoreRestSiblings: true, vars: 'all' }],
55
55
 
56
56
  // disallow use of variables before they are defined
57
- 'no-use-before-define': ['error', { functions: true, classes: true, variables: true }],
57
+ 'no-use-before-define': ['error', { classes: true, functions: true, variables: true }],
58
58
  } satisfies Linter.RulesRecord);
@@ -1,4 +1,5 @@
1
1
  import { ESLintConfig } from '@w5s/dev';
2
+
2
3
  import { esRules } from './esRules.js';
3
4
 
4
5
  export const tsRules = () => {
@@ -1,19 +1,23 @@
1
1
  import type { Linter } from 'eslint';
2
+
2
3
  import type { StylisticParameters } from './StylisticConfig.js';
3
4
 
4
5
  export interface PluginOptionsBase<Rules> {
5
- files?: Linter.Config['files'];
6
-
7
6
  /**
8
- * Plugin rules
7
+ * Files to apply
9
8
  */
10
- rules?: Rules;
9
+ files?: ((currentFiles: Array<string>) => Array<string>) | Linter.Config['files'];
11
10
 
12
11
  /**
13
12
  * Include recommended settings
14
13
  */
15
14
  recommended?: boolean;
16
15
 
16
+ /**
17
+ * Plugin rules
18
+ */
19
+ rules?: Rules;
20
+
17
21
  /**
18
22
  * Stylistic options
19
23
  */
@@ -1,11 +1,12 @@
1
1
  import type { StylisticCustomizeOptions } from '@stylistic/eslint-plugin';
2
+
2
3
  import prettierConfig from '@w5s/prettier-config';
3
4
 
4
5
  export interface StylisticConfig {
5
6
  enabled: boolean;
6
7
  indent: NonNullable<StylisticCustomizeOptions['indent']>;
7
- quotes: NonNullable<StylisticCustomizeOptions['quotes']>;
8
8
  jsx: NonNullable<StylisticCustomizeOptions['jsx']>;
9
+ quotes: NonNullable<StylisticCustomizeOptions['quotes']>;
9
10
  semi: NonNullable<StylisticCustomizeOptions['semi']>;
10
11
  }
11
12
 
@@ -14,8 +15,8 @@ export interface StylisticParameters extends Partial<StylisticConfig> {}
14
15
  const defaultConfig = {
15
16
  enabled: true,
16
17
  indent: prettierConfig.tabWidth ?? 2,
17
- quotes: prettierConfig.singleQuote ? 'single' : 'double',
18
18
  jsx: true,
19
+ quotes: prettierConfig.singleQuote ? 'single' : 'double',
19
20
  semi: prettierConfig.semi ?? true,
20
21
  } satisfies StylisticConfig;
21
22