@shayanthenerd/eslint-config 0.26.7 → 0.27.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/configs/base.mjs +1 -0
- package/dist/configs/baseline.mjs +1 -0
- package/dist/configs/importX.mjs +1 -0
- package/dist/configs/next.mjs +1 -1
- package/dist/configs/node.mjs +1 -0
- package/dist/configs/perfectionist.mjs +1 -0
- package/dist/configs/promise.mjs +1 -0
- package/dist/configs/react.mjs +1 -1
- package/dist/configs/stylistic.mjs +1 -0
- package/dist/configs/tailwind.mjs +1 -0
- package/dist/configs/typescript.mjs +1 -0
- package/dist/configs/unicorn.mjs +1 -0
- package/dist/configs/vueMiddlewares.mjs +14 -0
- package/dist/configs/zod.mjs +1 -0
- package/dist/helpers/globs.mjs +6 -3
- package/dist/helpers/options/mergeWithDefaults.mjs +2 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -0
- package/dist/rules/perfectionist.mjs +104 -42
- package/dist/types/eslint-schema.d.mts +441 -335
- package/dist/types/options/zod.d.mts +2 -2
- package/package.json +8 -11
package/dist/configs/base.mjs
CHANGED
package/dist/configs/importX.mjs
CHANGED
package/dist/configs/next.mjs
CHANGED
|
@@ -10,7 +10,7 @@ function getNextConfig(options) {
|
|
|
10
10
|
const { overrides } = isEnabled(next) ? next : defaultOptions.configs.next;
|
|
11
11
|
return mergeConfigs({
|
|
12
12
|
name: "shayanthenerd/next",
|
|
13
|
-
files: [globs.src],
|
|
13
|
+
files: [globs.src, globs.jsxLike],
|
|
14
14
|
plugins: { next: eslintPluginNext },
|
|
15
15
|
settings: { next: { rootDir: packageDir } },
|
|
16
16
|
rules: getNextRules()
|
package/dist/configs/node.mjs
CHANGED
package/dist/configs/promise.mjs
CHANGED
package/dist/configs/react.mjs
CHANGED
|
@@ -13,7 +13,7 @@ function getReactConfig(options) {
|
|
|
13
13
|
const { overrides, accessibility } = isEnabled(react) ? react : defaultOptions.configs.react;
|
|
14
14
|
return mergeConfigs({
|
|
15
15
|
name: "shayanthenerd/react",
|
|
16
|
-
files: [globs.src],
|
|
16
|
+
files: [globs.src, globs.jsxLike],
|
|
17
17
|
plugins: {
|
|
18
18
|
"@eslint-react": eslintPluginReact,
|
|
19
19
|
"@html-eslint/react": eslintPluginHtmlReact,
|
package/dist/configs/unicorn.mjs
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { globs } from "../helpers/globs.mjs";
|
|
2
|
+
//#region src/configs/vueMiddlewares.ts
|
|
3
|
+
function getVueMiddlewaresConfig() {
|
|
4
|
+
return {
|
|
5
|
+
name: "shayanthenerd/vue/middlewares",
|
|
6
|
+
files: [globs.vueMiddlewares],
|
|
7
|
+
rules: {
|
|
8
|
+
"consistent-return": "off",
|
|
9
|
+
"@typescript-eslint/consistent-return": "off"
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { getVueMiddlewaresConfig };
|
package/dist/configs/zod.mjs
CHANGED
package/dist/helpers/globs.mjs
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
//#region src/helpers/globs.ts
|
|
2
|
-
const srcExtensions = "?([mc])[jt]s
|
|
3
|
-
const
|
|
2
|
+
const srcExtensions = "?([mc])[jt]s";
|
|
3
|
+
const jsxLikeExtensions = "[jt]sx";
|
|
4
|
+
const vueExtensions = `{vue,${srcExtensions},${jsxLikeExtensions}}`;
|
|
4
5
|
const globs = {
|
|
5
6
|
src: `**/*.${srcExtensions}`,
|
|
7
|
+
jsxLike: `**/*.${jsxLikeExtensions}`,
|
|
6
8
|
packageJson: "**/package.json",
|
|
7
9
|
markdown: "**/*.md",
|
|
8
10
|
html: "**/*.html",
|
|
9
11
|
css: "**/*.css",
|
|
10
12
|
astro: "**/*.astro",
|
|
11
13
|
vue: `**/*.${vueExtensions}`,
|
|
14
|
+
vueMiddlewares: `**/middleware?(s)/**/*.${srcExtensions}`,
|
|
12
15
|
vueServerComponents: `**/*.server.${vueExtensions}`,
|
|
13
16
|
vueAppErrorLayoutsPages: `**/{{app,error},{layouts,pages}/**/*}.${vueExtensions}`,
|
|
14
|
-
storybook: `**/*.(story|stories)
|
|
17
|
+
storybook: `**/*.(story|stories).{${srcExtensions},${jsxLikeExtensions}}`,
|
|
15
18
|
test: `**/{__tests__/*,*.{test,spec,cy,bench?(mark)}.${srcExtensions}`,
|
|
16
19
|
coverage: "**/coverage/**"
|
|
17
20
|
};
|
|
@@ -18,7 +18,8 @@ const mergeOptions = createDefu((object, key, value) => {
|
|
|
18
18
|
return isEmptyString(value) || isValueTrue && !isDefaultValueFalse;
|
|
19
19
|
});
|
|
20
20
|
function mergeWithDefaults(options) {
|
|
21
|
-
|
|
21
|
+
const optionsWithDetectedConfigs = enableDetectedConfigs(options);
|
|
22
|
+
return mergeOptions(optionsWithDetectedConfigs, defaultOptions);
|
|
22
23
|
}
|
|
23
24
|
//#endregion
|
|
24
25
|
export { mergeWithDefaults };
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { Options } from "./types/index.mjs";
|
|
|
2
2
|
import { Linter } from "eslint";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
|
-
/** Valid argument combinations for
|
|
5
|
+
/** Valid argument combinations for `defineConfig`. */
|
|
6
6
|
type DefineConfigArguments = [] | [options: Options] | [configs: Linter.Config[]] | [options: Options, configs: Linter.Config[]];
|
|
7
7
|
/**
|
|
8
8
|
* Define your ESLint configuration based on the provided options and/or custom Flat Config Objects.
|
package/dist/index.mjs
CHANGED
|
@@ -23,6 +23,7 @@ import { getPlaywrightConfig } from "./configs/playwright.mjs";
|
|
|
23
23
|
import { getTypeScriptConfig } from "./configs/typescript.mjs";
|
|
24
24
|
import { getPackageJsonConfig } from "./configs/packageJson.mjs";
|
|
25
25
|
import { getPerfectionistConfig } from "./configs/perfectionist.mjs";
|
|
26
|
+
import { getVueMiddlewaresConfig } from "./configs/vueMiddlewares.mjs";
|
|
26
27
|
import { getIgnorePatterns } from "./helpers/ignores/getIgnorePatterns.mjs";
|
|
27
28
|
import { mergeWithDefaults } from "./helpers/options/mergeWithDefaults.mjs";
|
|
28
29
|
import { getVueComponentNamesConfig } from "./configs/vueComponentNames.mjs";
|
|
@@ -105,6 +106,7 @@ function defineConfig(...args) {
|
|
|
105
106
|
isEnabled(react) && getReactConfig(mergedOptions),
|
|
106
107
|
isEnabled(next) && getNextConfig(mergedOptions),
|
|
107
108
|
isEnabled(vue) && getVueConfig(mergedOptions),
|
|
109
|
+
isEnabled(vue) && getVueMiddlewaresConfig(),
|
|
108
110
|
isEnabled(vue) && getVueComponentNamesConfig(),
|
|
109
111
|
isEnabled(vue) && isEnabled(nuxt) && getVueServerComponentsConfig(),
|
|
110
112
|
isEnabled(storybook) && getStorybookConfig(mergedOptions),
|
|
@@ -1,6 +1,105 @@
|
|
|
1
1
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
2
2
|
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
3
3
|
//#region src/rules/perfectionist.ts
|
|
4
|
+
const literalCustomGroups = [
|
|
5
|
+
{
|
|
6
|
+
groupName: "template-literal",
|
|
7
|
+
selector: "literal",
|
|
8
|
+
elementNamePattern: "^`.*`$"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
groupName: "bigint-literal",
|
|
12
|
+
selector: "literal",
|
|
13
|
+
elementNamePattern: "^-?\\d[\\d_]*n$"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
groupName: "string-literal",
|
|
17
|
+
selector: "literal",
|
|
18
|
+
elementNamePattern: "^(?:'.*'|\".*\")$"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
groupName: "boolean-literal",
|
|
22
|
+
selector: "literal",
|
|
23
|
+
elementNamePattern: "^(?:true|false)$"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
groupName: "number-literal",
|
|
27
|
+
selector: "literal",
|
|
28
|
+
elementNamePattern: "^-?(?:\\d[\\d_]*(?:\\.\\d[\\d_]*)?|\\.\\d[\\d_]*)(?:[eE][+-]?\\d[\\d_]*)?$"
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
const booleanKeywordCustomGroup = {
|
|
32
|
+
groupName: "boolean-keyword",
|
|
33
|
+
selector: "keyword",
|
|
34
|
+
elementNamePattern: "^boolean$"
|
|
35
|
+
};
|
|
36
|
+
const sharedTypeLikeGroups = [
|
|
37
|
+
"boolean-literal",
|
|
38
|
+
"number-literal",
|
|
39
|
+
"bigint-literal",
|
|
40
|
+
"string-literal",
|
|
41
|
+
"template-literal",
|
|
42
|
+
"literal",
|
|
43
|
+
"keyword",
|
|
44
|
+
"named",
|
|
45
|
+
"operator",
|
|
46
|
+
"tuple",
|
|
47
|
+
"object",
|
|
48
|
+
"union",
|
|
49
|
+
"intersection",
|
|
50
|
+
"conditional",
|
|
51
|
+
"function",
|
|
52
|
+
"import",
|
|
53
|
+
"unknown",
|
|
54
|
+
"nullish"
|
|
55
|
+
];
|
|
56
|
+
const typeConstituentSortOptions = {
|
|
57
|
+
customGroups: [booleanKeywordCustomGroup, ...literalCustomGroups],
|
|
58
|
+
groups: ["boolean-keyword", ...sharedTypeLikeGroups]
|
|
59
|
+
};
|
|
60
|
+
const sortArrayIncludesOptions = {
|
|
61
|
+
customGroups: literalCustomGroups,
|
|
62
|
+
groups: sharedTypeLikeGroups
|
|
63
|
+
};
|
|
64
|
+
const sortImportsCustomGroups = [{
|
|
65
|
+
groupName: "component",
|
|
66
|
+
elementNamePattern: ["\\.(vue|[jt]sx)$"],
|
|
67
|
+
modifiers: ["value"]
|
|
68
|
+
}, {
|
|
69
|
+
groupName: "image",
|
|
70
|
+
elementNamePattern: ["\\.(ico|svg|gif|png|jpe?g|webp|avif|heic)$"]
|
|
71
|
+
}];
|
|
72
|
+
const sortImportsGroups = [
|
|
73
|
+
["style", "side-effect-style"],
|
|
74
|
+
{ newlinesBetween: 0 },
|
|
75
|
+
"side-effect",
|
|
76
|
+
"image",
|
|
77
|
+
"component",
|
|
78
|
+
"type-external",
|
|
79
|
+
{ newlinesBetween: 0 },
|
|
80
|
+
"type-builtin",
|
|
81
|
+
{ newlinesBetween: 0 },
|
|
82
|
+
["type-tsconfig-path", "type-subpath"],
|
|
83
|
+
{ newlinesBetween: 0 },
|
|
84
|
+
[
|
|
85
|
+
"type-internal",
|
|
86
|
+
"type-index",
|
|
87
|
+
"type-parent",
|
|
88
|
+
"type-sibling"
|
|
89
|
+
],
|
|
90
|
+
"external",
|
|
91
|
+
{ newlinesBetween: 0 },
|
|
92
|
+
"builtin",
|
|
93
|
+
["tsconfig-path", "subpath"],
|
|
94
|
+
{ newlinesBetween: 0 },
|
|
95
|
+
[
|
|
96
|
+
"internal",
|
|
97
|
+
"index",
|
|
98
|
+
"parent",
|
|
99
|
+
"sibling"
|
|
100
|
+
],
|
|
101
|
+
["import", "unknown"]
|
|
102
|
+
];
|
|
4
103
|
function getPerfectionistRules(options) {
|
|
5
104
|
const { env, tsConfig, configs: { stylistic, perfectionist } } = options;
|
|
6
105
|
const { maxLineLength } = isEnabled(stylistic) ? stylistic : defaultOptions.configs.stylistic;
|
|
@@ -8,9 +107,9 @@ function getPerfectionistRules(options) {
|
|
|
8
107
|
return {
|
|
9
108
|
"perfectionist/sort-maps": "warn",
|
|
10
109
|
"perfectionist/sort-exports": "warn",
|
|
11
|
-
"perfectionist/sort-union-types": "warn",
|
|
12
|
-
"perfectionist/sort-array-includes": "warn",
|
|
13
|
-
"perfectionist/sort-intersection-types": "warn",
|
|
110
|
+
"perfectionist/sort-union-types": ["warn", typeConstituentSortOptions],
|
|
111
|
+
"perfectionist/sort-array-includes": ["warn", sortArrayIncludesOptions],
|
|
112
|
+
"perfectionist/sort-intersection-types": ["warn", typeConstituentSortOptions],
|
|
14
113
|
"perfectionist/sort-named-imports": "warn",
|
|
15
114
|
"perfectionist/sort-named-exports": "warn",
|
|
16
115
|
"perfectionist/sort-imports": ["warn", {
|
|
@@ -25,45 +124,8 @@ function getPerfectionistRules(options) {
|
|
|
25
124
|
specialCharacters: "trim",
|
|
26
125
|
type: sortType,
|
|
27
126
|
maxLineLength,
|
|
28
|
-
customGroups:
|
|
29
|
-
|
|
30
|
-
elementNamePattern: ["\\.(vue|[jt]sx)$"],
|
|
31
|
-
modifiers: ["value"]
|
|
32
|
-
}, {
|
|
33
|
-
groupName: "image",
|
|
34
|
-
elementNamePattern: ["\\.(ico|svg|gif|png|jpe?g|webp|avif|heic)$"]
|
|
35
|
-
}],
|
|
36
|
-
groups: [
|
|
37
|
-
["style", "side-effect-style"],
|
|
38
|
-
{ newlinesBetween: 0 },
|
|
39
|
-
"side-effect",
|
|
40
|
-
"image",
|
|
41
|
-
"vue-sfc",
|
|
42
|
-
"type-external",
|
|
43
|
-
{ newlinesBetween: 0 },
|
|
44
|
-
"type-builtin",
|
|
45
|
-
{ newlinesBetween: 0 },
|
|
46
|
-
["type-tsconfig-path", "type-subpath"],
|
|
47
|
-
{ newlinesBetween: 0 },
|
|
48
|
-
[
|
|
49
|
-
"type-internal",
|
|
50
|
-
"type-index",
|
|
51
|
-
"type-parent",
|
|
52
|
-
"type-sibling"
|
|
53
|
-
],
|
|
54
|
-
"external",
|
|
55
|
-
{ newlinesBetween: 0 },
|
|
56
|
-
"builtin",
|
|
57
|
-
["tsconfig-path", "subpath"],
|
|
58
|
-
{ newlinesBetween: 0 },
|
|
59
|
-
[
|
|
60
|
-
"internal",
|
|
61
|
-
"index",
|
|
62
|
-
"parent",
|
|
63
|
-
"sibling"
|
|
64
|
-
],
|
|
65
|
-
["import", "unknown"]
|
|
66
|
-
]
|
|
127
|
+
customGroups: sortImportsCustomGroups,
|
|
128
|
+
groups: sortImportsGroups
|
|
67
129
|
}]
|
|
68
130
|
};
|
|
69
131
|
}
|