@ocavue/eslint-config 2.21.0 → 3.0.1
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 +0 -6
- package/dist/index.js +1 -9
- package/dist/markdown.js +13 -27
- package/dist/shared.d.ts +4 -0
- package/dist/shared.js +10 -0
- package/dist/types.d.ts +1 -0
- package/dist/typescript.js +132 -102
- package/package.json +3 -3
- package/dist/basic.d.ts +0 -2
- package/dist/basic.js +0 -22
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { type ESLintConfigOptions } from './options.js';
|
|
2
2
|
import type { Config } from './types.js';
|
|
3
|
-
export * from './basic.js';
|
|
4
|
-
export * from './markdown.js';
|
|
5
|
-
export * from './prettier.js';
|
|
6
|
-
export * from './react.js';
|
|
7
|
-
export * from './typescript.js';
|
|
8
|
-
export * from './vue.js';
|
|
9
3
|
export type { Config, ESLintConfigOptions };
|
|
10
4
|
export declare function defineESLintConfig(options?: ESLintConfigOptions, ...userConfigs: Config[]): Promise<Config[]>;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from 'eslint/config';
|
|
2
2
|
import { resolveOptions } from './options.js';
|
|
3
|
-
|
|
4
|
-
export * from './markdown.js';
|
|
5
|
-
export * from './prettier.js';
|
|
6
|
-
export * from './react.js';
|
|
7
|
-
export * from './typescript.js';
|
|
8
|
-
export * from './vue.js';
|
|
3
|
+
import { trueToUndefined } from './shared.js';
|
|
9
4
|
export async function defineESLintConfig(options, ...userConfigs) {
|
|
10
5
|
const resolvedOptions = resolveOptions(options);
|
|
11
6
|
const configs = [];
|
|
@@ -68,6 +63,3 @@ export async function defineESLintConfig(options, ...userConfigs) {
|
|
|
68
63
|
configs.push(...userConfigs);
|
|
69
64
|
return defineConfig(configs);
|
|
70
65
|
}
|
|
71
|
-
function trueToUndefined(value) {
|
|
72
|
-
return value === true ? undefined : value;
|
|
73
|
-
}
|
package/dist/markdown.js
CHANGED
|
@@ -1,41 +1,27 @@
|
|
|
1
1
|
import markdownPlugin from '@eslint/markdown';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
2
3
|
import { GLOB_MARKDOWN, GLOB_SRC, GLOB_VUE } from './shared.js';
|
|
3
4
|
export function markdown() {
|
|
4
|
-
const
|
|
5
|
-
|
|
5
|
+
const processor = markdownPlugin.configs.processor;
|
|
6
|
+
// @ts-expect-error: unmatched type: https://github.com/typescript-eslint/typescript-eslint/issues/10899
|
|
7
|
+
const disableTypeCheckedBase = tseslint.configs.disableTypeChecked;
|
|
8
|
+
const disableTypeChecked = {
|
|
9
|
+
...disableTypeCheckedBase,
|
|
10
|
+
name: 'ocavue/markdown/disable-type-checked',
|
|
11
|
+
files: [`${GLOB_MARKDOWN}/${GLOB_SRC}`, `${GLOB_MARKDOWN}/${GLOB_VUE}`],
|
|
12
|
+
};
|
|
13
|
+
const disableExtra = {
|
|
14
|
+
name: 'ocavue/markdown/disable-rules',
|
|
6
15
|
files: [`${GLOB_MARKDOWN}/${GLOB_SRC}`, `${GLOB_MARKDOWN}/${GLOB_VUE}`],
|
|
7
|
-
languageOptions: {
|
|
8
|
-
parserOptions: {
|
|
9
|
-
projectService: null,
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
16
|
rules: {
|
|
13
|
-
// Disable type-aware TypeScript rules, because the code blocks are not
|
|
14
|
-
// part of a compilable `tsconfig.json` project.
|
|
15
|
-
'@typescript-eslint/no-redeclare': 'off',
|
|
16
|
-
'@typescript-eslint/no-unused-vars': 'off',
|
|
17
|
-
'@typescript-eslint/no-use-before-define': 'off',
|
|
18
|
-
'@typescript-eslint/no-var-requires': 'off',
|
|
19
|
-
'@typescript-eslint/restrict-plus-operands': 'off',
|
|
20
|
-
'@typescript-eslint/no-unsafe-call': 'off',
|
|
21
|
-
'@typescript-eslint/no-unsafe-return': 'off',
|
|
22
|
-
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
23
|
-
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
24
|
-
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
25
|
-
'@typescript-eslint/no-floating-promises': 'off',
|
|
26
|
-
'@typescript-eslint/no-misused-promises': 'off',
|
|
27
|
-
'@typescript-eslint/await-thenable': 'off',
|
|
28
|
-
'@typescript-eslint/unbound-method': 'off',
|
|
29
|
-
'@typescript-eslint/require-await': 'off',
|
|
30
|
-
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
|
|
31
17
|
// Disable some import rules because they are not working well with
|
|
32
18
|
// twoslash ---cut--- imports.
|
|
33
19
|
'import/first': 'off',
|
|
34
20
|
'import/order': 'off',
|
|
35
21
|
'no-alert': 'off',
|
|
36
22
|
'no-console': 'off',
|
|
37
|
-
'no-
|
|
23
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
38
24
|
},
|
|
39
25
|
};
|
|
40
|
-
return [...
|
|
26
|
+
return [...processor, disableTypeChecked, disableExtra];
|
|
41
27
|
}
|
package/dist/shared.d.ts
CHANGED
|
@@ -21,3 +21,7 @@ export declare const GLOB_NODE_MODULES: "**/node_modules";
|
|
|
21
21
|
export declare const GLOB_LOCKFILE: readonly ["**/package-lock.json", "**/yarn.lock", "**/pnpm-lock.yaml"];
|
|
22
22
|
export declare const GLOB_EXCLUDE: readonly ["**/node_modules", "**/package-lock.json", "**/yarn.lock", "**/pnpm-lock.yaml", "**/fixtures", "**/.changeset", "**/CHANGELOG*.md", "**/*.min.*", "**/LICENSE*", "**/__snapshots__", "**/.tsup"];
|
|
23
23
|
export declare const EXTENSIONS: string[];
|
|
24
|
+
export declare function findConfigByName<T extends {
|
|
25
|
+
name?: string;
|
|
26
|
+
}>(configs: T[], name: string): T | undefined;
|
|
27
|
+
export declare function trueToUndefined<T>(value: T | true): T | undefined;
|
package/dist/shared.js
CHANGED
|
@@ -47,3 +47,13 @@ export const EXTENSIONS = ['ts', 'js']
|
|
|
47
47
|
.flatMap((ext) => [ext, ext + 'x'])
|
|
48
48
|
.flatMap((ext) => [ext, 'm' + ext, 'c' + ext])
|
|
49
49
|
.flatMap((ext) => [ext, 'd.' + ext]);
|
|
50
|
+
export function findConfigByName(configs, name) {
|
|
51
|
+
const config = configs.find((c) => c.name === name);
|
|
52
|
+
if (!config) {
|
|
53
|
+
console.error(`[@ocavue/eslint-config] Unable to find config with name ${name}`);
|
|
54
|
+
}
|
|
55
|
+
return config;
|
|
56
|
+
}
|
|
57
|
+
export function trueToUndefined(value) {
|
|
58
|
+
return value === true ? undefined : value;
|
|
59
|
+
}
|
package/dist/types.d.ts
CHANGED
package/dist/typescript.js
CHANGED
|
@@ -1,112 +1,142 @@
|
|
|
1
|
-
import eslint from '@eslint/js';
|
|
2
1
|
import tseslint from 'typescript-eslint';
|
|
3
|
-
import { GLOB_JS, GLOB_JSX,
|
|
2
|
+
import { findConfigByName, GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX, } from './shared.js';
|
|
4
3
|
export { tseslint };
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
function eslintRecommendedRules() {
|
|
5
|
+
return tseslint.configs.eslintRecommended.rules || {};
|
|
6
|
+
}
|
|
7
|
+
function recommendedRules() {
|
|
8
|
+
const configs = [...tseslint.configs.recommended];
|
|
9
|
+
const config = findConfigByName(configs, 'typescript-eslint/recommended');
|
|
10
|
+
// https://github.com/typescript-eslint/typescript-eslint/blob/v8.32.1/packages/eslint-plugin/src/configs/flat/recommended.ts#L25
|
|
11
|
+
const rules = config?.rules || {};
|
|
12
|
+
// @keep-sorted
|
|
13
|
+
return {
|
|
14
|
+
...rules,
|
|
15
|
+
// `type T1 = T0` and `interface T2 extends T0 {}` have the same meaning
|
|
16
|
+
// but different behavior in TypeScript type checking. `T1` and `T0` are
|
|
17
|
+
// the same type, while `T2` is different than `T0`. We allow `interface
|
|
18
|
+
// T2 extends T0 {}` explicitly.
|
|
19
|
+
'@typescript-eslint/no-empty-object-type': [
|
|
20
|
+
'error',
|
|
21
|
+
{
|
|
22
|
+
allowInterfaces: 'with-single-extends',
|
|
21
23
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
],
|
|
25
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
26
|
+
'@typescript-eslint/no-unused-vars': [
|
|
27
|
+
'error',
|
|
28
|
+
{
|
|
29
|
+
argsIgnorePattern: '^_',
|
|
30
|
+
varsIgnorePattern: '^_',
|
|
31
|
+
caughtErrorsIgnorePattern: '^_',
|
|
24
32
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
//
|
|
84
|
-
|
|
33
|
+
],
|
|
34
|
+
'@typescript-eslint/triple-slash-reference': 'off',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function recommendedTypeCheckedOnlyRules() {
|
|
38
|
+
const configs = [...tseslint.configs.recommendedTypeCheckedOnly];
|
|
39
|
+
const config = findConfigByName(configs, 'typescript-eslint/recommended-type-checked-only');
|
|
40
|
+
// https://github.com/typescript-eslint/typescript-eslint/blob/v8.32.1/packages/eslint-plugin/src/configs/flat/recommended-type-checked-only.ts#L25
|
|
41
|
+
const rules = config?.rules || {};
|
|
42
|
+
// @keep-sorted
|
|
43
|
+
return {
|
|
44
|
+
...rules,
|
|
45
|
+
'@typescript-eslint/no-floating-promises': 'warn',
|
|
46
|
+
'@typescript-eslint/no-misused-promises': [
|
|
47
|
+
'error',
|
|
48
|
+
{ checksVoidReturn: false },
|
|
49
|
+
],
|
|
50
|
+
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
|
|
51
|
+
'@typescript-eslint/no-unsafe-argument': 'warn',
|
|
52
|
+
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
|
53
|
+
'@typescript-eslint/no-unsafe-call': 'warn',
|
|
54
|
+
'@typescript-eslint/no-unsafe-member-access': 'warn',
|
|
55
|
+
'@typescript-eslint/no-unsafe-return': 'warn',
|
|
56
|
+
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function stylisticRules() {
|
|
60
|
+
const configs = [...tseslint.configs.stylistic];
|
|
61
|
+
const config = findConfigByName(configs, 'typescript-eslint/stylistic');
|
|
62
|
+
// https://github.com/typescript-eslint/typescript-eslint/blob/v8.32.1/packages/eslint-plugin/src/configs/flat/stylistic.ts#L25
|
|
63
|
+
const rules = config?.rules || {};
|
|
64
|
+
// @keep-sorted
|
|
65
|
+
return {
|
|
66
|
+
...rules,
|
|
67
|
+
'@typescript-eslint/array-type': 'off',
|
|
68
|
+
'@typescript-eslint/consistent-indexed-object-style': 'off',
|
|
69
|
+
'@typescript-eslint/consistent-type-definitions': 'off',
|
|
70
|
+
'@typescript-eslint/no-empty-function': 'off',
|
|
71
|
+
// Turn off this rule because it's incompatible with the `--isolatedDeclarations` compiler option.
|
|
72
|
+
'@typescript-eslint/no-inferrable-types': 'off',
|
|
73
|
+
'@typescript-eslint/prefer-for-of': 'off',
|
|
74
|
+
'@typescript-eslint/prefer-function-type': 'warn',
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function commonRules() {
|
|
78
|
+
return {
|
|
79
|
+
...eslintRecommendedRules,
|
|
80
|
+
...recommendedRules(),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function tsOnlyRules() {
|
|
84
|
+
// @keep-sorted
|
|
85
|
+
return {
|
|
86
|
+
...recommendedTypeCheckedOnlyRules(),
|
|
87
|
+
...stylisticRules(),
|
|
88
|
+
'@typescript-eslint/consistent-type-imports': [
|
|
89
|
+
'warn',
|
|
90
|
+
{
|
|
91
|
+
// Allow type imports in type annotations (e.g. `type T = import('Foo').Foo`)
|
|
92
|
+
disallowTypeAnnotations: false,
|
|
85
93
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
],
|
|
95
|
+
'@typescript-eslint/no-import-type-side-effects': 'warn',
|
|
96
|
+
'@typescript-eslint/no-mixed-enums': 'error',
|
|
97
|
+
'@typescript-eslint/no-unnecessary-parameter-property-assignment': 'warn',
|
|
98
|
+
'@typescript-eslint/return-await': ['error', 'always'],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function jsOnlyRules() {
|
|
102
|
+
// @keep-sorted
|
|
103
|
+
return {
|
|
104
|
+
'@typescript-eslint/no-require-imports': 'off',
|
|
105
|
+
'@typescript-eslint/no-var-requires': 'off',
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export function typescript() {
|
|
109
|
+
const base = {
|
|
110
|
+
name: 'ocavue/typescript/base',
|
|
111
|
+
files: [GLOB_TS, GLOB_TSX, GLOB_JS, GLOB_JSX],
|
|
112
|
+
languageOptions: {
|
|
113
|
+
parser: tseslint.parser,
|
|
114
|
+
parserOptions: {
|
|
115
|
+
projectService: true,
|
|
116
|
+
warnOnUnsupportedTypeScriptVersion: false,
|
|
117
|
+
sourceType: 'module',
|
|
93
118
|
},
|
|
94
119
|
},
|
|
95
|
-
{
|
|
96
|
-
|
|
97
|
-
files: [GLOB_TEST],
|
|
98
|
-
rules: {
|
|
99
|
-
'@typescript-eslint/no-unsafe-call': 'warn',
|
|
100
|
-
'@typescript-eslint/no-unsafe-return': 'warn',
|
|
101
|
-
'@typescript-eslint/no-unsafe-argument': 'warn',
|
|
102
|
-
'@typescript-eslint/no-unsafe-member-access': 'warn',
|
|
103
|
-
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
|
104
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
105
|
-
'@typescript-eslint/no-empty-function': 'off',
|
|
106
|
-
},
|
|
120
|
+
plugins: {
|
|
121
|
+
'@typescript-eslint': tseslint.plugin,
|
|
107
122
|
},
|
|
108
|
-
|
|
123
|
+
};
|
|
124
|
+
const common = {
|
|
125
|
+
name: 'ocavue/typescript/rules',
|
|
126
|
+
files: [GLOB_TS, GLOB_TSX, GLOB_JS, GLOB_JSX],
|
|
127
|
+
rules: commonRules(),
|
|
128
|
+
};
|
|
129
|
+
const ts = {
|
|
130
|
+
name: 'ocavue/typescript/ts-only-rules',
|
|
131
|
+
files: [GLOB_TS, GLOB_TSX],
|
|
132
|
+
rules: tsOnlyRules(),
|
|
133
|
+
};
|
|
134
|
+
const js = {
|
|
135
|
+
name: 'ocavue/typescript/js-only-rules',
|
|
136
|
+
files: [GLOB_JS, GLOB_JSX],
|
|
137
|
+
rules: jsOnlyRules(),
|
|
138
|
+
};
|
|
109
139
|
// @ts-expect-error: unmatched type
|
|
110
|
-
const
|
|
111
|
-
return
|
|
140
|
+
const configs = [base, common, ts, js];
|
|
141
|
+
return configs;
|
|
112
142
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocavue/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "ocavue <ocavue@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@eslint/js": "^9.
|
|
31
|
+
"@eslint/js": "^9.27.0",
|
|
32
32
|
"@eslint/markdown": "^6.4.0",
|
|
33
33
|
"@unocss/eslint-config": "^66.1.2",
|
|
34
34
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@ocavue/tsconfig": "^0.3.7",
|
|
52
52
|
"@types/node": "^20.17.9",
|
|
53
53
|
"@typescript-eslint/utils": "^8.32.1",
|
|
54
|
-
"eslint": "^9.
|
|
54
|
+
"eslint": "^9.27.0",
|
|
55
55
|
"jiti": "^2.4.2",
|
|
56
56
|
"pkg-pr-new": "^0.0.50",
|
|
57
57
|
"prettier": "^3.5.3",
|
package/dist/basic.d.ts
DELETED
package/dist/basic.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { antfu } from './antfu.js';
|
|
2
|
-
import { ignores } from './ignores.js';
|
|
3
|
-
import { imports } from './imports.js';
|
|
4
|
-
import { noOnlyTests } from './no-only-tests.js';
|
|
5
|
-
import { packageJson } from './package-json.js';
|
|
6
|
-
import { prettier } from './prettier.js';
|
|
7
|
-
import { typescript } from './typescript.js';
|
|
8
|
-
import { unicorn } from './unicorn.js';
|
|
9
|
-
import { gitignore } from './gitignore.js';
|
|
10
|
-
export function basic() {
|
|
11
|
-
return [
|
|
12
|
-
...ignores(),
|
|
13
|
-
...gitignore(),
|
|
14
|
-
...typescript(),
|
|
15
|
-
...imports(),
|
|
16
|
-
...packageJson(),
|
|
17
|
-
...unicorn(),
|
|
18
|
-
...antfu(),
|
|
19
|
-
...noOnlyTests(),
|
|
20
|
-
...prettier(),
|
|
21
|
-
];
|
|
22
|
-
}
|