@ocavue/eslint-config 2.17.0 → 2.19.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/README.md +32 -22
- package/dist/ignores.js +4 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +26 -2
- package/dist/options.d.ts +44 -0
- package/dist/options.js +14 -0
- package/dist/react.d.ts +3 -2
- package/dist/react.js +6 -5
- package/dist/types.d.ts +2 -0
- package/dist/types.js +1 -0
- package/dist/vue.d.ts +2 -1
- package/dist/vue.js +4 -3
- package/package.json +7 -8
package/README.md
CHANGED
|
@@ -23,36 +23,45 @@ In your `eslint.config.js` file, add the following to extend the basic config:
|
|
|
23
23
|
|
|
24
24
|
```js
|
|
25
25
|
// eslint.config.js
|
|
26
|
-
import {
|
|
26
|
+
import { defineESLintConfig } from '@ocavue/eslint-config'
|
|
27
27
|
|
|
28
|
-
export default
|
|
28
|
+
export default defineESLintConfig()
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
You can pass an optional object to the `defineESLintConfig` function to enable or disable the configs. For example, if you want to enable the React config, you can do the following:
|
|
32
32
|
|
|
33
33
|
```js
|
|
34
34
|
// eslint.config.js
|
|
35
|
-
import {
|
|
35
|
+
import { defineESLintConfig } from '@ocavue/eslint-config'
|
|
36
36
|
|
|
37
|
-
export default
|
|
37
|
+
export default defineESLintConfig({ react: true })
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
The full type definition for the options is as follows:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
export interface ESLintConfigOptions {
|
|
44
|
+
/**
|
|
45
|
+
* Whether to check code blocks in Markdown files.
|
|
46
|
+
*
|
|
47
|
+
* @default true
|
|
48
|
+
*/
|
|
49
|
+
markdown?: boolean
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether to enable React configuration.
|
|
53
|
+
*
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
react?: boolean | ReactOptions
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Whether to enable Vue configuration.
|
|
60
|
+
*
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
vue?: boolean
|
|
64
|
+
}
|
|
56
65
|
```
|
|
57
66
|
|
|
58
67
|
### Add script for package.json
|
|
@@ -86,7 +95,8 @@ If you are using VS Code, you and install [ESLint extension](https://marketplace
|
|
|
86
95
|
}
|
|
87
96
|
```
|
|
88
97
|
|
|
89
|
-
##
|
|
98
|
+
## Alternative solutions
|
|
90
99
|
|
|
91
100
|
- https://github.com/antfu/eslint-config
|
|
92
101
|
- https://github.com/sxzz/eslint-config
|
|
102
|
+
- https://github.com/ntnyq/eslint-config
|
package/dist/ignores.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import gitignore from 'eslint-config-flat-gitignore';
|
|
2
2
|
import { GLOB_EXCLUDE } from './shared.js';
|
|
3
3
|
export function ignores() {
|
|
4
|
-
return [
|
|
4
|
+
return [
|
|
5
|
+
{ ignores: [...GLOB_EXCLUDE], name: 'basic-global-ignores' },
|
|
6
|
+
gitignore(),
|
|
7
|
+
];
|
|
5
8
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { type ESLintConfigOptions } from './options.js';
|
|
2
|
+
import type { Config } from './types.js';
|
|
3
3
|
export * from './basic.js';
|
|
4
4
|
export * from './markdown.js';
|
|
5
|
+
export * from './prettier.js';
|
|
5
6
|
export * from './react.js';
|
|
7
|
+
export * from './typescript.js';
|
|
6
8
|
export * from './vue.js';
|
|
9
|
+
export type { Config, ESLintConfigOptions };
|
|
10
|
+
export declare function defineESLintConfig(options?: ESLintConfigOptions): Config[];
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import { basic } from './basic.js';
|
|
3
|
+
import { markdown } from './markdown.js';
|
|
4
|
+
import { resolveOptions } from './options.js';
|
|
5
|
+
import { react } from './react.js';
|
|
6
|
+
import { vue } from './vue.js';
|
|
3
7
|
export * from './basic.js';
|
|
4
8
|
export * from './markdown.js';
|
|
9
|
+
export * from './prettier.js';
|
|
5
10
|
export * from './react.js';
|
|
11
|
+
export * from './typescript.js';
|
|
6
12
|
export * from './vue.js';
|
|
13
|
+
export function defineESLintConfig(options) {
|
|
14
|
+
const resolvedOptions = resolveOptions(options);
|
|
15
|
+
const configs = [];
|
|
16
|
+
configs.push(...basic());
|
|
17
|
+
if (resolvedOptions.markdown) {
|
|
18
|
+
configs.push(...markdown());
|
|
19
|
+
}
|
|
20
|
+
if (resolvedOptions.react) {
|
|
21
|
+
configs.push(...react(trueToUndefined(resolvedOptions.react)));
|
|
22
|
+
}
|
|
23
|
+
if (resolvedOptions.vue) {
|
|
24
|
+
configs.push(...vue(trueToUndefined(resolvedOptions.vue)));
|
|
25
|
+
}
|
|
26
|
+
return defineConfig(configs);
|
|
27
|
+
}
|
|
28
|
+
function trueToUndefined(value) {
|
|
29
|
+
return value === true ? undefined : value;
|
|
30
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Config } from './types.js';
|
|
2
|
+
export interface ESLintConfigOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Whether to check code blocks in Markdown files.
|
|
5
|
+
*
|
|
6
|
+
* @default true
|
|
7
|
+
*/
|
|
8
|
+
markdown?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether to enable React configuration.
|
|
11
|
+
*
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
react?: boolean | ReactOptions;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to enable Vue configuration.
|
|
17
|
+
*
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
vue?: boolean | VueOptions;
|
|
21
|
+
}
|
|
22
|
+
export declare function resolveOptions({ markdown, react, vue, }?: ESLintConfigOptions): Required<ESLintConfigOptions>;
|
|
23
|
+
export interface ReactOptions {
|
|
24
|
+
/**
|
|
25
|
+
* The default files to lint.
|
|
26
|
+
*
|
|
27
|
+
* @default: All typescript files
|
|
28
|
+
*
|
|
29
|
+
* @see {@link Config.files}
|
|
30
|
+
*/
|
|
31
|
+
files?: Config['files'];
|
|
32
|
+
}
|
|
33
|
+
export declare function resolveReactOptions({ files, }?: ReactOptions): Required<ReactOptions>;
|
|
34
|
+
export interface VueOptions {
|
|
35
|
+
/**
|
|
36
|
+
* The default files to lint.
|
|
37
|
+
*
|
|
38
|
+
* @default: All .vue files
|
|
39
|
+
*
|
|
40
|
+
* @see {@link Config.files}
|
|
41
|
+
*/
|
|
42
|
+
files?: Config['files'];
|
|
43
|
+
}
|
|
44
|
+
export declare function resolveVueOptions({ files, }?: VueOptions): Required<VueOptions>;
|
package/dist/options.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GLOB_TS, GLOB_TSX, GLOB_VUE } from './shared.js';
|
|
2
|
+
export function resolveOptions({ markdown = true, react = false, vue = false, } = {}) {
|
|
3
|
+
return {
|
|
4
|
+
markdown,
|
|
5
|
+
react,
|
|
6
|
+
vue,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export function resolveReactOptions({ files = [GLOB_TS, GLOB_TSX], } = {}) {
|
|
10
|
+
return { files };
|
|
11
|
+
}
|
|
12
|
+
export function resolveVueOptions({ files = [GLOB_VUE], } = {}) {
|
|
13
|
+
return { files };
|
|
14
|
+
}
|
package/dist/react.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
1
|
+
import { type ReactOptions } from './options.js';
|
|
2
|
+
import type { Config } from './types.js';
|
|
3
|
+
export declare function react(options?: ReactOptions): Config[];
|
package/dist/react.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import reactPlugin from 'eslint-plugin-react';
|
|
2
2
|
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
3
|
-
import {
|
|
4
|
-
export function react() {
|
|
5
|
-
const
|
|
3
|
+
import { resolveReactOptions } from './options.js';
|
|
4
|
+
export function react(options) {
|
|
5
|
+
const { files } = resolveReactOptions(options);
|
|
6
|
+
const reactRecommended = reactPlugin.configs.flat.recommended;
|
|
6
7
|
return [
|
|
7
8
|
{
|
|
8
9
|
...reactRecommended,
|
|
9
10
|
name: 'react',
|
|
10
|
-
files:
|
|
11
|
+
files: files,
|
|
11
12
|
settings: {
|
|
12
13
|
react: {
|
|
13
14
|
version: 'detect',
|
|
@@ -21,7 +22,7 @@ export function react() {
|
|
|
21
22
|
},
|
|
22
23
|
{
|
|
23
24
|
name: 'react-hooks',
|
|
24
|
-
files:
|
|
25
|
+
files: files,
|
|
25
26
|
plugins: {
|
|
26
27
|
'react-hooks': reactHooksPlugin,
|
|
27
28
|
},
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/vue.d.ts
CHANGED
package/dist/vue.js
CHANGED
|
@@ -2,13 +2,14 @@ import prettierConfig from 'eslint-config-prettier';
|
|
|
2
2
|
import vuePlugin from 'eslint-plugin-vue';
|
|
3
3
|
import globals from 'globals';
|
|
4
4
|
import tseslint from 'typescript-eslint';
|
|
5
|
-
import {
|
|
6
|
-
export function vue() {
|
|
5
|
+
import { resolveVueOptions } from './options.js';
|
|
6
|
+
export function vue(options) {
|
|
7
|
+
const { files } = resolveVueOptions(options);
|
|
7
8
|
return [
|
|
8
9
|
...vuePlugin.configs['flat/recommended'],
|
|
9
10
|
{
|
|
10
11
|
name: 'vue:language-options',
|
|
11
|
-
files:
|
|
12
|
+
files: files,
|
|
12
13
|
languageOptions: {
|
|
13
14
|
ecmaVersion: 'latest',
|
|
14
15
|
sourceType: 'module',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocavue/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.19.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "ocavue <ocavue@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"@eslint/js": "^9.26.0",
|
|
32
32
|
"@eslint/markdown": "^6.4.0",
|
|
33
33
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
34
|
-
"eslint-config-prettier": "^10.1.
|
|
35
|
-
"eslint-import-resolver-typescript": "^4.3.
|
|
34
|
+
"eslint-config-prettier": "^10.1.5",
|
|
35
|
+
"eslint-import-resolver-typescript": "^4.3.5",
|
|
36
36
|
"eslint-plugin-antfu": "^3.1.1",
|
|
37
|
-
"eslint-plugin-import-x": "^4.
|
|
37
|
+
"eslint-plugin-import-x": "^4.12.2",
|
|
38
38
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
39
39
|
"eslint-plugin-package-json": "^0.31.0",
|
|
40
40
|
"eslint-plugin-react": "^7.37.5",
|
|
@@ -42,17 +42,16 @@
|
|
|
42
42
|
"eslint-plugin-unicorn": "^59.0.1",
|
|
43
43
|
"eslint-plugin-vue": "^10.1.0",
|
|
44
44
|
"globals": "^16.1.0",
|
|
45
|
-
"typescript-eslint": "^8.32.
|
|
45
|
+
"typescript-eslint": "^8.32.1",
|
|
46
46
|
"vue-eslint-parser": "^10.1.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@ocavue/tsconfig": "^0.3.7",
|
|
50
|
-
"@types/eslint-config-prettier": "^6.11.3",
|
|
51
50
|
"@types/node": "^20.17.9",
|
|
52
|
-
"@typescript-eslint/utils": "^8.32.
|
|
51
|
+
"@typescript-eslint/utils": "^8.32.1",
|
|
53
52
|
"eslint": "^9.26.0",
|
|
54
53
|
"jiti": "^2.4.2",
|
|
55
|
-
"pkg-pr-new": "^0.0.
|
|
54
|
+
"pkg-pr-new": "^0.0.50",
|
|
56
55
|
"prettier": "^3.5.3",
|
|
57
56
|
"typescript": "^5.8.3"
|
|
58
57
|
},
|