@w5s/eslint-config 3.12.0 → 3.14.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/dist/index.d.ts +3 -56
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +102 -139
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/config/imports.ts +5 -2
- package/src/config/jsdoc.ts +48 -13
- package/src/config/jsonc.ts +1 -1
- package/src/config/ts.ts +39 -2
- package/src/config/unicorn.ts +3 -2
- package/src/config/yml.ts +1 -1
- package/src/defineConfig.ts +9 -4
- package/src/rules/esRules/bestPractices.ts +4 -4
- package/src/rules/esRules/errors.ts +7 -7
- package/src/rules/esRules/es6.ts +35 -35
- package/src/rules/esRules/overrides.ts +1 -1
- package/src/rules/esStylistic.ts +98 -0
- package/src/rules/tsRules.ts +1 -63
package/src/config/imports.ts
CHANGED
|
@@ -10,10 +10,13 @@ export async function imports(options: imports.Options = {}) {
|
|
|
10
10
|
const [importPlugin] = await Promise.all([interopDefault(import('eslint-plugin-import'))] as const);
|
|
11
11
|
return [
|
|
12
12
|
{
|
|
13
|
-
name: 'w5s/import/
|
|
13
|
+
name: 'w5s/import/setup',
|
|
14
14
|
plugins: {
|
|
15
15
|
import: importPlugin,
|
|
16
16
|
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'w5s/import/rules',
|
|
17
20
|
rules: {
|
|
18
21
|
...(recommended ? imports['recommended'] : {}),
|
|
19
22
|
...(stylisticEnabled
|
|
@@ -22,7 +25,7 @@ export async function imports(options: imports.Options = {}) {
|
|
|
22
25
|
...rules,
|
|
23
26
|
},
|
|
24
27
|
},
|
|
25
|
-
] as [Config] satisfies Array<Config>;
|
|
28
|
+
] as [Config, Config] satisfies Array<Config>;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
/**
|
package/src/config/jsdoc.ts
CHANGED
|
@@ -2,13 +2,14 @@ import { interopDefault } from '@w5s/dev';
|
|
|
2
2
|
|
|
3
3
|
import type { RuleOptions } from '../typegen/jsdoc.js';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { esSourceGlob, tsSourceGlob } from '../glob.js';
|
|
6
6
|
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
7
7
|
import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const defaultJsFiles = [esSourceGlob];
|
|
10
|
+
const defaultTsFiles = [tsSourceGlob];
|
|
10
11
|
|
|
11
|
-
export async function jsdoc(options: jsdoc.Options = {}): Promise<
|
|
12
|
+
export async function jsdoc(options: jsdoc.Options = {}): Promise<ReadonlyArray<Config>> {
|
|
12
13
|
const [jsdocPlugin] = await Promise.all([interopDefault(import('eslint-plugin-jsdoc'))] as const);
|
|
13
14
|
const {
|
|
14
15
|
files,
|
|
@@ -18,6 +19,18 @@ export async function jsdoc(options: jsdoc.Options = {}): Promise<readonly Confi
|
|
|
18
19
|
} = options;
|
|
19
20
|
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
20
21
|
|
|
22
|
+
const recommendedRules = recommended
|
|
23
|
+
? jsdocPlugin.configs['flat/recommended-typescript-flavor'].rules
|
|
24
|
+
: {};
|
|
25
|
+
const stylisticRules = stylisticEnabled
|
|
26
|
+
? {
|
|
27
|
+
...jsdocPlugin.configs['flat/stylistic-typescript'].rules,
|
|
28
|
+
'jsdoc/check-alignment': 'warn',
|
|
29
|
+
'jsdoc/multiline-blocks': 'warn',
|
|
30
|
+
'jsdoc/tag-lines': ['warn', 'any', { startLines: 1 }],
|
|
31
|
+
}
|
|
32
|
+
: {};
|
|
33
|
+
|
|
21
34
|
return [
|
|
22
35
|
{
|
|
23
36
|
name: 'w5s/jsdoc/setup',
|
|
@@ -26,10 +39,10 @@ export async function jsdoc(options: jsdoc.Options = {}): Promise<readonly Confi
|
|
|
26
39
|
},
|
|
27
40
|
},
|
|
28
41
|
{
|
|
29
|
-
files: withDefaultFiles(files,
|
|
30
|
-
name: 'w5s/jsdoc/rules',
|
|
42
|
+
files: withDefaultFiles(files, defaultJsFiles),
|
|
43
|
+
name: 'w5s/jsdoc/rules-js',
|
|
31
44
|
rules: {
|
|
32
|
-
...
|
|
45
|
+
...recommendedRules,
|
|
33
46
|
|
|
34
47
|
...(recommended
|
|
35
48
|
? {
|
|
@@ -39,19 +52,41 @@ export async function jsdoc(options: jsdoc.Options = {}): Promise<readonly Confi
|
|
|
39
52
|
'jsdoc/require-param-description': 'off',
|
|
40
53
|
'jsdoc/require-param-type': 'off',
|
|
41
54
|
'jsdoc/require-returns': 'off',
|
|
55
|
+
'jsdoc/require-returns-type': 'off',
|
|
42
56
|
'jsdoc/valid-types': 'off', // FIXME: reports lots of false positive
|
|
43
57
|
}
|
|
44
58
|
: {}),
|
|
45
59
|
|
|
46
|
-
|
|
47
|
-
...
|
|
60
|
+
...stylisticRules,
|
|
61
|
+
...rules,
|
|
62
|
+
},
|
|
63
|
+
settings: {
|
|
64
|
+
jsdoc: {
|
|
65
|
+
mode: 'typescript',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
files: withDefaultFiles(files, defaultTsFiles),
|
|
71
|
+
name: 'w5s/jsdoc/rules-ts',
|
|
72
|
+
rules: {
|
|
73
|
+
...recommendedRules,
|
|
74
|
+
|
|
75
|
+
...(recommended
|
|
48
76
|
? {
|
|
49
|
-
|
|
50
|
-
'jsdoc/
|
|
51
|
-
'jsdoc/
|
|
52
|
-
'jsdoc/
|
|
77
|
+
'jsdoc/no-types': 'warn',
|
|
78
|
+
'jsdoc/no-undefined-types': 'off', // https://github.com/gajus/eslint-plugin-jsdoc/issues/839
|
|
79
|
+
'jsdoc/require-hyphen-before-param-description': ['warn', 'always'],
|
|
80
|
+
'jsdoc/require-jsdoc': 'off',
|
|
81
|
+
'jsdoc/require-param-description': 'off',
|
|
82
|
+
'jsdoc/require-param-type': 'off',
|
|
83
|
+
'jsdoc/require-returns': 'off',
|
|
84
|
+
'jsdoc/require-returns-type': 'off',
|
|
85
|
+
'jsdoc/valid-types': 'off', // FIXME: reports lots of false positive
|
|
53
86
|
}
|
|
54
87
|
: {}),
|
|
88
|
+
|
|
89
|
+
...stylisticRules,
|
|
55
90
|
...rules,
|
|
56
91
|
},
|
|
57
92
|
settings: {
|
|
@@ -60,7 +95,7 @@ export async function jsdoc(options: jsdoc.Options = {}): Promise<readonly Confi
|
|
|
60
95
|
},
|
|
61
96
|
},
|
|
62
97
|
},
|
|
63
|
-
] as [Config, Config] satisfies Array<Config>;
|
|
98
|
+
] as [Config, Config, Config] satisfies Array<Config>;
|
|
64
99
|
}
|
|
65
100
|
|
|
66
101
|
export namespace jsdoc {
|
package/src/config/jsonc.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js
|
|
|
9
9
|
|
|
10
10
|
const defaultFiles = [jsonSourceGlob];
|
|
11
11
|
|
|
12
|
-
export async function jsonc(options: jsonc.Options = {}): Promise<
|
|
12
|
+
export async function jsonc(options: jsonc.Options = {}): Promise<ReadonlyArray<Config>> {
|
|
13
13
|
const [jsoncPlugin, jsoncParser] = await Promise.all([
|
|
14
14
|
interopDefault(import('eslint-plugin-jsonc')),
|
|
15
15
|
interopDefault(import('jsonc-eslint-parser')),
|
package/src/config/ts.ts
CHANGED
|
@@ -20,6 +20,7 @@ export async function ts(options: ts.Options = {}) {
|
|
|
20
20
|
const tsTypeCheckedRules = tsPlugin.configs['recommended-type-checked-only']!.rules!;
|
|
21
21
|
const { files, rules = {}, stylistic = true, typeChecked = false } = options;
|
|
22
22
|
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
23
|
+
const tsCustomRules = tsRules();
|
|
23
24
|
|
|
24
25
|
return [
|
|
25
26
|
{
|
|
@@ -51,8 +52,44 @@ export async function ts(options: ts.Options = {}) {
|
|
|
51
52
|
rules: {
|
|
52
53
|
...ESLintConfig.renameRules(tsRecommendedRules, { '@typescript-eslint': 'ts' }),
|
|
53
54
|
...ESLintConfig.renameRules(tsStrictRules, { '@typescript-eslint': 'ts' }),
|
|
54
|
-
...
|
|
55
|
-
...(stylisticEnabled
|
|
55
|
+
...tsCustomRules,
|
|
56
|
+
...(stylisticEnabled
|
|
57
|
+
? {
|
|
58
|
+
// eslint-disable-next-line ts/no-non-null-asserted-optional-chain
|
|
59
|
+
...ESLintConfig.renameRules(tsPlugin.configs['stylistic']?.rules!, { '@typescript-eslint': 'ts' }),
|
|
60
|
+
'ts/array-type': ['error', { default: 'generic' }],
|
|
61
|
+
'ts/consistent-type-assertions': [
|
|
62
|
+
'error',
|
|
63
|
+
{ assertionStyle: 'as', objectLiteralTypeAssertions: 'allow' },
|
|
64
|
+
],
|
|
65
|
+
'ts/naming-convention': [
|
|
66
|
+
'error',
|
|
67
|
+
// {
|
|
68
|
+
// format: ['PascalCase', 'camelCase'],
|
|
69
|
+
// leadingUnderscore: 'allow',
|
|
70
|
+
// selector: 'default',
|
|
71
|
+
// trailingUnderscore: 'allow',
|
|
72
|
+
// },
|
|
73
|
+
{
|
|
74
|
+
format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
|
|
75
|
+
leadingUnderscore: 'allow',
|
|
76
|
+
selector: 'variable',
|
|
77
|
+
trailingUnderscore: 'allow',
|
|
78
|
+
},
|
|
79
|
+
// {
|
|
80
|
+
// format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
|
|
81
|
+
// leadingUnderscore: 'allowSingleOrDouble',
|
|
82
|
+
// selector: 'memberLike',
|
|
83
|
+
// trailingUnderscore: 'allowDouble',
|
|
84
|
+
// },
|
|
85
|
+
{
|
|
86
|
+
format: ['PascalCase'],
|
|
87
|
+
selector: 'typeLike',
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
'ts/no-empty-function': tsCustomRules['ts/no-empty-function'],
|
|
91
|
+
}
|
|
92
|
+
: {}),
|
|
56
93
|
...rules,
|
|
57
94
|
},
|
|
58
95
|
},
|
package/src/config/unicorn.ts
CHANGED
|
@@ -3,13 +3,14 @@ import { interopDefault } from '@w5s/dev';
|
|
|
3
3
|
import type { RuleOptions } from '../typegen/unicorn.js';
|
|
4
4
|
|
|
5
5
|
import { sourceGlob } from '../glob.js';
|
|
6
|
+
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
6
7
|
import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
|
|
7
8
|
|
|
8
9
|
const defaultFiles = [sourceGlob];
|
|
9
10
|
|
|
10
11
|
export async function unicorn(options: unicorn.Options = {}) {
|
|
11
12
|
const [unicornPlugin] = await Promise.all([interopDefault(import('eslint-plugin-unicorn'))] as const);
|
|
12
|
-
const { files
|
|
13
|
+
const { files, recommended = true, rules = {}, stylistic = true } = options;
|
|
13
14
|
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
14
15
|
|
|
15
16
|
return [
|
|
@@ -20,7 +21,7 @@ export async function unicorn(options: unicorn.Options = {}) {
|
|
|
20
21
|
},
|
|
21
22
|
},
|
|
22
23
|
{
|
|
23
|
-
files,
|
|
24
|
+
files: withDefaultFiles(files, defaultFiles),
|
|
24
25
|
name: 'w5s/unicorn/rules',
|
|
25
26
|
rules: {
|
|
26
27
|
...(recommended && unicornPlugin.configs['unopinionated'].rules),
|
package/src/config/yml.ts
CHANGED
|
@@ -28,7 +28,7 @@ export async function yml(options: yml.Options = {}) {
|
|
|
28
28
|
...(recommended
|
|
29
29
|
? ymlPlugin.configs['recommended'].reduce(
|
|
30
30
|
(acc, config) => ({ ...acc, ...config.rules }),
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
{} as RuleOptions,
|
|
33
33
|
)
|
|
34
34
|
: {}),
|
package/src/defineConfig.ts
CHANGED
|
@@ -56,13 +56,18 @@ export async function defineConfig(options: DefineConfigOptions = {}) {
|
|
|
56
56
|
const stylisticOptions =
|
|
57
57
|
typeof plugins.stylistic === 'boolean' ? { enabled: plugins.stylistic } : { enabled: true, ...plugins.stylistic };
|
|
58
58
|
const withDefaultStylistic = <T>(_options: T) => ({ stylistic: stylisticOptions, ..._options });
|
|
59
|
-
const toOption = <T extends {}>(
|
|
59
|
+
const toOption = <T extends {}>(
|
|
60
|
+
optionsOrBoolean: boolean | T | undefined,
|
|
61
|
+
defaultEnabled = true,
|
|
62
|
+
) =>
|
|
60
63
|
withDefaultStylistic(
|
|
61
64
|
(typeof optionsOrBoolean === 'boolean'
|
|
62
65
|
? { enabled: optionsOrBoolean }
|
|
63
|
-
:
|
|
66
|
+
: optionsOrBoolean === undefined
|
|
67
|
+
? { enabled: defaultEnabled }
|
|
68
|
+
: { enabled: defaultEnabled, ...optionsOrBoolean }) as T & { enabled: boolean },
|
|
64
69
|
);
|
|
65
|
-
const includeEnabled = <T extends { enabled?: boolean }, R extends Promise<
|
|
70
|
+
const includeEnabled = <T extends { enabled?: boolean }, R extends Promise<ReadonlyArray<Config>>>(factory: (config: T) => R, input: T) =>
|
|
66
71
|
input.enabled ? [factory(input)] : [];
|
|
67
72
|
|
|
68
73
|
return ESLintConfig.concat(
|
|
@@ -76,7 +81,7 @@ export async function defineConfig(options: DefineConfigOptions = {}) {
|
|
|
76
81
|
...includeEnabled(stylistic, toOption(plugins.stylistic)),
|
|
77
82
|
...includeEnabled(imports, toOption(plugins.import)),
|
|
78
83
|
...includeEnabled(markdown, toOption(plugins.markdown)),
|
|
79
|
-
...includeEnabled(next, toOption(plugins.next)),
|
|
84
|
+
...includeEnabled(next, toOption(plugins.next, false)),
|
|
80
85
|
...includeEnabled(node, toOption(plugins.node)),
|
|
81
86
|
...includeEnabled(perfectionist, toOption(plugins.perfectionist)),
|
|
82
87
|
...includeEnabled(unicorn, toOption(plugins.unicorn)),
|
|
@@ -44,7 +44,7 @@ export const bestPractices = () => ({
|
|
|
44
44
|
|
|
45
45
|
// enforces consistent newlines before or after dots
|
|
46
46
|
// https://eslint.org/docs/rules/dot-location
|
|
47
|
-
'dot-location': ['error', 'property'],
|
|
47
|
+
// 'dot-location': ['error', 'property'],
|
|
48
48
|
|
|
49
49
|
// encourages use of dot notation whenever possible
|
|
50
50
|
// https://eslint.org/docs/rules/dot-notation
|
|
@@ -190,9 +190,9 @@ export const bestPractices = () => ({
|
|
|
190
190
|
|
|
191
191
|
// disallow use of multiple spaces
|
|
192
192
|
// https://eslint.org/docs/rules/no-multi-spaces
|
|
193
|
-
'no-multi-spaces': ['error', {
|
|
194
|
-
|
|
195
|
-
}],
|
|
193
|
+
// 'no-multi-spaces': ['error', {
|
|
194
|
+
// ignoreEOLComments: false,
|
|
195
|
+
// }],
|
|
196
196
|
|
|
197
197
|
// disallow use of multiline strings
|
|
198
198
|
// https://eslint.org/docs/rules/no-multi-str
|
|
@@ -69,13 +69,13 @@ export const errors = () => ({
|
|
|
69
69
|
|
|
70
70
|
// disallow unnecessary parentheses
|
|
71
71
|
// https://eslint.org/docs/rules/no-extra-parens
|
|
72
|
-
'no-extra-parens': ['off', 'all', {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}],
|
|
72
|
+
// 'no-extra-parens': ['off', 'all', {
|
|
73
|
+
// conditionalAssign: true,
|
|
74
|
+
// enforceForArrowConditionals: false,
|
|
75
|
+
// ignoreJSX: 'all', // delegate to eslint-plugin-react
|
|
76
|
+
// nestedBinaryExpressions: false,
|
|
77
|
+
// returnAssign: false,
|
|
78
|
+
// }],
|
|
79
79
|
|
|
80
80
|
// disallow unnecessary semicolons
|
|
81
81
|
'no-extra-semi': 'error',
|
package/src/rules/esRules/es6.ts
CHANGED
|
@@ -4,24 +4,24 @@ export const es6 = () => ({
|
|
|
4
4
|
// enforces no braces where they can be omitted
|
|
5
5
|
// https://eslint.org/docs/rules/arrow-body-style
|
|
6
6
|
// TODO: enable requireReturnForObjectLiteral?
|
|
7
|
-
'arrow-body-style': ['error', 'as-needed', {
|
|
8
|
-
|
|
9
|
-
}],
|
|
7
|
+
// 'arrow-body-style': ['error', 'as-needed', {
|
|
8
|
+
// requireReturnForObjectLiteral: false,
|
|
9
|
+
// }],
|
|
10
10
|
|
|
11
11
|
// require parens in arrow function arguments
|
|
12
12
|
// https://eslint.org/docs/rules/arrow-parens
|
|
13
|
-
'arrow-parens': ['error', 'always'],
|
|
13
|
+
// 'arrow-parens': ['error', 'always'],
|
|
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', { after: true, before: 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', { after: true, before: false }],
|
|
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
|
|
@@ -90,16 +90,16 @@ export const es6 = () => ({
|
|
|
90
90
|
|
|
91
91
|
// require method and property shorthand syntax for object literals
|
|
92
92
|
// https://eslint.org/docs/rules/object-shorthand
|
|
93
|
-
'object-shorthand': ['error', 'always', {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}],
|
|
93
|
+
// 'object-shorthand': ['error', 'always', {
|
|
94
|
+
// avoidQuotes: true,
|
|
95
|
+
// ignoreConstructors: false,
|
|
96
|
+
// }],
|
|
97
97
|
|
|
98
98
|
// suggest using arrow functions as callbacks
|
|
99
|
-
'prefer-arrow-callback': ['error', {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}],
|
|
99
|
+
// 'prefer-arrow-callback': ['error', {
|
|
100
|
+
// allowNamedFunctions: false,
|
|
101
|
+
// allowUnboundThis: true,
|
|
102
|
+
// }],
|
|
103
103
|
|
|
104
104
|
// suggest using of const declaration for variables that are never modified after declared
|
|
105
105
|
'prefer-const': ['error', {
|
|
@@ -109,18 +109,18 @@ export const es6 = () => ({
|
|
|
109
109
|
|
|
110
110
|
// Prefer destructuring from arrays and objects
|
|
111
111
|
// https://eslint.org/docs/rules/prefer-destructuring
|
|
112
|
-
'prefer-destructuring': ['error', {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}, {
|
|
122
|
-
|
|
123
|
-
}],
|
|
112
|
+
// 'prefer-destructuring': ['error', {
|
|
113
|
+
// AssignmentExpression: {
|
|
114
|
+
// array: true,
|
|
115
|
+
// object: false,
|
|
116
|
+
// },
|
|
117
|
+
// VariableDeclarator: {
|
|
118
|
+
// array: false,
|
|
119
|
+
// object: true,
|
|
120
|
+
// },
|
|
121
|
+
// }, {
|
|
122
|
+
// enforceForRenamedProperties: false,
|
|
123
|
+
// }],
|
|
124
124
|
|
|
125
125
|
// disallow parseInt() in favor of binary, octal, and hexadecimal literals
|
|
126
126
|
// https://eslint.org/docs/rules/prefer-numeric-literals
|
|
@@ -148,16 +148,16 @@ export const es6 = () => ({
|
|
|
148
148
|
|
|
149
149
|
// enforce spacing between object rest-spread
|
|
150
150
|
// https://eslint.org/docs/rules/rest-spread-spacing
|
|
151
|
-
'rest-spread-spacing': ['error', 'never'],
|
|
151
|
+
// 'rest-spread-spacing': ['error', 'never'],
|
|
152
152
|
|
|
153
153
|
// import sorting
|
|
154
154
|
// https://eslint.org/docs/rules/sort-imports
|
|
155
|
-
'sort-imports': ['off', {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}],
|
|
155
|
+
// 'sort-imports': ['off', {
|
|
156
|
+
// ignoreCase: false,
|
|
157
|
+
// ignoreDeclarationSort: false,
|
|
158
|
+
// ignoreMemberSort: false,
|
|
159
|
+
// memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
|
|
160
|
+
// }],
|
|
161
161
|
|
|
162
162
|
// require a Symbol description
|
|
163
163
|
// https://eslint.org/docs/rules/symbol-description
|
|
@@ -165,9 +165,9 @@ export const es6 = () => ({
|
|
|
165
165
|
|
|
166
166
|
// enforce usage of spacing in template strings
|
|
167
167
|
// https://eslint.org/docs/rules/template-curly-spacing
|
|
168
|
-
'template-curly-spacing': 'error',
|
|
168
|
+
// 'template-curly-spacing': 'error',
|
|
169
169
|
|
|
170
170
|
// enforce spacing around the * in yield* expressions
|
|
171
171
|
// https://eslint.org/docs/rules/yield-star-spacing
|
|
172
|
-
'yield-star-spacing': ['error', 'after'],
|
|
172
|
+
// 'yield-star-spacing': ['error', 'after'],
|
|
173
173
|
} satisfies Linter.RulesRecord);
|
|
@@ -24,5 +24,5 @@ export const overrides = () => ({
|
|
|
24
24
|
'no-use-before-define': ['error', 'nofunc'],
|
|
25
25
|
// Allow statements, to be compatible with '@typescript-eslint/no-floating-promises' fix
|
|
26
26
|
'no-void': ['error', { allowAsStatement: true }],
|
|
27
|
-
'unicode-bom': ['error', 'never'],
|
|
27
|
+
// 'unicode-bom': ['error', 'never'],
|
|
28
28
|
} satisfies Linter.RulesRecord);
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
|
|
3
|
+
// Extracted from airbnb base but not used at the moment
|
|
4
|
+
export const esStylistic = () => ({
|
|
5
|
+
// enforces no braces where they can be omitted
|
|
6
|
+
// https://eslint.org/docs/rules/arrow-body-style
|
|
7
|
+
// TODO: enable requireReturnForObjectLiteral?
|
|
8
|
+
'arrow-body-style': ['error', 'as-needed', {
|
|
9
|
+
requireReturnForObjectLiteral: false,
|
|
10
|
+
}],
|
|
11
|
+
|
|
12
|
+
// require parens in arrow function arguments
|
|
13
|
+
// https://eslint.org/docs/rules/arrow-parens
|
|
14
|
+
'arrow-parens': ['error', 'always'],
|
|
15
|
+
|
|
16
|
+
// require space before/after arrow function's arrow
|
|
17
|
+
// https://eslint.org/docs/rules/arrow-spacing
|
|
18
|
+
'arrow-spacing': ['error', { after: true, before: true }],
|
|
19
|
+
|
|
20
|
+
// enforces consistent newlines before or after dots
|
|
21
|
+
// https://eslint.org/docs/rules/dot-location
|
|
22
|
+
'dot-location': ['error', 'property'],
|
|
23
|
+
|
|
24
|
+
// enforce the spacing around the * in generator functions
|
|
25
|
+
// https://eslint.org/docs/rules/generator-star-spacing
|
|
26
|
+
'generator-star-spacing': ['error', { after: true, before: false }],
|
|
27
|
+
|
|
28
|
+
// disallow unnecessary parentheses (stylistic)
|
|
29
|
+
// https://eslint.org/docs/rules/no-extra-parens
|
|
30
|
+
'no-extra-parens': ['off', 'all', {
|
|
31
|
+
conditionalAssign: true,
|
|
32
|
+
enforceForArrowConditionals: false,
|
|
33
|
+
ignoreJSX: 'all', // delegate to eslint-plugin-react
|
|
34
|
+
nestedBinaryExpressions: false,
|
|
35
|
+
returnAssign: false,
|
|
36
|
+
}],
|
|
37
|
+
|
|
38
|
+
// disallow use of multiple spaces
|
|
39
|
+
// https://eslint.org/docs/rules/no-multi-spaces
|
|
40
|
+
'no-multi-spaces': ['error', {
|
|
41
|
+
ignoreEOLComments: false,
|
|
42
|
+
}],
|
|
43
|
+
|
|
44
|
+
// require method and property shorthand syntax for object literals
|
|
45
|
+
// https://eslint.org/docs/rules/object-shorthand
|
|
46
|
+
'object-shorthand': ['error', 'always', {
|
|
47
|
+
avoidQuotes: true,
|
|
48
|
+
ignoreConstructors: false,
|
|
49
|
+
}],
|
|
50
|
+
|
|
51
|
+
// suggest using arrow functions as callbacks
|
|
52
|
+
'prefer-arrow-callback': ['error', {
|
|
53
|
+
allowNamedFunctions: false,
|
|
54
|
+
allowUnboundThis: true,
|
|
55
|
+
}],
|
|
56
|
+
|
|
57
|
+
// Prefer destructuring from arrays and objects
|
|
58
|
+
// https://eslint.org/docs/rules/prefer-destructuring
|
|
59
|
+
'prefer-destructuring': ['error', {
|
|
60
|
+
AssignmentExpression: {
|
|
61
|
+
array: true,
|
|
62
|
+
object: false,
|
|
63
|
+
},
|
|
64
|
+
VariableDeclarator: {
|
|
65
|
+
array: false,
|
|
66
|
+
object: true,
|
|
67
|
+
},
|
|
68
|
+
}, {
|
|
69
|
+
enforceForRenamedProperties: false,
|
|
70
|
+
}],
|
|
71
|
+
|
|
72
|
+
// enforce spacing between object rest-spread
|
|
73
|
+
// https://eslint.org/docs/rules/rest-spread-spacing
|
|
74
|
+
'rest-spread-spacing': ['error', 'never'],
|
|
75
|
+
|
|
76
|
+
// import sorting
|
|
77
|
+
// https://eslint.org/docs/rules/sort-imports
|
|
78
|
+
'sort-imports': ['off', {
|
|
79
|
+
ignoreCase: false,
|
|
80
|
+
ignoreDeclarationSort: false,
|
|
81
|
+
ignoreMemberSort: false,
|
|
82
|
+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
|
|
83
|
+
}],
|
|
84
|
+
|
|
85
|
+
// enforce usage of spacing in template strings
|
|
86
|
+
// https://eslint.org/docs/rules/template-curly-spacing
|
|
87
|
+
'template-curly-spacing': 'error',
|
|
88
|
+
|
|
89
|
+
// Unicode BOM handling
|
|
90
|
+
// https://eslint.org/docs/rules/unicode-bom
|
|
91
|
+
'unicode-bom': ['error', 'never'],
|
|
92
|
+
|
|
93
|
+
// enforce spacing around the * in yield* expressions
|
|
94
|
+
// https://eslint.org/docs/rules/yield-star-spacing
|
|
95
|
+
'yield-star-spacing': ['error', 'after'],
|
|
96
|
+
} satisfies Linter.RulesRecord);
|
|
97
|
+
|
|
98
|
+
export default esStylistic;
|
package/src/rules/tsRules.ts
CHANGED
|
@@ -7,16 +7,6 @@ export const tsRules = () => {
|
|
|
7
7
|
|
|
8
8
|
return ESLintConfig.renameRules(
|
|
9
9
|
{
|
|
10
|
-
// '@typescript-eslint/comma-dangle': [
|
|
11
|
-
// baseRules['comma-dangle'][0],
|
|
12
|
-
// {
|
|
13
|
-
// ...baseRules['comma-dangle'][1],
|
|
14
|
-
// enums: baseRules['comma-dangle'][1].arrays,
|
|
15
|
-
// generics: baseRules['comma-dangle'][1].arrays,
|
|
16
|
-
// tuples: baseRules['comma-dangle'][1].arrays,
|
|
17
|
-
// },
|
|
18
|
-
// ],
|
|
19
|
-
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
20
10
|
'@typescript-eslint/ban-ts-comment': [
|
|
21
11
|
'warn',
|
|
22
12
|
{
|
|
@@ -27,65 +17,17 @@ export const tsRules = () => {
|
|
|
27
17
|
'ts-nocheck': true,
|
|
28
18
|
},
|
|
29
19
|
],
|
|
30
|
-
// '@typescript-eslint/brace-style': baseRules['brace-style'],
|
|
31
|
-
// '@typescript-eslint/comma-dangle': [
|
|
32
|
-
// baseRules['comma-dangle'][0],
|
|
33
|
-
// {
|
|
34
|
-
// ...baseRules['comma-dangle'][1],
|
|
35
|
-
// enums: baseRules['comma-dangle'][1].arrays,
|
|
36
|
-
// generics: baseRules['comma-dangle'][1].arrays,
|
|
37
|
-
// tuples: baseRules['comma-dangle'][1].arrays,
|
|
38
|
-
// },
|
|
39
|
-
// ],
|
|
40
|
-
// '@typescript-eslint/comma-spacing': baseRules['comma-spacing'],
|
|
41
|
-
'@typescript-eslint/consistent-type-assertions': [
|
|
42
|
-
'error',
|
|
43
|
-
{ assertionStyle: 'as', objectLiteralTypeAssertions: 'never' },
|
|
44
|
-
],
|
|
45
20
|
'@typescript-eslint/default-param-last': baseRules['default-param-last'],
|
|
46
|
-
// '@typescript-eslint/dot-notation': baseRules['dot-notation'], // TODO: Stylistic typechecked
|
|
47
21
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
48
22
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
49
|
-
|
|
50
|
-
// '@typescript-eslint/indent': baseRules.indent,
|
|
51
|
-
// '@typescript-eslint/keyword-spacing': baseRules['keyword-spacing'],
|
|
52
|
-
// '@typescript-eslint/lines-between-class-members': baseRules['lines-between-class-members'],
|
|
53
|
-
// '@typescript-eslint/member-delimiter-style': 'error', // TODO: @stylistic/member-delimiter-style
|
|
54
|
-
'@typescript-eslint/naming-convention': [
|
|
55
|
-
'error',
|
|
56
|
-
// {
|
|
57
|
-
// format: ['PascalCase', 'camelCase'],
|
|
58
|
-
// leadingUnderscore: 'allow',
|
|
59
|
-
// selector: 'default',
|
|
60
|
-
// trailingUnderscore: 'allow',
|
|
61
|
-
// },
|
|
62
|
-
{
|
|
63
|
-
format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
|
|
64
|
-
leadingUnderscore: 'allow',
|
|
65
|
-
selector: 'variable',
|
|
66
|
-
trailingUnderscore: 'allow',
|
|
67
|
-
},
|
|
68
|
-
// {
|
|
69
|
-
// format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
|
|
70
|
-
// leadingUnderscore: 'allowSingleOrDouble',
|
|
71
|
-
// selector: 'memberLike',
|
|
72
|
-
// trailingUnderscore: 'allowDouble',
|
|
73
|
-
// },
|
|
74
|
-
{
|
|
75
|
-
format: ['PascalCase'],
|
|
76
|
-
selector: 'typeLike',
|
|
77
|
-
},
|
|
78
|
-
],
|
|
23
|
+
'@typescript-eslint/no-dupe-class-members': baseRules['no-dupe-class-members'],
|
|
79
24
|
// '@typescript-eslint/no-array-constructor': baseRules['no-array-constructor'],
|
|
80
25
|
// '@typescript-eslint/no-base-to-string': 'error', // TODO: require type check
|
|
81
|
-
'@typescript-eslint/no-dupe-class-members': baseRules['no-dupe-class-members'],
|
|
82
26
|
'@typescript-eslint/no-empty-function': baseRules['no-empty-function'],
|
|
83
27
|
'@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],
|
|
84
28
|
'@typescript-eslint/no-empty-object-type': 'off',
|
|
85
29
|
'@typescript-eslint/no-explicit-any': 'off', // if any is explicit then it's wanted
|
|
86
|
-
'@typescript-eslint/no-extra-parens': baseRules['no-extra-parens'],
|
|
87
30
|
// '@typescript-eslint/no-extra-semi': baseRules['no-extra-semi'], // TODO: @stylistic/no-extra-semi
|
|
88
|
-
'@typescript-eslint/no-inferrable-types': 'error',
|
|
89
31
|
'@typescript-eslint/no-loop-func': baseRules['no-loop-func'],
|
|
90
32
|
'@typescript-eslint/no-loss-of-precision': baseRules['no-loss-of-precision'],
|
|
91
33
|
'@typescript-eslint/no-magic-numbers': baseRules['no-magic-numbers'],
|
|
@@ -102,7 +44,6 @@ export const tsRules = () => {
|
|
|
102
44
|
'@typescript-eslint/no-unused-vars': baseRules['no-unused-vars'],
|
|
103
45
|
'@typescript-eslint/no-use-before-define': baseRules['no-use-before-define'],
|
|
104
46
|
'@typescript-eslint/no-useless-constructor': baseRules['no-useless-constructor'],
|
|
105
|
-
'@typescript-eslint/no-var-requires': 'error',
|
|
106
47
|
'@typescript-eslint/no-wrapper-object-types': 'error',
|
|
107
48
|
// '@typescript-eslint/object-curly-spacing': baseRules['object-curly-spacing'],
|
|
108
49
|
// '@typescript-eslint/only-throw-error': baseRules['no-throw-literal'], //TODO: Recommended type check
|
|
@@ -111,8 +52,6 @@ export const tsRules = () => {
|
|
|
111
52
|
// '@typescript-eslint/quotes': baseRules.quotes,
|
|
112
53
|
'@typescript-eslint/require-await': baseRules['require-await'],
|
|
113
54
|
// '@typescript-eslint/return-await': baseRules['no-return-await'], // TODO: strict type check
|
|
114
|
-
// '@typescript-eslint/semi': baseRules.semi,
|
|
115
|
-
// '@typescript-eslint/space-before-function-paren': baseRules['space-before-function-paren'],
|
|
116
55
|
// '@typescript-eslint/space-infix-ops': baseRules['space-infix-ops'],
|
|
117
56
|
// '@typescript-eslint/strict-boolean-expressions': [
|
|
118
57
|
// 'error',
|
|
@@ -124,7 +63,6 @@ export const tsRules = () => {
|
|
|
124
63
|
// ], //TODO: require typing
|
|
125
64
|
// '@typescript-eslint/switch-exhaustiveness-check': 'error',//TODO: require type check
|
|
126
65
|
'@typescript-eslint/triple-slash-reference': 'error',
|
|
127
|
-
// '@typescript-eslint/type-annotation-spacing': 'error',// TODO: @stylistic/type-annotation-spacing
|
|
128
66
|
},
|
|
129
67
|
{
|
|
130
68
|
'@typescript-eslint': 'ts',
|