@shayanthenerd/eslint-config 0.11.1 → 0.12.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 +43 -0
- package/dist/configs/{css.js → css.mjs} +6 -6
- package/dist/configs/{cypress.js → cypress.mjs} +6 -5
- package/dist/configs/{html.js → html.mjs} +7 -5
- package/dist/configs/importX.mjs +26 -0
- package/dist/configs/{oxlintOverrides.js → oxlintOverrides.mjs} +14 -14
- package/dist/configs/{perfectionist.js → perfectionist.mjs} +5 -5
- package/dist/configs/{playwright.js → playwright.mjs} +6 -5
- package/dist/configs/{restrictedExports.js → restrictedExports.mjs} +1 -1
- package/dist/configs/{storybook.js → storybook.mjs} +5 -6
- package/dist/configs/{stylistic.js → stylistic.mjs} +7 -7
- package/dist/configs/{tailwind.js → tailwind.mjs} +19 -16
- package/dist/configs/typescript.mjs +34 -0
- package/dist/configs/{vitest.js → vitest.mjs} +5 -5
- package/dist/configs/vue.mjs +45 -0
- package/dist/configs/{vueComponentNames.js → vueComponentNames.mjs} +1 -1
- package/dist/configs/{vueServerComponents.js → vueServerComponents.mjs} +1 -1
- package/dist/{index.d.ts → index.d.mts} +3 -3
- package/dist/index.mjs +75 -0
- package/dist/oxlint.config.jsonc +1 -0
- package/dist/rules/{css.js → css.mjs} +14 -5
- package/dist/rules/cypress.mjs +18 -0
- package/dist/rules/{html.js → html.mjs} +47 -25
- package/dist/rules/{importX.js → importX.mjs} +25 -23
- package/dist/rules/{javascript.js → javascript.mjs} +167 -115
- package/dist/rules/{perfectionist.js → perfectionist.mjs} +2 -2
- package/dist/rules/playwright.mjs +54 -0
- package/dist/rules/storybook.mjs +25 -0
- package/dist/rules/{stylistic.js → stylistic.mjs} +106 -57
- package/dist/rules/{tailwind.js → tailwind.mjs} +15 -14
- package/dist/rules/typescript.mjs +173 -0
- package/dist/rules/{vitest.js → vitest.mjs} +57 -28
- package/dist/rules/vue.mjs +361 -0
- package/dist/rules/{vueAccessibility.js → vueAccessibility.mjs} +23 -9
- package/dist/types/configOptions/{base.d.ts → base.d.mts} +2 -2
- package/dist/types/configOptions/{css.d.ts → css.d.mts} +2 -2
- package/dist/types/configOptions/{html.d.ts → html.d.mts} +2 -2
- package/dist/types/configOptions/{importX.d.ts → importX.d.mts} +1 -1
- package/dist/types/configOptions/{perfectionist.d.ts → perfectionist.d.mts} +2 -2
- package/dist/types/configOptions/{stylistic.d.ts → stylistic.d.mts} +2 -2
- package/dist/types/configOptions/{tailwind.d.ts → tailwind.d.mts} +2 -2
- package/dist/types/configOptions/{test.d.ts → test.d.mts} +2 -2
- package/dist/types/configOptions/{typescript.d.ts → typescript.d.mts} +2 -2
- package/dist/types/configOptions/{vue.d.ts → vue.d.mts} +3 -3
- package/dist/types/configOptions/{vueAccessibility.d.ts → vueAccessibility.d.mts} +1 -1
- package/dist/types/{eslint-schema.d.ts → eslint-schema.d.mts} +24 -33
- package/dist/types/{eslintRules.d.ts → eslintRules.d.mts} +2 -2
- package/dist/types/{index.d.ts → index.d.mts} +12 -12
- package/dist/utils/ignores/{getIgnorePatterns.js → getIgnorePatterns.mjs} +2 -2
- package/dist/utils/{isPackageDetected.js → isPackageDetected.mjs} +1 -1
- package/dist/utils/options/{enableDetectedConfigs.js → enableDetectedConfigs.mjs} +2 -2
- package/dist/utils/options/{mergeWithDefaults.js → mergeWithDefaults.mjs} +3 -3
- package/package.json +30 -31
- package/dist/configs/base.js +0 -44
- package/dist/configs/importX.js +0 -23
- package/dist/configs/typescript.js +0 -31
- package/dist/configs/vue.js +0 -33
- package/dist/index.js +0 -74
- package/dist/rules/cypress.js +0 -14
- package/dist/rules/playwright.js +0 -26
- package/dist/rules/storybook.js +0 -14
- package/dist/rules/typescript.js +0 -63
- package/dist/rules/vue.js +0 -186
- /package/dist/{prettier.config.d.ts → prettier.config.d.mts} +0 -0
- /package/dist/{prettier.config.js → prettier.config.mjs} +0 -0
- /package/dist/types/configOptions/{nuxt.d.ts → nuxt.d.mts} +0 -0
- /package/dist/types/{helpers.d.ts → helpers.d.mts} +0 -0
- /package/dist/utils/{globs.js → globs.mjs} +0 -0
- /package/dist/utils/ignores/{defaultIgnorePatterns.js → defaultIgnorePatterns.mjs} +0 -0
- /package/dist/utils/ignores/{resolveGitignorePatterns.js → resolveGitignorePatterns.mjs} +0 -0
- /package/dist/utils/{isEmptyString.js → isEmptyString.mjs} +0 -0
- /package/dist/utils/{isEnabled.js → isEnabled.mjs} +0 -0
- /package/dist/utils/options/{defaultOptions.js → defaultOptions.mjs} +0 -0
- /package/dist/utils/vue/{getRestrictedVueElements.js → getRestrictedVueElements.mjs} +0 -0
- /package/dist/utils/vue/{getRestrictedVueInputs.js → getRestrictedVueInputs.mjs} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { globs } from "../utils/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { getJavaScriptRules } from "../rules/javascript.mjs";
|
|
4
|
+
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
5
|
+
import { parser } from "typescript-eslint";
|
|
6
|
+
import globals from "globals";
|
|
7
|
+
|
|
8
|
+
//#region src/configs/base.ts
|
|
9
|
+
function getBaseConfig(options) {
|
|
10
|
+
const { configs: { vue, test: { vitest }, base: { overrides } }, global: { globals: { node, worker, browser, commonjs, webextension, serviceworker, custom: userGlobals } } } = options;
|
|
11
|
+
return mergeConfigs({
|
|
12
|
+
name: "shayanthenerd/base",
|
|
13
|
+
files: isEnabled(vue) ? [globs.src, globs.vue] : [globs.src],
|
|
14
|
+
languageOptions: {
|
|
15
|
+
parser,
|
|
16
|
+
parserOptions: {
|
|
17
|
+
ecmaVersion: "latest",
|
|
18
|
+
ecmaFeatures: {
|
|
19
|
+
jsx: true,
|
|
20
|
+
impliedStrict: true
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
globals: {
|
|
24
|
+
...globals.builtin,
|
|
25
|
+
...globals.es2026,
|
|
26
|
+
...commonjs && globals.commonjs,
|
|
27
|
+
...node && globals.node,
|
|
28
|
+
...node && globals.nodeBuiltin,
|
|
29
|
+
...browser && globals.browser,
|
|
30
|
+
...worker && globals.worker,
|
|
31
|
+
...serviceworker && globals.serviceworker,
|
|
32
|
+
...webextension && globals.webextensions,
|
|
33
|
+
...isEnabled(vue) && globals.vue,
|
|
34
|
+
...isEnabled(vitest) && globals.vitest,
|
|
35
|
+
...userGlobals
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
rules: getJavaScriptRules(options)
|
|
39
|
+
}, overrides);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { getBaseConfig };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { globs } from "../utils/globs.
|
|
2
|
-
import { isEnabled } from "../utils/isEnabled.
|
|
3
|
-
import { defaultOptions } from "../utils/options/defaultOptions.
|
|
4
|
-
import { getCSSRules } from "../rules/css.
|
|
5
|
-
import
|
|
1
|
+
import { globs } from "../utils/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../utils/options/defaultOptions.mjs";
|
|
4
|
+
import { getCSSRules } from "../rules/css.mjs";
|
|
5
|
+
import eslintPluginCSS from "@eslint/css";
|
|
6
6
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
7
7
|
import { tailwind3, tailwind4 } from "tailwind-csstree";
|
|
8
8
|
|
|
@@ -14,7 +14,7 @@ function getCSSConfig(options) {
|
|
|
14
14
|
return mergeConfigs({
|
|
15
15
|
name: "shayanthenerd/css",
|
|
16
16
|
files: [globs.css],
|
|
17
|
-
|
|
17
|
+
plugins: { css: eslintPluginCSS },
|
|
18
18
|
language: "css/css",
|
|
19
19
|
languageOptions: {
|
|
20
20
|
tolerant: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { globs } from "../utils/globs.
|
|
2
|
-
import { isEnabled } from "../utils/isEnabled.
|
|
3
|
-
import { defaultOptions } from "../utils/options/defaultOptions.
|
|
4
|
-
import { getCypressRules } from "../rules/cypress.
|
|
1
|
+
import { globs } from "../utils/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../utils/options/defaultOptions.mjs";
|
|
4
|
+
import { getCypressRules } from "../rules/cypress.mjs";
|
|
5
5
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
6
|
import eslintPluginCypress from "eslint-plugin-cypress";
|
|
7
7
|
|
|
@@ -12,7 +12,8 @@ function getCypressConfig(options) {
|
|
|
12
12
|
return mergeConfigs({
|
|
13
13
|
name: "shayanthenerd/cypress",
|
|
14
14
|
files: [globs.test],
|
|
15
|
-
|
|
15
|
+
plugins: { cypress: eslintPluginCypress },
|
|
16
|
+
languageOptions: { globals: eslintPluginCypress.configs.recommended.languageOptions?.globals },
|
|
16
17
|
rules: getCypressRules()
|
|
17
18
|
}, overrides);
|
|
18
19
|
}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { globs } from "../utils/globs.
|
|
2
|
-
import { isEnabled } from "../utils/isEnabled.
|
|
3
|
-
import { defaultOptions } from "../utils/options/defaultOptions.
|
|
4
|
-
import { getHTMLRules } from "../rules/html.
|
|
1
|
+
import { globs } from "../utils/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../utils/options/defaultOptions.mjs";
|
|
4
|
+
import { getHTMLRules } from "../rules/html.mjs";
|
|
5
5
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
6
|
import eslintPluginHTML from "@html-eslint/eslint-plugin";
|
|
7
7
|
|
|
8
8
|
//#region src/configs/html.ts
|
|
9
|
+
const eslintParserHTML = (eslintPluginHTML.configs?.["flat/recommended"])?.languageOptions?.parser;
|
|
9
10
|
function getHTMLConfig(options) {
|
|
10
11
|
const { html } = options.configs;
|
|
11
12
|
const { overrides } = isEnabled(html) ? html : defaultOptions.configs.html;
|
|
12
13
|
return mergeConfigs({
|
|
13
14
|
name: "shayanthenerd/html",
|
|
14
15
|
files: [globs.html],
|
|
15
|
-
|
|
16
|
+
plugins: { "@html-eslint": eslintPluginHTML },
|
|
16
17
|
language: "html/html",
|
|
18
|
+
languageOptions: { parser: eslintParserHTML },
|
|
17
19
|
rules: getHTMLRules(options)
|
|
18
20
|
}, overrides);
|
|
19
21
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { globs } from "../utils/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../utils/options/defaultOptions.mjs";
|
|
4
|
+
import { getImportXRules } from "../rules/importX.mjs";
|
|
5
|
+
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
|
+
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
7
|
+
import eslintPluginUnusedImports from "eslint-plugin-unused-imports";
|
|
8
|
+
|
|
9
|
+
//#region src/configs/importX.ts
|
|
10
|
+
function getImportXConfig(options) {
|
|
11
|
+
const { vue, importX, typescript } = options.configs;
|
|
12
|
+
const { overrides, removeUnusedImports } = isEnabled(importX) ? importX : defaultOptions.configs.importX;
|
|
13
|
+
return mergeConfigs({
|
|
14
|
+
name: "shayanthenerd/imports",
|
|
15
|
+
files: isEnabled(vue) ? [globs.src, globs.vue] : [globs.src],
|
|
16
|
+
plugins: {
|
|
17
|
+
"import-x": eslintPluginImportX,
|
|
18
|
+
...removeUnusedImports && { "unused-imports": eslintPluginUnusedImports }
|
|
19
|
+
},
|
|
20
|
+
settings: isEnabled(typescript) ? eslintPluginImportX.flatConfigs.typescript.settings : void 0,
|
|
21
|
+
rules: getImportXRules(options)
|
|
22
|
+
}, overrides);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { getImportXConfig };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { globs } from "../utils/globs.
|
|
2
|
-
import { isEnabled } from "../utils/isEnabled.
|
|
3
|
-
import { getJavaScriptRules } from "../rules/javascript.
|
|
4
|
-
import { getVitestRules } from "../rules/vitest.
|
|
5
|
-
import { getPlaywrightRules } from "../rules/playwright.
|
|
6
|
-
import { getTypeScriptRules } from "../rules/typescript.
|
|
1
|
+
import { globs } from "../utils/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { getJavaScriptRules } from "../rules/javascript.mjs";
|
|
4
|
+
import { getVitestRules } from "../rules/vitest.mjs";
|
|
5
|
+
import { getPlaywrightRules } from "../rules/playwright.mjs";
|
|
6
|
+
import { getTypeScriptRules } from "../rules/typescript.mjs";
|
|
7
7
|
import typescriptESLint from "typescript-eslint";
|
|
8
8
|
import eslintPluginVitest from "@vitest/eslint-plugin";
|
|
9
9
|
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
@@ -11,7 +11,7 @@ import eslintPluginPlaywright from "eslint-plugin-playwright";
|
|
|
11
11
|
|
|
12
12
|
//#region src/configs/oxlintOverrides.ts
|
|
13
13
|
function getOXLintOverridesConfig(options) {
|
|
14
|
-
const { vue, typescript, test: { vitest, playwright } } = options.configs;
|
|
14
|
+
const { vue, importX, typescript, test: { vitest, playwright } } = options.configs;
|
|
15
15
|
const vitestRules = getVitestRules(options);
|
|
16
16
|
const javascriptRules = getJavaScriptRules(options);
|
|
17
17
|
const typescriptRules = getTypeScriptRules(options);
|
|
@@ -20,14 +20,14 @@ function getOXLintOverridesConfig(options) {
|
|
|
20
20
|
name: "shayanthenerd/oxlint/overrides",
|
|
21
21
|
files: [
|
|
22
22
|
globs.src,
|
|
23
|
-
vue ? globs.vue : "",
|
|
24
|
-
vitest || playwright ? globs.test : ""
|
|
25
|
-
],
|
|
23
|
+
isEnabled(vue) ? globs.vue : "",
|
|
24
|
+
isEnabled(vitest) || isEnabled(playwright) ? globs.test : ""
|
|
25
|
+
].filter(Boolean),
|
|
26
26
|
plugins: {
|
|
27
|
-
|
|
28
|
-
"import-x": eslintPluginImportX,
|
|
29
|
-
|
|
30
|
-
"@typescript-eslint": typescriptESLint.plugin
|
|
27
|
+
...isEnabled(vitest) && { vitest: eslintPluginVitest },
|
|
28
|
+
...isEnabled(importX) && { "import-x": eslintPluginImportX },
|
|
29
|
+
...isEnabled(playwright) && { playwright: eslintPluginPlaywright },
|
|
30
|
+
...isEnabled(typescript) && { "@typescript-eslint": typescriptESLint.plugin }
|
|
31
31
|
},
|
|
32
32
|
rules: {
|
|
33
33
|
"max-depth": javascriptRules["max-depth"],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { globs } from "../utils/globs.
|
|
2
|
-
import { isEnabled } from "../utils/isEnabled.
|
|
3
|
-
import { defaultOptions } from "../utils/options/defaultOptions.
|
|
4
|
-
import { getPerfectionistRules } from "../rules/perfectionist.
|
|
1
|
+
import { globs } from "../utils/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../utils/options/defaultOptions.mjs";
|
|
4
|
+
import { getPerfectionistRules } from "../rules/perfectionist.mjs";
|
|
5
5
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
6
|
import eslintPluginPerfectionist from "eslint-plugin-perfectionist";
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ function getPerfectionistConfig(options) {
|
|
|
11
11
|
const { sortType, overrides } = isEnabled(perfectionist) ? perfectionist : defaultOptions.configs.perfectionist;
|
|
12
12
|
return mergeConfigs({
|
|
13
13
|
name: "shayanthenerd/perfectionist",
|
|
14
|
-
files: [globs.src,
|
|
14
|
+
files: isEnabled(vue) ? [globs.src, globs.vue] : [globs.src],
|
|
15
15
|
plugins: { perfectionist: eslintPluginPerfectionist },
|
|
16
16
|
settings: { perfectionist: { type: sortType } },
|
|
17
17
|
rules: getPerfectionistRules(options)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { globs } from "../utils/globs.
|
|
2
|
-
import { isEnabled } from "../utils/isEnabled.
|
|
3
|
-
import { defaultOptions } from "../utils/options/defaultOptions.
|
|
4
|
-
import { getPlaywrightRules } from "../rules/playwright.
|
|
1
|
+
import { globs } from "../utils/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../utils/options/defaultOptions.mjs";
|
|
4
|
+
import { getPlaywrightRules } from "../rules/playwright.mjs";
|
|
5
5
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
6
|
import eslintPluginPlaywright from "eslint-plugin-playwright";
|
|
7
7
|
|
|
@@ -12,7 +12,8 @@ function getPlaywrightConfig(options) {
|
|
|
12
12
|
return mergeConfigs({
|
|
13
13
|
name: "shayanthenerd/playwright",
|
|
14
14
|
files: [globs.test],
|
|
15
|
-
|
|
15
|
+
plugins: { playwright: eslintPluginPlaywright },
|
|
16
|
+
languageOptions: { globals: eslintPluginPlaywright.configs["flat/recommended"].languageOptions?.globals },
|
|
16
17
|
rules: getPlaywrightRules(options)
|
|
17
18
|
}, overrides);
|
|
18
19
|
}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { globs } from "../utils/globs.
|
|
2
|
-
import { isEnabled } from "../utils/isEnabled.
|
|
3
|
-
import { defaultOptions } from "../utils/options/defaultOptions.
|
|
4
|
-
import { getStorybookRules } from "../rules/storybook.
|
|
1
|
+
import { globs } from "../utils/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../utils/options/defaultOptions.mjs";
|
|
4
|
+
import { getStorybookRules } from "../rules/storybook.mjs";
|
|
5
5
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
6
|
import eslintPluginStorybook from "eslint-plugin-storybook";
|
|
7
7
|
|
|
8
8
|
//#region src/configs/storybook.ts
|
|
9
|
-
const eslintConfigStorybook = eslintPluginStorybook.configs["flat/recommended"];
|
|
10
9
|
function getStorybookConfig(options) {
|
|
11
10
|
const { storybook } = options.configs.test;
|
|
12
11
|
const { overrides } = isEnabled(storybook) ? storybook : defaultOptions.configs.test.storybook;
|
|
13
12
|
return mergeConfigs({
|
|
14
13
|
name: "shayanthenerd/storybook",
|
|
15
14
|
files: [globs.storybook],
|
|
16
|
-
|
|
15
|
+
plugins: { storybook: eslintPluginStorybook },
|
|
17
16
|
rules: getStorybookRules(options)
|
|
18
17
|
}, overrides);
|
|
19
18
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { globs } from "../utils/globs.
|
|
2
|
-
import { isEnabled } from "../utils/isEnabled.
|
|
3
|
-
import { defaultOptions } from "../utils/options/defaultOptions.
|
|
4
|
-
import { getStylisticRules } from "../rules/stylistic.
|
|
1
|
+
import { globs } from "../utils/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../utils/options/defaultOptions.mjs";
|
|
4
|
+
import { getStylisticRules } from "../rules/stylistic.mjs";
|
|
5
5
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
6
|
import eslintPluginStylistic from "@stylistic/eslint-plugin";
|
|
7
7
|
|
|
8
8
|
//#region src/configs/stylistic.ts
|
|
9
9
|
function getStylisticConfig(options) {
|
|
10
|
-
const { stylistic } = options.configs;
|
|
10
|
+
const { vue, stylistic } = options.configs;
|
|
11
11
|
const { overrides } = isEnabled(stylistic) ? stylistic : defaultOptions.configs.stylistic;
|
|
12
12
|
return mergeConfigs({
|
|
13
13
|
name: "shayanthenerd/stylistic",
|
|
14
|
-
files: [globs.src,
|
|
15
|
-
|
|
14
|
+
files: isEnabled(vue) ? [globs.src, globs.vue] : [globs.src],
|
|
15
|
+
plugins: { "@stylistic": eslintPluginStylistic },
|
|
16
16
|
rules: getStylisticRules(options)
|
|
17
17
|
}, overrides);
|
|
18
18
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { globs } from "../utils/globs.
|
|
2
|
-
import { isEnabled } from "../utils/isEnabled.
|
|
3
|
-
import { defaultOptions } from "../utils/options/defaultOptions.
|
|
4
|
-
import { getTailwindRules } from "../rules/tailwind.
|
|
1
|
+
import { globs } from "../utils/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../utils/options/defaultOptions.mjs";
|
|
4
|
+
import { getTailwindRules } from "../rules/tailwind.mjs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
7
7
|
import eslintPluginVue from "eslint-plugin-vue";
|
|
@@ -9,8 +9,15 @@ import eslintPluginHTML from "@html-eslint/eslint-plugin";
|
|
|
9
9
|
import eslintPluginTailwind from "eslint-plugin-better-tailwindcss";
|
|
10
10
|
|
|
11
11
|
//#region src/configs/tailwind.ts
|
|
12
|
-
const eslintParserHTML = eslintPluginHTML.configs["flat/recommended"]
|
|
13
|
-
const eslintParserVue = eslintPluginVue.configs["flat/recommended"].find((config) =>
|
|
12
|
+
const eslintParserHTML = (eslintPluginHTML.configs?.["flat/recommended"])?.languageOptions?.parser;
|
|
13
|
+
const eslintParserVue = eslintPluginVue.configs["flat/recommended"].find((config) => {
|
|
14
|
+
return config.name === "vue/base/setup-for-vue";
|
|
15
|
+
})?.languageOptions?.parser;
|
|
16
|
+
const vueAttributes = [["^v-bind:ui$", [{ match: "objectValues" }]], ["^(?:v-bind:)?(class|activeClass|inactiveClass)$", [
|
|
17
|
+
{ match: "strings" },
|
|
18
|
+
{ match: "objectKeys" },
|
|
19
|
+
{ match: "objectValues" }
|
|
20
|
+
]]];
|
|
14
21
|
function getTailwindConfig(options) {
|
|
15
22
|
const { tsConfig, configs: { vue, html, tailwind } } = options;
|
|
16
23
|
const { config, entryPoint, overrides } = isEnabled(tailwind) ? tailwind : defaultOptions.configs.tailwind;
|
|
@@ -20,18 +27,14 @@ function getTailwindConfig(options) {
|
|
|
20
27
|
globs.src,
|
|
21
28
|
html ? globs.html : "",
|
|
22
29
|
vue ? globs.vue : ""
|
|
23
|
-
],
|
|
30
|
+
].filter(Boolean),
|
|
24
31
|
plugins: { "better-tailwindcss": eslintPluginTailwind },
|
|
25
|
-
languageOptions: { parserOptions: { parser: html ? eslintParserHTML : eslintParserVue } },
|
|
32
|
+
languageOptions: { parserOptions: { parser: isEnabled(html) ? eslintParserHTML : eslintParserVue } },
|
|
26
33
|
settings: { "better-tailwindcss": {
|
|
27
|
-
entryPoint,
|
|
28
|
-
tailwindConfig: config,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
{ match: "strings" },
|
|
32
|
-
{ match: "objectKeys" },
|
|
33
|
-
{ match: "objectValues" }
|
|
34
|
-
]]]
|
|
34
|
+
entryPoint: entryPoint || void 0,
|
|
35
|
+
tailwindConfig: config || void 0,
|
|
36
|
+
attributes: isEnabled(vue) ? vueAttributes : void 0,
|
|
37
|
+
tsconfig: tsConfig ? path.resolve(tsConfig.rootDir, tsConfig.filename) : void 0
|
|
35
38
|
} },
|
|
36
39
|
rules: getTailwindRules(options)
|
|
37
40
|
}, overrides);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { globs } from "../utils/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../utils/options/defaultOptions.mjs";
|
|
4
|
+
import { getTypeScriptRules } from "../rules/typescript.mjs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
7
|
+
import { parser, plugin } from "typescript-eslint";
|
|
8
|
+
|
|
9
|
+
//#region src/configs/typescript.ts
|
|
10
|
+
function getTypeScriptConfig(options) {
|
|
11
|
+
const { tsConfig, configs: { vue, typescript } } = options;
|
|
12
|
+
const { allowedDefaultProjects } = isEnabled(typescript) ? typescript : defaultOptions.configs.typescript;
|
|
13
|
+
const { overrides } = isEnabled(typescript) ? typescript : defaultOptions.configs.typescript;
|
|
14
|
+
return mergeConfigs({
|
|
15
|
+
name: "shayanthenerd/typescript",
|
|
16
|
+
files: isEnabled(vue) ? [globs.ts, globs.vue] : [globs.ts],
|
|
17
|
+
plugins: { "@typescript-eslint": plugin },
|
|
18
|
+
languageOptions: {
|
|
19
|
+
parser,
|
|
20
|
+
parserOptions: {
|
|
21
|
+
warnOnUnsupportedTypeScriptVersion: false,
|
|
22
|
+
tsconfigRootDir: tsConfig ? path.resolve(tsConfig.rootDir) : void 0,
|
|
23
|
+
projectService: {
|
|
24
|
+
defaultProject: tsConfig ? tsConfig.filename : void 0,
|
|
25
|
+
allowDefaultProject: ["{prettier,eslint}.config.?([mc])ts", ...allowedDefaultProjects]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
rules: getTypeScriptRules(options)
|
|
30
|
+
}, overrides);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { getTypeScriptConfig };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { globs } from "../utils/globs.
|
|
2
|
-
import { isEnabled } from "../utils/isEnabled.
|
|
3
|
-
import { defaultOptions } from "../utils/options/defaultOptions.
|
|
4
|
-
import { getVitestRules } from "../rules/vitest.
|
|
1
|
+
import { globs } from "../utils/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../utils/options/defaultOptions.mjs";
|
|
4
|
+
import { getVitestRules } from "../rules/vitest.mjs";
|
|
5
5
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
6
|
import eslintPluginVitest from "@vitest/eslint-plugin";
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ function getVitestConfig(options) {
|
|
|
12
12
|
return mergeConfigs({
|
|
13
13
|
name: "shayanthenerd/vitest",
|
|
14
14
|
files: [globs.test],
|
|
15
|
-
|
|
15
|
+
plugins: { vitest: eslintPluginVitest },
|
|
16
16
|
rules: getVitestRules(options)
|
|
17
17
|
}, overrides);
|
|
18
18
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { globs } from "../utils/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../utils/options/defaultOptions.mjs";
|
|
4
|
+
import { getVueRules } from "../rules/vue.mjs";
|
|
5
|
+
import { getVueAccessibilityRules } from "../rules/vueAccessibility.mjs";
|
|
6
|
+
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
7
|
+
import eslintPluginVue from "eslint-plugin-vue";
|
|
8
|
+
import { parser } from "typescript-eslint";
|
|
9
|
+
import eslintPluginVueAccessibility from "eslint-plugin-vuejs-accessibility";
|
|
10
|
+
|
|
11
|
+
//#region src/configs/vue.ts
|
|
12
|
+
const vueSetupConfig = eslintPluginVue.configs["flat/recommended"].find((config) => {
|
|
13
|
+
return config.name === "vue/base/setup-for-vue";
|
|
14
|
+
});
|
|
15
|
+
vueSetupConfig.name = "setup";
|
|
16
|
+
function getVueConfig(options) {
|
|
17
|
+
const { vue } = options.configs;
|
|
18
|
+
const accessibility = isEnabled(vue) && isEnabled(vue.accessibility);
|
|
19
|
+
const { overrides } = isEnabled(vue) ? vue : defaultOptions.configs.vue;
|
|
20
|
+
return mergeConfigs({
|
|
21
|
+
name: "shayanthenerd/vue",
|
|
22
|
+
files: [globs.vue],
|
|
23
|
+
extends: [vueSetupConfig],
|
|
24
|
+
plugins: {
|
|
25
|
+
vue: eslintPluginVue,
|
|
26
|
+
...accessibility && { "vuejs-accessibility": eslintPluginVueAccessibility }
|
|
27
|
+
},
|
|
28
|
+
languageOptions: {
|
|
29
|
+
globals: eslintPluginVueAccessibility.configs["flat/recommended"][0]?.languageOptions.globals,
|
|
30
|
+
parser: vueSetupConfig.languageOptions?.parser,
|
|
31
|
+
parserOptions: {
|
|
32
|
+
parser,
|
|
33
|
+
extraFileExtensions: [".vue"],
|
|
34
|
+
vueFeatures: { filter: false }
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
rules: {
|
|
38
|
+
...getVueRules(options),
|
|
39
|
+
...accessibility && getVueAccessibilityRules(options)
|
|
40
|
+
}
|
|
41
|
+
}, overrides);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { getVueConfig };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ConfigObject, Options } from "./types/index.
|
|
1
|
+
import { ConfigObject, Options } from "./types/index.mjs";
|
|
2
2
|
import { Linter } from "eslint";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Define
|
|
7
|
+
* Define ESLint configuration based on the provided options and any number of Flat Config Objects.
|
|
8
8
|
*
|
|
9
9
|
* @param {Options} options - Options to configure and customize the config
|
|
10
|
-
* @param {...ConfigObject} configs - Additional Flat Config
|
|
10
|
+
* @param {...ConfigObject} configs - Additional Flat Config Objects to extend the default config
|
|
11
11
|
*
|
|
12
12
|
* @returns {Linter.Config[]} The merged ESLint configuration array
|
|
13
13
|
*/
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { isEnabled } from "./utils/isEnabled.mjs";
|
|
2
|
+
import { defaultOptions } from "./utils/options/defaultOptions.mjs";
|
|
3
|
+
import { getCSSConfig } from "./configs/css.mjs";
|
|
4
|
+
import { getVueConfig } from "./configs/vue.mjs";
|
|
5
|
+
import { getBaseConfig } from "./configs/base.mjs";
|
|
6
|
+
import { getHTMLConfig } from "./configs/html.mjs";
|
|
7
|
+
import { getVitestConfig } from "./configs/vitest.mjs";
|
|
8
|
+
import { getCypressConfig } from "./configs/cypress.mjs";
|
|
9
|
+
import { getImportXConfig } from "./configs/importX.mjs";
|
|
10
|
+
import { getTailwindConfig } from "./configs/tailwind.mjs";
|
|
11
|
+
import { getStorybookConfig } from "./configs/storybook.mjs";
|
|
12
|
+
import { getStylisticConfig } from "./configs/stylistic.mjs";
|
|
13
|
+
import { getPlaywrightConfig } from "./configs/playwright.mjs";
|
|
14
|
+
import { getTypeScriptConfig } from "./configs/typescript.mjs";
|
|
15
|
+
import { getPerfectionistConfig } from "./configs/perfectionist.mjs";
|
|
16
|
+
import { getRestrictedExports } from "./configs/restrictedExports.mjs";
|
|
17
|
+
import { getOXLintOverridesConfig } from "./configs/oxlintOverrides.mjs";
|
|
18
|
+
import { getIgnorePatterns } from "./utils/ignores/getIgnorePatterns.mjs";
|
|
19
|
+
import { mergeWithDefaults } from "./utils/options/mergeWithDefaults.mjs";
|
|
20
|
+
import { getVueComponentNamesConfig } from "./configs/vueComponentNames.mjs";
|
|
21
|
+
import { getVueServerComponentsConfig } from "./configs/vueServerComponents.mjs";
|
|
22
|
+
import eslintPluginOXLint from "eslint-plugin-oxlint";
|
|
23
|
+
import { defineConfig as defineConfig$1, globalIgnores } from "eslint/config";
|
|
24
|
+
import path from "node:path";
|
|
25
|
+
|
|
26
|
+
//#region src/index.ts
|
|
27
|
+
/**
|
|
28
|
+
* Define ESLint configuration based on the provided options and any number of Flat Config Objects.
|
|
29
|
+
*
|
|
30
|
+
* @param {Options} options - Options to configure and customize the config
|
|
31
|
+
* @param {...ConfigObject} configs - Additional Flat Config Objects to extend the default config
|
|
32
|
+
*
|
|
33
|
+
* @returns {Linter.Config[]} The merged ESLint configuration array
|
|
34
|
+
*/
|
|
35
|
+
function defineConfig(options = {}, ...configs) {
|
|
36
|
+
const mergedOptions = mergeWithDefaults(options);
|
|
37
|
+
const { gitignore, global: { rules, ignores, settings, linterOptions }, configs: { vue, css, nuxt, html, oxlint, importX, tailwind, stylistic, typescript, perfectionist, base: { preferNamedExports }, test: { vitest, cypress, storybook, playwright } } } = mergedOptions;
|
|
38
|
+
const ignorePatterns = getIgnorePatterns({
|
|
39
|
+
gitignore,
|
|
40
|
+
patterns: ignores
|
|
41
|
+
});
|
|
42
|
+
const oxlintConfigPath = oxlint ? path.resolve(oxlint || defaultOptions.configs.oxlint) : "";
|
|
43
|
+
const oxlintOverrides = oxlint ? eslintPluginOXLint.buildFromOxlintConfigFile(oxlintConfigPath).filter((config) => config.name !== "oxlint/vue-svelte-exceptions") : [];
|
|
44
|
+
return defineConfig$1([
|
|
45
|
+
globalIgnores(ignorePatterns, "shayanthenerd/ignores"),
|
|
46
|
+
{
|
|
47
|
+
name: "shayanthenerd/global",
|
|
48
|
+
linterOptions,
|
|
49
|
+
settings,
|
|
50
|
+
rules
|
|
51
|
+
},
|
|
52
|
+
getBaseConfig(mergedOptions),
|
|
53
|
+
isEnabled(typescript) && getTypeScriptConfig(mergedOptions),
|
|
54
|
+
isEnabled(html) && getHTMLConfig(mergedOptions),
|
|
55
|
+
isEnabled(css) && getCSSConfig(mergedOptions),
|
|
56
|
+
isEnabled(importX) && getImportXConfig(mergedOptions),
|
|
57
|
+
preferNamedExports && getRestrictedExports(),
|
|
58
|
+
isEnabled(stylistic) && getStylisticConfig(mergedOptions),
|
|
59
|
+
isEnabled(perfectionist) && getPerfectionistConfig(mergedOptions),
|
|
60
|
+
isEnabled(tailwind) && getTailwindConfig(mergedOptions),
|
|
61
|
+
isEnabled(vue) && getVueConfig(mergedOptions),
|
|
62
|
+
isEnabled(vue) && getVueComponentNamesConfig(),
|
|
63
|
+
isEnabled(vue) && isEnabled(nuxt) && getVueServerComponentsConfig(),
|
|
64
|
+
isEnabled(storybook) && getStorybookConfig(mergedOptions),
|
|
65
|
+
isEnabled(vitest) && getVitestConfig(mergedOptions),
|
|
66
|
+
isEnabled(cypress) && getCypressConfig(mergedOptions),
|
|
67
|
+
isEnabled(playwright) && getPlaywrightConfig(mergedOptions),
|
|
68
|
+
...oxlintOverrides,
|
|
69
|
+
oxlint && getOXLintOverridesConfig(mergedOptions),
|
|
70
|
+
...configs
|
|
71
|
+
].filter(Boolean));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
export { defineConfig };
|
package/dist/oxlint.config.jsonc
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isEnabled } from "../utils/isEnabled.
|
|
2
|
-
import { defaultOptions } from "../utils/options/defaultOptions.
|
|
1
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
2
|
+
import { defaultOptions } from "../utils/options/defaultOptions.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/rules/css.ts
|
|
5
5
|
const allowedPhysicalUnits = [
|
|
@@ -50,13 +50,22 @@ function getCSSRules(options) {
|
|
|
50
50
|
const { css } = options.configs;
|
|
51
51
|
const { useBaseline, allowedRelativeFontUnits } = isEnabled(css) ? css : defaultOptions.configs.css;
|
|
52
52
|
return {
|
|
53
|
+
"css/font-family-fallbacks": "warn",
|
|
54
|
+
"css/no-duplicate-imports": "error",
|
|
55
|
+
"css/no-duplicate-keyframe-selectors": "error",
|
|
56
|
+
"css/no-empty-blocks": "error",
|
|
57
|
+
"css/no-important": "warn",
|
|
58
|
+
"css/no-invalid-at-rule-placement": "error",
|
|
59
|
+
"css/no-invalid-at-rules": "error",
|
|
60
|
+
"css/no-invalid-named-grid-areas": "error",
|
|
53
61
|
"css/no-invalid-properties": ["error", { allowUnknownVariables: true }],
|
|
54
|
-
"css/
|
|
55
|
-
"css/use-baseline": useBaseline ? ["warn", { available: useBaseline }] : "off",
|
|
62
|
+
"css/no-unmatchable-selectors": "error",
|
|
56
63
|
"css/prefer-logical-properties": ["error", {
|
|
57
64
|
allowUnits: allowedPhysicalUnits,
|
|
58
65
|
allowProperties: allowedPhysicalProperties
|
|
59
|
-
}]
|
|
66
|
+
}],
|
|
67
|
+
"css/relative-font-units": ["warn", { allowUnits: allowedRelativeFontUnits }],
|
|
68
|
+
"css/use-baseline": useBaseline ? ["warn", { available: useBaseline }] : "off"
|
|
60
69
|
};
|
|
61
70
|
}
|
|
62
71
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/rules/cypress.ts
|
|
2
|
+
function getCypressRules() {
|
|
3
|
+
return {
|
|
4
|
+
"cypress/no-assigning-return-values": "error",
|
|
5
|
+
"cypress/no-async-before": "warn",
|
|
6
|
+
"cypress/no-async-tests": "error",
|
|
7
|
+
"cypress/no-chained-get": "error",
|
|
8
|
+
"cypress/no-debug": "error",
|
|
9
|
+
"cypress/no-force": "error",
|
|
10
|
+
"cypress/no-pause": "error",
|
|
11
|
+
"cypress/no-unnecessary-waiting": "error",
|
|
12
|
+
"cypress/no-xpath": "error",
|
|
13
|
+
"cypress/unsafe-to-chain-command": "error"
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { getCypressRules };
|