@shayanthenerd/eslint-config 0.16.0 → 0.20.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 +498 -342
- package/dist/configs/astro.mjs +1 -3
- package/dist/configs/base.mjs +4 -5
- package/dist/configs/css.mjs +1 -3
- package/dist/configs/cypress.mjs +1 -3
- package/dist/configs/html.mjs +2 -5
- package/dist/configs/importX.mjs +6 -11
- package/dist/configs/markdown.mjs +24 -0
- package/dist/configs/packageJson.mjs +20 -0
- package/dist/configs/perfectionist.mjs +3 -4
- package/dist/configs/playwright.mjs +1 -3
- package/dist/configs/promise.mjs +24 -0
- package/dist/configs/restrictedExports.mjs +1 -3
- package/dist/configs/storybook.mjs +1 -3
- package/dist/configs/stylistic.mjs +3 -4
- package/dist/configs/tailwind.mjs +33 -21
- package/dist/configs/typescript.mjs +4 -5
- package/dist/configs/vitest.mjs +1 -3
- package/dist/configs/vue.mjs +5 -10
- package/dist/configs/vueComponentNames.mjs +1 -3
- package/dist/configs/vueServerComponents.mjs +1 -3
- package/dist/configs/zod.mjs +9 -9
- package/dist/helpers/globs.mjs +6 -6
- package/dist/helpers/ignores/defaultIgnorePatterns.mjs +1 -2
- package/dist/helpers/ignores/getIgnorePatterns.mjs +1 -3
- package/dist/helpers/ignores/resolveGitignorePatterns.mjs +3 -5
- package/dist/helpers/isPackageDetected.mjs +5 -7
- package/dist/helpers/options/defaultOptions.mjs +102 -94
- package/dist/helpers/options/enableDetectedConfigs.mjs +4 -3
- package/dist/helpers/options/mergeWithDefaults.mjs +1 -3
- package/dist/helpers/vue/getRestrictedVueElements.mjs +1 -2
- package/dist/helpers/vue/getRestrictedVueInputs.mjs +1 -2
- package/dist/index.d.mts +34 -7
- package/dist/index.mjs +57 -26
- package/dist/prettier.config.mjs +21 -23
- package/dist/rules/astro.mjs +58 -57
- package/dist/rules/css.mjs +1 -3
- package/dist/rules/cypress.mjs +14 -14
- package/dist/rules/html.mjs +13 -6
- package/dist/rules/importX.mjs +2 -8
- package/dist/rules/javascript.mjs +49 -37
- package/dist/rules/markdown.mjs +52 -0
- package/dist/rules/packageJson.mjs +133 -0
- package/dist/rules/perfectionist.mjs +1 -3
- package/dist/rules/playwright.mjs +4 -3
- package/dist/rules/promise.mjs +26 -0
- package/dist/rules/storybook.mjs +1 -3
- package/dist/rules/stylistic.mjs +5 -6
- package/dist/rules/tailwind.mjs +9 -15
- package/dist/rules/typescript.mjs +15 -45
- package/dist/rules/vitest.mjs +2 -2
- package/dist/rules/vue.mjs +25 -14
- package/dist/rules/vueAccessibility.mjs +1 -5
- package/dist/rules/zod.mjs +54 -16
- package/dist/types/eslint-schema.d.mts +5145 -2020
- package/dist/types/eslintRules.d.mts +8 -2
- package/dist/types/helpers.d.mts +2 -2
- package/dist/types/index.d.mts +131 -163
- package/dist/types/{configOptions → options}/base.d.mts +20 -23
- package/dist/types/{configOptions → options}/css.d.mts +13 -13
- package/dist/types/{configOptions → options}/html.d.mts +13 -13
- package/dist/types/options/markdown.d.mts +42 -0
- package/dist/types/{configOptions → options}/nuxt.d.mts +12 -14
- package/dist/types/{configOptions → options}/perfectionist.d.mts +5 -4
- package/dist/types/{configOptions → options}/stylistic.d.mts +58 -65
- package/dist/types/{configOptions → options}/tailwind.d.mts +29 -19
- package/dist/types/{configOptions → options}/test.d.mts +32 -33
- package/dist/types/{configOptions → options}/typescript.d.mts +16 -7
- package/dist/types/{configOptions → options}/vue.d.mts +92 -106
- package/dist/types/{configOptions → options}/vueAccessibility.d.mts +14 -16
- package/dist/types/options/zod.d.mts +27 -0
- package/dist/utils/isEmptyString.mjs +1 -2
- package/dist/utils/isEnabled.mjs +1 -2
- package/dist/utils/isTruthy.mjs +6 -0
- package/package.json +97 -101
- package/dist/configs/oxlintOverrides.mjs +0 -52
- package/dist/oxlint.config.jsonc +0 -122
- package/dist/types/configOptions/importX.d.mts +0 -15
package/dist/configs/astro.mjs
CHANGED
|
@@ -6,7 +6,6 @@ import { mergeConfigs } from "eslint-flat-config-utils";
|
|
|
6
6
|
import { parser } from "typescript-eslint";
|
|
7
7
|
import eslintPluginAstro from "eslint-plugin-astro";
|
|
8
8
|
import * as eslintParserAstro from "astro-eslint-parser";
|
|
9
|
-
|
|
10
9
|
//#region src/configs/astro.ts
|
|
11
10
|
function getAstroConfig(options) {
|
|
12
11
|
const { astro } = options.configs;
|
|
@@ -29,6 +28,5 @@ function getAstroConfig(options) {
|
|
|
29
28
|
rules: getAstroRules()
|
|
30
29
|
}, overrides);
|
|
31
30
|
}
|
|
32
|
-
|
|
33
31
|
//#endregion
|
|
34
|
-
export { getAstroConfig };
|
|
32
|
+
export { getAstroConfig };
|
package/dist/configs/base.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
import { isTruthy } from "../utils/isTruthy.mjs";
|
|
1
2
|
import { globs } from "../helpers/globs.mjs";
|
|
2
3
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
4
|
import { getJavaScriptRules } from "../rules/javascript.mjs";
|
|
4
5
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
5
6
|
import { parser } from "typescript-eslint";
|
|
6
7
|
import globals from "globals";
|
|
7
|
-
|
|
8
8
|
//#region src/configs/base.ts
|
|
9
9
|
function getBaseConfig(options) {
|
|
10
|
-
const { env, configs: { vue, astro, base: { overrides } },
|
|
10
|
+
const { env, configs: { vue, astro, base: { overrides } }, project: { globals: { bun, node, deno, vitest, worker, browser, commonjs, nodeBuiltin, audioWorklet, webextension, sharedWorker, serviceworker, vue: vueGlobals, astro: astroGlobals, custom: userGlobals } } } = options;
|
|
11
11
|
return mergeConfigs({
|
|
12
12
|
name: "shayanthenerd/base",
|
|
13
13
|
files: [
|
|
14
14
|
globs.src,
|
|
15
15
|
isEnabled(vue) ? globs.vue : "",
|
|
16
16
|
isEnabled(astro) ? globs.astro : ""
|
|
17
|
-
].filter(
|
|
17
|
+
].filter(isTruthy),
|
|
18
18
|
languageOptions: {
|
|
19
19
|
parser,
|
|
20
20
|
parserOptions: {
|
|
@@ -47,6 +47,5 @@ function getBaseConfig(options) {
|
|
|
47
47
|
rules: getJavaScriptRules(options)
|
|
48
48
|
}, overrides);
|
|
49
49
|
}
|
|
50
|
-
|
|
51
50
|
//#endregion
|
|
52
|
-
export { getBaseConfig };
|
|
51
|
+
export { getBaseConfig };
|
package/dist/configs/css.mjs
CHANGED
|
@@ -5,7 +5,6 @@ import { getCSSRules } from "../rules/css.mjs";
|
|
|
5
5
|
import eslintPluginCSS from "@eslint/css";
|
|
6
6
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
7
7
|
import { tailwind3, tailwind4 } from "tailwind-csstree";
|
|
8
|
-
|
|
9
8
|
//#region src/configs/css.ts
|
|
10
9
|
function getCSSConfig(options) {
|
|
11
10
|
const { css, tailwind } = options.configs;
|
|
@@ -23,6 +22,5 @@ function getCSSConfig(options) {
|
|
|
23
22
|
rules: getCSSRules(options)
|
|
24
23
|
}, overrides);
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
//#endregion
|
|
28
|
-
export { getCSSConfig };
|
|
26
|
+
export { getCSSConfig };
|
package/dist/configs/cypress.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
|
4
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
|
-
|
|
8
7
|
//#region src/configs/cypress.ts
|
|
9
8
|
function getCypressConfig(options) {
|
|
10
9
|
const { cypress } = options.configs.test;
|
|
@@ -17,6 +16,5 @@ function getCypressConfig(options) {
|
|
|
17
16
|
rules: getCypressRules()
|
|
18
17
|
}, overrides);
|
|
19
18
|
}
|
|
20
|
-
|
|
21
19
|
//#endregion
|
|
22
|
-
export { getCypressConfig };
|
|
20
|
+
export { getCypressConfig };
|
package/dist/configs/html.mjs
CHANGED
|
@@ -4,9 +4,7 @@ import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
|
4
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
|
-
|
|
8
7
|
//#region src/configs/html.ts
|
|
9
|
-
const eslintParserHTML = (eslintPluginHTML.configs?.["flat/recommended"])?.languageOptions?.parser;
|
|
10
8
|
function getHTMLConfig(options) {
|
|
11
9
|
const { html } = options.configs;
|
|
12
10
|
const { overrides } = isEnabled(html) ? html : defaultOptions.configs.html;
|
|
@@ -14,10 +12,9 @@ function getHTMLConfig(options) {
|
|
|
14
12
|
name: "shayanthenerd/html",
|
|
15
13
|
files: [globs.html],
|
|
16
14
|
plugins: { "@html-eslint": eslintPluginHTML },
|
|
17
|
-
languageOptions: { parser:
|
|
15
|
+
languageOptions: { parser: eslintPluginHTML.configs["flat/recommended"].languageOptions.parser },
|
|
18
16
|
rules: getHTMLRules(options)
|
|
19
17
|
}, overrides);
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
//#endregion
|
|
23
|
-
export { getHTMLConfig };
|
|
20
|
+
export { getHTMLConfig };
|
package/dist/configs/importX.mjs
CHANGED
|
@@ -1,30 +1,25 @@
|
|
|
1
|
+
import { isTruthy } from "../utils/isTruthy.mjs";
|
|
1
2
|
import { globs } from "../helpers/globs.mjs";
|
|
2
3
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
4
|
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
5
|
import { getImportXRules } from "../rules/importX.mjs";
|
|
5
6
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
7
|
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
7
|
-
import eslintPluginUnusedImports from "eslint-plugin-unused-imports";
|
|
8
|
-
|
|
9
8
|
//#region src/configs/importX.ts
|
|
10
9
|
function getImportXConfig(options) {
|
|
11
10
|
const { vue, astro, importX, typescript } = options.configs;
|
|
12
|
-
const { overrides
|
|
11
|
+
const { overrides } = isEnabled(importX) ? importX : defaultOptions.configs.importX;
|
|
13
12
|
return mergeConfigs({
|
|
14
|
-
name: "shayanthenerd/
|
|
13
|
+
name: "shayanthenerd/import-x",
|
|
15
14
|
files: [
|
|
16
15
|
globs.src,
|
|
17
16
|
isEnabled(vue) ? globs.vue : "",
|
|
18
17
|
isEnabled(astro) ? globs.astro : ""
|
|
19
|
-
].filter(
|
|
20
|
-
plugins: {
|
|
21
|
-
"import-x": eslintPluginImportX,
|
|
22
|
-
...removeUnusedImports && { "unused-imports": eslintPluginUnusedImports }
|
|
23
|
-
},
|
|
18
|
+
].filter(isTruthy),
|
|
19
|
+
plugins: { "import-x": eslintPluginImportX },
|
|
24
20
|
settings: isEnabled(typescript) ? eslintPluginImportX.flatConfigs.typescript.settings : void 0,
|
|
25
21
|
rules: getImportXRules(options)
|
|
26
22
|
}, overrides);
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
//#endregion
|
|
30
|
-
export { getImportXConfig };
|
|
25
|
+
export { getImportXConfig };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { globs } from "../helpers/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
|
+
import { getMarkdownRules } from "../rules/markdown.mjs";
|
|
5
|
+
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
|
+
import eslintPluginMarkdown from "@eslint/markdown";
|
|
7
|
+
//#region src/configs/markdown.ts
|
|
8
|
+
function getMarkdownConfig(options) {
|
|
9
|
+
const { markdown } = options.configs;
|
|
10
|
+
const { language, frontmatter, overrides } = isEnabled(markdown) ? markdown : defaultOptions.configs.markdown;
|
|
11
|
+
return mergeConfigs({
|
|
12
|
+
name: "shayanthenerd/markdown",
|
|
13
|
+
files: [globs.markdown],
|
|
14
|
+
plugins: { markdown: eslintPluginMarkdown },
|
|
15
|
+
language: `markdown/${language}`,
|
|
16
|
+
languageOptions: {
|
|
17
|
+
math: true,
|
|
18
|
+
frontmatter
|
|
19
|
+
},
|
|
20
|
+
rules: getMarkdownRules(options)
|
|
21
|
+
}, overrides);
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { getMarkdownConfig };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { globs } from "../helpers/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
|
+
import { getPackageJsonRules } from "../rules/packageJson.mjs";
|
|
5
|
+
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
|
+
import eslintPluginPackageJson from "eslint-plugin-package-json";
|
|
7
|
+
//#region src/configs/packageJson.ts
|
|
8
|
+
function getPackageJsonConfig(options) {
|
|
9
|
+
const { packageJson } = options.configs;
|
|
10
|
+
const { overrides } = isEnabled(packageJson) ? packageJson : defaultOptions.configs.packageJson;
|
|
11
|
+
return mergeConfigs({
|
|
12
|
+
name: "shayanthenerd/package-json",
|
|
13
|
+
files: [globs.packageJson],
|
|
14
|
+
plugins: { "package-json": eslintPluginPackageJson },
|
|
15
|
+
languageOptions: { parser: eslintPluginPackageJson.configs.recommended.languageOptions.parser },
|
|
16
|
+
rules: getPackageJsonRules()
|
|
17
|
+
}, overrides);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getPackageJsonConfig };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { isTruthy } from "../utils/isTruthy.mjs";
|
|
1
2
|
import { globs } from "../helpers/globs.mjs";
|
|
2
3
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
4
|
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
5
|
import { getPerfectionistRules } from "../rules/perfectionist.mjs";
|
|
5
6
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
7
|
import eslintPluginPerfectionist from "eslint-plugin-perfectionist";
|
|
7
|
-
|
|
8
8
|
//#region src/configs/perfectionist.ts
|
|
9
9
|
function getPerfectionistConfig(options) {
|
|
10
10
|
const { vue, astro, perfectionist } = options.configs;
|
|
@@ -15,7 +15,7 @@ function getPerfectionistConfig(options) {
|
|
|
15
15
|
globs.src,
|
|
16
16
|
isEnabled(vue) ? globs.vue : "",
|
|
17
17
|
isEnabled(astro) ? globs.astro : ""
|
|
18
|
-
].filter(
|
|
18
|
+
].filter(isTruthy),
|
|
19
19
|
plugins: { perfectionist: eslintPluginPerfectionist },
|
|
20
20
|
settings: { perfectionist: {
|
|
21
21
|
type: sortType,
|
|
@@ -28,6 +28,5 @@ function getPerfectionistConfig(options) {
|
|
|
28
28
|
rules: getPerfectionistRules(options)
|
|
29
29
|
}, overrides);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
31
|
//#endregion
|
|
33
|
-
export { getPerfectionistConfig };
|
|
32
|
+
export { getPerfectionistConfig };
|
|
@@ -4,7 +4,6 @@ import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
|
4
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
|
-
|
|
8
7
|
//#region src/configs/playwright.ts
|
|
9
8
|
function getPlaywrightConfig(options) {
|
|
10
9
|
const { playwright } = options.configs.test;
|
|
@@ -17,6 +16,5 @@ function getPlaywrightConfig(options) {
|
|
|
17
16
|
rules: getPlaywrightRules(options)
|
|
18
17
|
}, overrides);
|
|
19
18
|
}
|
|
20
|
-
|
|
21
19
|
//#endregion
|
|
22
|
-
export { getPlaywrightConfig };
|
|
20
|
+
export { getPlaywrightConfig };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isTruthy } from "../utils/isTruthy.mjs";
|
|
2
|
+
import { globs } from "../helpers/globs.mjs";
|
|
3
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
4
|
+
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
5
|
+
import { getPromiseRules } from "../rules/promise.mjs";
|
|
6
|
+
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
7
|
+
import eslintPluginPromise from "eslint-plugin-promise";
|
|
8
|
+
//#region src/configs/promise.ts
|
|
9
|
+
function getPromiseConfig(options) {
|
|
10
|
+
const { vue, astro, promise } = options.configs;
|
|
11
|
+
const { overrides } = isEnabled(promise) ? promise : defaultOptions.configs.promise;
|
|
12
|
+
return mergeConfigs({
|
|
13
|
+
name: "shayanthenerd/promise",
|
|
14
|
+
files: [
|
|
15
|
+
globs.src,
|
|
16
|
+
isEnabled(vue) ? globs.vue : "",
|
|
17
|
+
isEnabled(astro) ? globs.astro : ""
|
|
18
|
+
].filter(isTruthy),
|
|
19
|
+
plugins: { promise: eslintPluginPromise },
|
|
20
|
+
rules: getPromiseRules()
|
|
21
|
+
}, overrides);
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { getPromiseConfig };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { globs } from "../helpers/globs.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/configs/restrictedExports.ts
|
|
4
3
|
function getRestrictedExports() {
|
|
5
4
|
return {
|
|
@@ -13,6 +12,5 @@ function getRestrictedExports() {
|
|
|
13
12
|
} }] }
|
|
14
13
|
};
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
//#endregion
|
|
18
|
-
export { getRestrictedExports };
|
|
16
|
+
export { getRestrictedExports };
|
|
@@ -4,7 +4,6 @@ import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
|
4
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
|
-
|
|
8
7
|
//#region src/configs/storybook.ts
|
|
9
8
|
function getStorybookConfig(options) {
|
|
10
9
|
const { storybook } = options.configs.test;
|
|
@@ -16,6 +15,5 @@ function getStorybookConfig(options) {
|
|
|
16
15
|
rules: getStorybookRules(options)
|
|
17
16
|
}, overrides);
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
//#endregion
|
|
21
|
-
export { getStorybookConfig };
|
|
19
|
+
export { getStorybookConfig };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { isTruthy } from "../utils/isTruthy.mjs";
|
|
1
2
|
import { globs } from "../helpers/globs.mjs";
|
|
2
3
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
4
|
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
5
|
import { getStylisticRules } from "../rules/stylistic.mjs";
|
|
5
6
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
7
|
import eslintPluginStylistic from "@stylistic/eslint-plugin";
|
|
7
|
-
|
|
8
8
|
//#region src/configs/stylistic.ts
|
|
9
9
|
function getStylisticConfig(options) {
|
|
10
10
|
const { vue, astro, stylistic } = options.configs;
|
|
@@ -15,11 +15,10 @@ function getStylisticConfig(options) {
|
|
|
15
15
|
globs.src,
|
|
16
16
|
isEnabled(vue) ? globs.vue : "",
|
|
17
17
|
isEnabled(astro) ? globs.astro : ""
|
|
18
|
-
].filter(
|
|
18
|
+
].filter(isTruthy),
|
|
19
19
|
plugins: { "@stylistic": eslintPluginStylistic },
|
|
20
20
|
rules: getStylisticRules(options)
|
|
21
21
|
}, overrides);
|
|
22
22
|
}
|
|
23
|
-
|
|
24
23
|
//#endregion
|
|
25
|
-
export { getStylisticConfig };
|
|
24
|
+
export { getStylisticConfig };
|
|
@@ -1,26 +1,37 @@
|
|
|
1
|
+
import { isTruthy } from "../utils/isTruthy.mjs";
|
|
1
2
|
import { globs } from "../helpers/globs.mjs";
|
|
2
3
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
4
|
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
5
|
import { getTailwindRules } from "../rules/tailwind.mjs";
|
|
5
|
-
import path from "node:path";
|
|
6
6
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
7
|
+
import path from "node:path";
|
|
7
8
|
import eslintPluginTailwind from "eslint-plugin-better-tailwindcss";
|
|
8
|
-
|
|
9
|
+
import { getDefaultSelectors } from "eslint-plugin-better-tailwindcss/defaults";
|
|
10
|
+
import { MatcherType, SelectorKind } from "eslint-plugin-better-tailwindcss/types";
|
|
9
11
|
//#region src/configs/tailwind.ts
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
{
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
|
|
12
|
+
const astroAttribute = {
|
|
13
|
+
kind: SelectorKind.Attribute,
|
|
14
|
+
name: "^class:list$",
|
|
15
|
+
match: [{ type: MatcherType.String }, { type: MatcherType.ObjectKey }]
|
|
16
|
+
};
|
|
17
|
+
const vueAttributes = [{
|
|
18
|
+
kind: SelectorKind.Attribute,
|
|
19
|
+
name: "^v-bind:ui$",
|
|
20
|
+
match: [{ type: MatcherType.ObjectValue }]
|
|
21
|
+
}, {
|
|
22
|
+
kind: SelectorKind.Attribute,
|
|
23
|
+
name: "^(?:v-bind:)?(activeClass|inactiveClass|active-class|inactive-class)$",
|
|
24
|
+
match: [{ type: MatcherType.String }, { type: MatcherType.ObjectKey }]
|
|
25
|
+
}];
|
|
20
26
|
function getTailwindConfig(options) {
|
|
21
27
|
const { tsConfig, configs: { vue, html, astro, tailwind } } = options;
|
|
22
|
-
const { config, entryPoint, overrides } = isEnabled(tailwind) ? tailwind : defaultOptions.configs.tailwind;
|
|
23
|
-
const
|
|
28
|
+
const { cwd, config, entryPoint, overrides } = isEnabled(tailwind) ? tailwind : defaultOptions.configs.tailwind;
|
|
29
|
+
const tsconfig = tsConfig ? path.resolve(tsConfig.rootDir, tsConfig.filename) : void 0;
|
|
30
|
+
const selectors = [
|
|
31
|
+
...getDefaultSelectors(),
|
|
32
|
+
...isEnabled(vue) ? vueAttributes : [],
|
|
33
|
+
isEnabled(astro) ? astroAttribute : void 0
|
|
34
|
+
].filter(isTruthy);
|
|
24
35
|
return mergeConfigs({
|
|
25
36
|
name: "shayanthenerd/tailwind",
|
|
26
37
|
files: [
|
|
@@ -28,17 +39,18 @@ function getTailwindConfig(options) {
|
|
|
28
39
|
isEnabled(vue) ? globs.vue : "",
|
|
29
40
|
isEnabled(html) ? globs.html : "",
|
|
30
41
|
isEnabled(astro) ? globs.astro : ""
|
|
31
|
-
].filter(
|
|
42
|
+
].filter(isTruthy),
|
|
32
43
|
plugins: { "better-tailwindcss": eslintPluginTailwind },
|
|
33
44
|
settings: { "better-tailwindcss": {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
cwd,
|
|
46
|
+
tsconfig,
|
|
47
|
+
selectors,
|
|
48
|
+
entryPoint,
|
|
49
|
+
tailwindConfig: config,
|
|
50
|
+
detectComponentClasses: true
|
|
38
51
|
} },
|
|
39
52
|
rules: getTailwindRules(options)
|
|
40
53
|
}, overrides);
|
|
41
54
|
}
|
|
42
|
-
|
|
43
55
|
//#endregion
|
|
44
|
-
export { getTailwindConfig };
|
|
56
|
+
export { getTailwindConfig };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { isTruthy } from "../utils/isTruthy.mjs";
|
|
1
2
|
import { globs } from "../helpers/globs.mjs";
|
|
2
3
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
4
|
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
5
|
import { getTypeScriptRules } from "../rules/typescript.mjs";
|
|
5
|
-
import path from "node:path";
|
|
6
6
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
7
7
|
import { parser, plugin } from "typescript-eslint";
|
|
8
|
-
|
|
8
|
+
import path from "node:path";
|
|
9
9
|
//#region src/configs/typescript.ts
|
|
10
10
|
function getTypeScriptConfig(options) {
|
|
11
11
|
const { tsConfig, configs: { vue, astro, typescript } } = options;
|
|
@@ -17,7 +17,7 @@ function getTypeScriptConfig(options) {
|
|
|
17
17
|
globs.src,
|
|
18
18
|
isEnabled(vue) ? globs.vue : "",
|
|
19
19
|
isEnabled(astro) ? globs.astro : ""
|
|
20
|
-
].filter(
|
|
20
|
+
].filter(isTruthy),
|
|
21
21
|
plugins: { "@typescript-eslint": plugin },
|
|
22
22
|
languageOptions: {
|
|
23
23
|
parser,
|
|
@@ -33,6 +33,5 @@ function getTypeScriptConfig(options) {
|
|
|
33
33
|
rules: getTypeScriptRules(options)
|
|
34
34
|
}, overrides);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
36
|
//#endregion
|
|
38
|
-
export { getTypeScriptConfig };
|
|
37
|
+
export { getTypeScriptConfig };
|
package/dist/configs/vitest.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
|
4
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
|
-
|
|
8
7
|
//#region src/configs/vitest.ts
|
|
9
8
|
function getVitestConfig(options) {
|
|
10
9
|
const { vitest } = options.configs.test;
|
|
@@ -16,6 +15,5 @@ function getVitestConfig(options) {
|
|
|
16
15
|
rules: getVitestRules(options)
|
|
17
16
|
}, overrides);
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
//#endregion
|
|
21
|
-
export { getVitestConfig };
|
|
19
|
+
export { getVitestConfig };
|
package/dist/configs/vue.mjs
CHANGED
|
@@ -7,12 +7,8 @@ import { mergeConfigs } from "eslint-flat-config-utils";
|
|
|
7
7
|
import eslintPluginVue from "eslint-plugin-vue";
|
|
8
8
|
import { parser } from "typescript-eslint";
|
|
9
9
|
import eslintPluginVueAccessibility from "eslint-plugin-vuejs-accessibility";
|
|
10
|
-
|
|
11
10
|
//#region src/configs/vue.ts
|
|
12
|
-
const
|
|
13
|
-
return config.name === "vue/base/setup-for-vue";
|
|
14
|
-
});
|
|
15
|
-
vueSetupConfig.name = "setup";
|
|
11
|
+
const baseVueConfig = eslintPluginVue.configs["flat/base"].find((config) => config.languageOptions?.parser);
|
|
16
12
|
function getVueConfig(options) {
|
|
17
13
|
const { vue } = options.configs;
|
|
18
14
|
const accessibility = isEnabled(vue) && isEnabled(vue.accessibility);
|
|
@@ -20,14 +16,14 @@ function getVueConfig(options) {
|
|
|
20
16
|
return mergeConfigs({
|
|
21
17
|
name: "shayanthenerd/vue",
|
|
22
18
|
files: [globs.vue],
|
|
23
|
-
extends: [vueSetupConfig],
|
|
24
19
|
plugins: {
|
|
25
20
|
vue: eslintPluginVue,
|
|
26
21
|
...accessibility && { "vuejs-accessibility": eslintPluginVueAccessibility }
|
|
27
22
|
},
|
|
23
|
+
processor: "vue/vue",
|
|
28
24
|
languageOptions: {
|
|
29
|
-
globals: eslintPluginVueAccessibility.configs["flat/recommended"][0]
|
|
30
|
-
parser:
|
|
25
|
+
globals: eslintPluginVueAccessibility.configs["flat/recommended"][0].languageOptions.globals,
|
|
26
|
+
parser: baseVueConfig?.languageOptions?.parser,
|
|
31
27
|
parserOptions: {
|
|
32
28
|
parser,
|
|
33
29
|
extraFileExtensions: [".vue"],
|
|
@@ -40,6 +36,5 @@ function getVueConfig(options) {
|
|
|
40
36
|
}
|
|
41
37
|
}, overrides);
|
|
42
38
|
}
|
|
43
|
-
|
|
44
39
|
//#endregion
|
|
45
|
-
export { getVueConfig };
|
|
40
|
+
export { getVueConfig };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { globs } from "../helpers/globs.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/configs/vueComponentNames.ts
|
|
4
3
|
function getVueComponentNamesConfig() {
|
|
5
4
|
return {
|
|
@@ -12,6 +11,5 @@ function getVueComponentNamesConfig() {
|
|
|
12
11
|
}
|
|
13
12
|
};
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
//#endregion
|
|
17
|
-
export { getVueComponentNamesConfig };
|
|
15
|
+
export { getVueComponentNamesConfig };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { globs } from "../helpers/globs.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/configs/vueServerComponents.ts
|
|
4
3
|
function getVueServerComponentsConfig() {
|
|
5
4
|
return {
|
|
@@ -8,6 +7,5 @@ function getVueServerComponentsConfig() {
|
|
|
8
7
|
rules: { "vue/no-multiple-template-root": "error" }
|
|
9
8
|
};
|
|
10
9
|
}
|
|
11
|
-
|
|
12
10
|
//#endregion
|
|
13
|
-
export { getVueServerComponentsConfig };
|
|
11
|
+
export { getVueServerComponentsConfig };
|
package/dist/configs/zod.mjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
+
import { isTruthy } from "../utils/isTruthy.mjs";
|
|
1
2
|
import { globs } from "../helpers/globs.mjs";
|
|
2
3
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
4
|
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
5
|
import { getZodRules } from "../rules/zod.mjs";
|
|
5
6
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
|
-
import
|
|
7
|
-
|
|
7
|
+
import eslintPluginZod from "eslint-plugin-zod";
|
|
8
|
+
import eslintPluginZodMini from "eslint-plugin-zod-mini";
|
|
8
9
|
//#region src/configs/zod.ts
|
|
9
10
|
function getZodConfig(options) {
|
|
10
11
|
const { zod, vue, astro } = options.configs;
|
|
11
|
-
const { overrides } = isEnabled(zod) ? zod : defaultOptions.configs.zod;
|
|
12
|
+
const { mini, overrides } = isEnabled(zod) ? zod : defaultOptions.configs.zod;
|
|
12
13
|
return mergeConfigs({
|
|
13
|
-
name: "
|
|
14
|
+
name: `shayanthenerd/${mini ? "zod-mini" : "zod"}`,
|
|
14
15
|
files: [
|
|
15
16
|
globs.src,
|
|
16
17
|
isEnabled(vue) ? globs.vue : "",
|
|
17
18
|
isEnabled(astro) ? globs.astro : ""
|
|
18
|
-
].filter(
|
|
19
|
-
plugins: { "zod-
|
|
20
|
-
rules: getZodRules()
|
|
19
|
+
].filter(isTruthy),
|
|
20
|
+
plugins: mini ? { "zod-mini": eslintPluginZodMini } : { zod: eslintPluginZod },
|
|
21
|
+
rules: getZodRules(options)
|
|
21
22
|
}, overrides);
|
|
22
23
|
}
|
|
23
|
-
|
|
24
24
|
//#endregion
|
|
25
|
-
export { getZodConfig };
|
|
25
|
+
export { getZodConfig };
|
package/dist/helpers/globs.mjs
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
const srcExtensions = "?([mc])[jt]s?(x)";
|
|
3
3
|
const vueExtensions = `{vue,${srcExtensions}}`;
|
|
4
4
|
const globs = {
|
|
5
|
-
css: "**/*.css",
|
|
6
|
-
html: "**/*.html",
|
|
7
|
-
ts: "**/*.?([mc])ts?(x)",
|
|
8
5
|
src: `**/*.${srcExtensions}`,
|
|
9
6
|
restrictedExports: `**/{${[
|
|
10
7
|
"shared",
|
|
@@ -16,13 +13,16 @@ const globs = {
|
|
|
16
13
|
"composable?(s)",
|
|
17
14
|
"repo?(s|sitory|sitories)"
|
|
18
15
|
].join(",")}}/**/*.${srcExtensions}`,
|
|
16
|
+
packageJson: "**/package.json",
|
|
17
|
+
markdown: "**/*.md",
|
|
18
|
+
html: "**/*.html",
|
|
19
|
+
css: "**/*.css",
|
|
20
|
+
astro: "**/*.astro",
|
|
19
21
|
vue: `**/*.${vueExtensions}`,
|
|
20
22
|
vueServerComponents: `**/*.server.${vueExtensions}`,
|
|
21
23
|
vueAppErrorLayoutsPages: `**/{{app,error},{layouts,pages}/**/*}.${vueExtensions}`,
|
|
22
|
-
astro: "**/*.astro",
|
|
23
24
|
storybook: `**/*.(story|stories).${srcExtensions}`,
|
|
24
25
|
test: `**/{__tests__/*,*.{test,spec,cy,bench?(mark)}.${srcExtensions}`
|
|
25
26
|
};
|
|
26
|
-
|
|
27
27
|
//#endregion
|
|
28
|
-
export { globs };
|
|
28
|
+
export { globs };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { defaultIgnorePatterns } from "./defaultIgnorePatterns.mjs";
|
|
2
2
|
import { resolveGitignorePatterns } from "./resolveGitignorePatterns.mjs";
|
|
3
|
-
|
|
4
3
|
//#region src/helpers/ignores/getIgnorePatterns.ts
|
|
5
4
|
function getIgnorePatterns({ patterns, gitignore }) {
|
|
6
5
|
if (gitignore) {
|
|
@@ -10,6 +9,5 @@ function getIgnorePatterns({ patterns, gitignore }) {
|
|
|
10
9
|
if (patterns.length > 0) defaultIgnorePatterns.push(...patterns);
|
|
11
10
|
return [...new Set(defaultIgnorePatterns)];
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
//#endregion
|
|
15
|
-
export { getIgnorePatterns };
|
|
13
|
+
export { getIgnorePatterns };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { includeIgnoreFile } from "eslint/config";
|
|
1
2
|
import path from "node:path";
|
|
2
|
-
import { includeIgnoreFile } from "@eslint/compat";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { styleText } from "node:util";
|
|
5
|
-
|
|
6
5
|
//#region src/helpers/ignores/resolveGitignorePatterns.ts
|
|
7
6
|
const warningMessage = styleText("yellow", "⚠ Warning:");
|
|
8
7
|
const fallbackMessage = `Falling back to default ignore patterns. You can suppress this warning by setting ${styleText("bgBlack", " gitignore: false ")} in the config.`;
|
|
@@ -15,11 +14,10 @@ function resolveGitignorePatterns(gitignorePath) {
|
|
|
15
14
|
console.warn(warningMessage, `No .gitignore file found at "${styledGitignorePath}".`, fallbackMessage);
|
|
16
15
|
return gitignorePatterns;
|
|
17
16
|
}
|
|
18
|
-
const ignorePatterns = includeIgnoreFile(gitignoreAbsolutePath).ignores ?? [];
|
|
17
|
+
const ignorePatterns = includeIgnoreFile(gitignoreAbsolutePath, { gitignoreResolution: true }).ignores ?? [];
|
|
19
18
|
if (ignorePatterns.length > 0) gitignorePatterns.push(...ignorePatterns);
|
|
20
19
|
else console.warn(warningMessage, `No patterns found in .gitignore file at "${styledGitignorePath}".`, fallbackMessage);
|
|
21
20
|
return gitignorePatterns;
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
//#endregion
|
|
25
|
-
export { resolveGitignorePatterns };
|
|
23
|
+
export { resolveGitignorePatterns };
|