@w5s/eslint-config 3.13.0 → 3.16.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 +402 -69
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +419 -135
- package/dist/index.js.map +1 -1
- package/package.json +10 -6
- package/src/config/jsdoc.ts +48 -13
- package/src/config/jsonc.ts +1 -1
- package/src/config/jsx.ts +51 -0
- package/src/config/react.ts +4 -2
- package/src/config/ts.ts +39 -2
- package/src/config/yml.ts +1 -1
- package/src/config.ts +1 -0
- package/src/defineConfig.ts +4 -1
- package/src/glob.ts +2 -0
- 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/typegen/jsx-a11y.d.ts +427 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/eslint-config",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.0",
|
|
4
4
|
"description": "ESLint configuration presets",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@e18e/eslint-plugin": "^0.5.0",
|
|
40
|
-
"@eslint-react/eslint-plugin": "5.
|
|
40
|
+
"@eslint-react/eslint-plugin": "5.11.2",
|
|
41
41
|
"@eslint/js": "^10.0.0",
|
|
42
42
|
"@eslint/markdown": "^8.0.0",
|
|
43
43
|
"@next/eslint-plugin-next": "^16.0.0",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
46
46
|
"@typescript-eslint/parser": "^8.0.0",
|
|
47
47
|
"@vitest/eslint-plugin": "~1.6.20",
|
|
48
|
-
"@w5s/dev": "^3.
|
|
49
|
-
"@w5s/eslint-config-ignore": "^1.
|
|
50
|
-
"@w5s/prettier-config": "^3.1.
|
|
48
|
+
"@w5s/dev": "^3.7.0",
|
|
49
|
+
"@w5s/eslint-config-ignore": "^1.6.0",
|
|
50
|
+
"@w5s/prettier-config": "^3.1.20",
|
|
51
51
|
"eslint-merge-processors": "^2.0.0",
|
|
52
52
|
"eslint-plugin-import": "~2.32.0",
|
|
53
53
|
"eslint-plugin-jsdoc": "~63.0.0",
|
|
@@ -63,12 +63,16 @@
|
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"eslint": "9.x || 10.x",
|
|
66
|
+
"eslint-plugin-jsx-a11y": ">=6.10.2",
|
|
66
67
|
"typescript": "4.x || 5.x || 6.x"
|
|
67
68
|
},
|
|
68
69
|
"peerDependenciesMeta": {
|
|
69
70
|
"eslint": {
|
|
70
71
|
"optional": true
|
|
71
72
|
},
|
|
73
|
+
"eslint-plugin-jsx-a11y": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
72
76
|
"typescript": {
|
|
73
77
|
"optional": true
|
|
74
78
|
}
|
|
@@ -80,5 +84,5 @@
|
|
|
80
84
|
"access": "public"
|
|
81
85
|
},
|
|
82
86
|
"sideEffect": false,
|
|
83
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "488ae0c9dcf081e3bf443c0cbc410a0fa8f10b12"
|
|
84
88
|
}
|
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')),
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { interopDefault } from '@w5s/dev';
|
|
2
|
+
|
|
3
|
+
import type { RuleOptions } from '../typegen/jsx-a11y.js';
|
|
4
|
+
|
|
5
|
+
import { jsxSourceGlob } from '../glob.js';
|
|
6
|
+
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
7
|
+
import { type Config, type PluginOptionsBase } from '../type.js';
|
|
8
|
+
|
|
9
|
+
const defaultFiles = [jsxSourceGlob];
|
|
10
|
+
|
|
11
|
+
export async function jsx(options: jsx.Options = {}) {
|
|
12
|
+
const { files, jsxA11y = false, recommended = true, rules = {} } = options;
|
|
13
|
+
const [jsxA11yPlugin] = await Promise.all([
|
|
14
|
+
jsxA11y ? interopDefault(import('eslint-plugin-jsx-a11y')) : undefined,
|
|
15
|
+
] as const);
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
languageOptions: {
|
|
19
|
+
parserOptions: {
|
|
20
|
+
ecmaFeatures: {
|
|
21
|
+
jsx: true,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
sourceType: 'module',
|
|
25
|
+
},
|
|
26
|
+
name: 'w5s/jsx/setup',
|
|
27
|
+
plugins: {
|
|
28
|
+
...(jsxA11yPlugin ? { 'jsx-a11y': jsxA11yPlugin } : {}),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
files: withDefaultFiles(files, defaultFiles),
|
|
33
|
+
name: 'w5s/jsx/rules',
|
|
34
|
+
rules: {
|
|
35
|
+
...(recommended && jsxA11yPlugin != null ? jsxA11yPlugin.configs['recommended'].rules : {}),
|
|
36
|
+
...rules,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
] as [Config, Config] satisfies Array<Config>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export namespace jsx {
|
|
43
|
+
export interface Options extends Omit<PluginOptionsBase<Rules>, 'stylistic'> {
|
|
44
|
+
/**
|
|
45
|
+
* Enable jsx-a11y plugin. Defaults to false.
|
|
46
|
+
*/
|
|
47
|
+
jsxA11y?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type Rules = RuleOptions;
|
|
51
|
+
}
|
package/src/config/react.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { interopDefault } from '@w5s/dev';
|
|
|
2
2
|
|
|
3
3
|
import type { RuleOptions } from '../typegen/react.js';
|
|
4
4
|
|
|
5
|
+
import { ESLintConfig } from '../../../dev/dist/index.cjs';
|
|
5
6
|
import { sourceGlob } from '../glob.js';
|
|
6
7
|
import { withDefaultFiles } from '../internal/withDefaultFiles.js';
|
|
7
8
|
import { type Config, type PluginOptionsBase } from '../type.js';
|
|
@@ -12,7 +13,7 @@ export async function react(options: react.Options = {}) {
|
|
|
12
13
|
const [reactPlugin] = await Promise.all([
|
|
13
14
|
interopDefault(import('@eslint-react/eslint-plugin')),
|
|
14
15
|
] as const);
|
|
15
|
-
const { files, recommended, rules = {} } = options;
|
|
16
|
+
const { files, recommended = true, rules = {} } = options;
|
|
16
17
|
return [
|
|
17
18
|
{
|
|
18
19
|
name: 'w5s/react/setup',
|
|
@@ -32,7 +33,8 @@ export async function react(options: react.Options = {}) {
|
|
|
32
33
|
},
|
|
33
34
|
name: 'w5s/react/rules',
|
|
34
35
|
rules: {
|
|
35
|
-
|
|
36
|
+
// eslint-disable-next-line ts/no-non-null-assertion
|
|
37
|
+
...(recommended ? ESLintConfig.renameRules(reactPlugin.configs['recommended'].rules!, { '@eslint-react': 'react' }) : {}),
|
|
36
38
|
...rules,
|
|
37
39
|
},
|
|
38
40
|
},
|
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/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/config.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './config/ignores.js';
|
|
|
4
4
|
export * from './config/imports.js';
|
|
5
5
|
export * from './config/jsdoc.js';
|
|
6
6
|
export * from './config/jsonc.js';
|
|
7
|
+
export * from './config/jsx.js';
|
|
7
8
|
export * from './config/markdown.js';
|
|
8
9
|
export * from './config/next.js';
|
|
9
10
|
export * from './config/node.js';
|
package/src/defineConfig.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
imports,
|
|
12
12
|
jsdoc,
|
|
13
13
|
jsonc,
|
|
14
|
+
jsx,
|
|
14
15
|
markdown,
|
|
15
16
|
next,
|
|
16
17
|
node,
|
|
@@ -33,6 +34,7 @@ export interface DefineConfigOptions extends ignores.Options {
|
|
|
33
34
|
import?: boolean | imports.Options;
|
|
34
35
|
jsdoc?: boolean | jsdoc.Options;
|
|
35
36
|
jsonc?: boolean | jsonc.Options;
|
|
37
|
+
jsx?: boolean | jsx.Options;
|
|
36
38
|
markdown?: boolean | markdown.Options;
|
|
37
39
|
next?: boolean | next.Options;
|
|
38
40
|
node?: boolean | node.Options;
|
|
@@ -67,7 +69,7 @@ export async function defineConfig(options: DefineConfigOptions = {}) {
|
|
|
67
69
|
? { enabled: defaultEnabled }
|
|
68
70
|
: { enabled: defaultEnabled, ...optionsOrBoolean }) as T & { enabled: boolean },
|
|
69
71
|
);
|
|
70
|
-
const includeEnabled = <T extends { enabled?: boolean }, R extends Promise<
|
|
72
|
+
const includeEnabled = <T extends { enabled?: boolean }, R extends Promise<ReadonlyArray<Config>>>(factory: (config: T) => R, input: T) =>
|
|
71
73
|
input.enabled ? [factory(input)] : [];
|
|
72
74
|
|
|
73
75
|
return ESLintConfig.concat(
|
|
@@ -77,6 +79,7 @@ export async function defineConfig(options: DefineConfigOptions = {}) {
|
|
|
77
79
|
...includeEnabled(ignores, toOption(options)),
|
|
78
80
|
...includeEnabled(jsonc, toOption(plugins.jsonc)),
|
|
79
81
|
...includeEnabled(jsdoc, toOption(plugins.jsdoc)),
|
|
82
|
+
...includeEnabled(jsx, toOption(plugins.jsx)),
|
|
80
83
|
...includeEnabled(react, toOption(plugins.react)),
|
|
81
84
|
...includeEnabled(stylistic, toOption(plugins.stylistic)),
|
|
82
85
|
...includeEnabled(imports, toOption(plugins.import)),
|
package/src/glob.ts
CHANGED
|
@@ -4,6 +4,8 @@ export const sourceGlob = `**/${Project.extensionsToGlob(Project.sourceExtension
|
|
|
4
4
|
|
|
5
5
|
export const esSourceGlob = `**/${Project.extensionsToGlob(Project.queryExtensions(['javascript', 'javascriptreact']))}`;
|
|
6
6
|
|
|
7
|
+
export const jsxSourceGlob = `**/${Project.extensionsToGlob(Project.queryExtensions(['javascriptreact', 'typescriptreact']))}`;
|
|
8
|
+
|
|
7
9
|
export const jsonSourceGlob = `**/${Project.extensionsToGlob(['.json', '.json5', '.jsonc'])}`;
|
|
8
10
|
|
|
9
11
|
export const tsSourceGlob = `**/${Project.extensionsToGlob(Project.queryExtensions(['typescript', 'typescriptreact']))}`;
|
|
@@ -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;
|