@shayanthenerd/eslint-config 0.13.1 → 0.15.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/LICENSE +1 -1
- package/README.md +192 -183
- package/dist/configs/base.mjs +13 -9
- package/dist/configs/css.mjs +2 -2
- package/dist/configs/cypress.mjs +2 -2
- package/dist/configs/html.mjs +2 -2
- package/dist/configs/importX.mjs +2 -2
- package/dist/configs/oxlintOverrides.mjs +16 -11
- package/dist/configs/perfectionist.mjs +2 -2
- package/dist/configs/playwright.mjs +2 -2
- package/dist/configs/restrictedExports.mjs +1 -1
- package/dist/configs/storybook.mjs +2 -2
- package/dist/configs/stylistic.mjs +2 -2
- package/dist/configs/tailwind.mjs +4 -4
- package/dist/configs/typescript.mjs +2 -2
- package/dist/configs/vitest.mjs +2 -2
- package/dist/configs/vue.mjs +2 -2
- package/dist/configs/vueComponentNames.mjs +1 -1
- package/dist/configs/vueServerComponents.mjs +1 -1
- package/dist/configs/zod.mjs +21 -0
- package/dist/{utils → helpers}/globs.mjs +1 -1
- package/dist/{utils → helpers}/ignores/defaultIgnorePatterns.mjs +1 -1
- package/dist/{utils → helpers}/ignores/getIgnorePatterns.mjs +1 -1
- package/dist/{utils → helpers}/ignores/resolveGitignorePatterns.mjs +1 -1
- package/dist/{utils → helpers}/isPackageDetected.mjs +5 -3
- package/dist/{utils → helpers}/options/defaultOptions.mjs +14 -7
- package/dist/{utils → helpers}/options/enableDetectedConfigs.mjs +2 -3
- package/dist/{utils → helpers}/options/mergeWithDefaults.mjs +4 -5
- package/dist/{utils → helpers}/vue/getRestrictedVueElements.mjs +1 -1
- package/dist/{utils → helpers}/vue/getRestrictedVueInputs.mjs +1 -1
- package/dist/index.mjs +6 -4
- package/dist/oxlint.config.jsonc +209 -201
- package/dist/prettier.config.mjs +1 -1
- package/dist/rules/css.mjs +1 -1
- package/dist/rules/html.mjs +3 -3
- package/dist/rules/importX.mjs +1 -1
- package/dist/rules/javascript.mjs +1 -2
- package/dist/rules/perfectionist.mjs +2 -2
- package/dist/rules/stylistic.mjs +22 -10
- package/dist/rules/tailwind.mjs +4 -4
- package/dist/rules/typescript.mjs +6 -3
- package/dist/rules/vitest.mjs +4 -0
- package/dist/rules/vue.mjs +6 -6
- package/dist/rules/vueAccessibility.mjs +1 -1
- package/dist/rules/zod.mjs +20 -0
- package/dist/types/configOptions/base.d.mts +8 -8
- package/dist/types/configOptions/nuxt.d.mts +3 -3
- package/dist/types/configOptions/stylistic.d.mts +0 -15
- package/dist/types/configOptions/test.d.mts +4 -4
- package/dist/types/configOptions/vue.d.mts +1 -1
- package/dist/types/eslint-schema.d.mts +769 -270
- package/dist/types/index.d.mts +43 -19
- package/package.json +139 -123
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { globs } from "../
|
|
1
|
+
import { globs } from "../helpers/globs.mjs";
|
|
2
2
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
-
import { defaultOptions } from "../
|
|
3
|
+
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
4
|
import { getStylisticRules } from "../rules/stylistic.mjs";
|
|
5
5
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
6
|
import eslintPluginStylistic from "@stylistic/eslint-plugin";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { globs } from "../
|
|
1
|
+
import { globs } from "../helpers/globs.mjs";
|
|
2
2
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
-
import { defaultOptions } from "../
|
|
3
|
+
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
4
|
import { getTailwindRules } from "../rules/tailwind.mjs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
@@ -25,8 +25,8 @@ function getTailwindConfig(options) {
|
|
|
25
25
|
name: "shayanthenerd/tailwind",
|
|
26
26
|
files: [
|
|
27
27
|
globs.src,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
vue ? globs.vue : "",
|
|
29
|
+
html ? globs.html : ""
|
|
30
30
|
].filter(Boolean),
|
|
31
31
|
plugins: { "better-tailwindcss": eslintPluginTailwind },
|
|
32
32
|
languageOptions: { parserOptions: { parser: isEnabled(html) ? eslintParserHTML : eslintParserVue } },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { globs } from "../
|
|
1
|
+
import { globs } from "../helpers/globs.mjs";
|
|
2
2
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
-
import { defaultOptions } from "../
|
|
3
|
+
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
4
|
import { getTypeScriptRules } from "../rules/typescript.mjs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
package/dist/configs/vitest.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { globs } from "../
|
|
1
|
+
import { globs } from "../helpers/globs.mjs";
|
|
2
2
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
-
import { defaultOptions } from "../
|
|
3
|
+
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";
|
package/dist/configs/vue.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { globs } from "../
|
|
1
|
+
import { globs } from "../helpers/globs.mjs";
|
|
2
2
|
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
-
import { defaultOptions } from "../
|
|
3
|
+
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
4
|
import { getVueRules } from "../rules/vue.mjs";
|
|
5
5
|
import { getVueAccessibilityRules } from "../rules/vueAccessibility.mjs";
|
|
6
6
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { globs } from "../helpers/globs.mjs";
|
|
2
|
+
import { isEnabled } from "../utils/isEnabled.mjs";
|
|
3
|
+
import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
|
|
4
|
+
import { getZodRules } from "../rules/zod.mjs";
|
|
5
|
+
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
|
+
import eslintPluginZodX from "eslint-plugin-zod-x";
|
|
7
|
+
|
|
8
|
+
//#region src/configs/zod.ts
|
|
9
|
+
function getZodConfig(options) {
|
|
10
|
+
const { zod, vue } = options.configs;
|
|
11
|
+
const { overrides } = isEnabled(zod) ? zod : defaultOptions.configs.zod;
|
|
12
|
+
return mergeConfigs({
|
|
13
|
+
name: "shayanthenerd/zod",
|
|
14
|
+
files: isEnabled(vue) ? [globs.src, globs.vue] : [globs.src],
|
|
15
|
+
plugins: { "zod-x": eslintPluginZodX },
|
|
16
|
+
rules: getZodRules()
|
|
17
|
+
}, overrides);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { getZodConfig };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defaultIgnorePatterns } from "./defaultIgnorePatterns.mjs";
|
|
2
2
|
import { resolveGitignorePatterns } from "./resolveGitignorePatterns.mjs";
|
|
3
3
|
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/helpers/ignores/getIgnorePatterns.ts
|
|
5
5
|
function getIgnorePatterns({ patterns, gitignore }) {
|
|
6
6
|
if (gitignore) {
|
|
7
7
|
const gitignorePatterns = resolveGitignorePatterns(gitignore);
|
|
@@ -3,7 +3,7 @@ import { includeIgnoreFile } from "@eslint/compat";
|
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { styleText } from "node:util";
|
|
5
5
|
|
|
6
|
-
//#region src/
|
|
6
|
+
//#region src/helpers/ignores/resolveGitignorePatterns.ts
|
|
7
7
|
const warningMessage = styleText("yellow", "⚠ Warning:");
|
|
8
8
|
const fallbackMessage = `Falling back to default ignore patterns. You can suppress this warning by setting ${styleText("bgBlack", " gitignore: false ")} in the config.`;
|
|
9
9
|
function resolveGitignorePatterns(gitignorePath) {
|
|
@@ -3,17 +3,19 @@ import path from "node:path";
|
|
|
3
3
|
import { styleText } from "node:util";
|
|
4
4
|
import { isPackageExists } from "local-pkg";
|
|
5
5
|
|
|
6
|
-
//#region src/
|
|
6
|
+
//#region src/helpers/isPackageDetected.ts
|
|
7
7
|
const detectedPackages = [];
|
|
8
8
|
function logDetectedPackages() {
|
|
9
|
-
if (detectedPackages.length > 0)
|
|
9
|
+
if (detectedPackages.length > 0) {
|
|
10
|
+
detectedPackages.sort();
|
|
11
|
+
console.info(styleText("green", "✔"), "Automatic dependency detection enabled ESLint configurations for", detectedPackages.map((packageName) => styleText("blue", packageName)).join(", "));
|
|
12
|
+
}
|
|
10
13
|
}
|
|
11
14
|
function isPackageDetected(packageName, options = defaultOptions) {
|
|
12
15
|
const { packageDir = defaultOptions.packageDir, autoDetectDeps = defaultOptions.autoDetectDeps } = options;
|
|
13
16
|
if (!autoDetectDeps) return false;
|
|
14
17
|
const isPackageInstalled = isPackageExists(packageName, { paths: [path.resolve(packageDir)] });
|
|
15
18
|
if (isPackageInstalled) detectedPackages.push(packageName);
|
|
16
|
-
detectedPackages.sort();
|
|
17
19
|
return isPackageInstalled;
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/helpers/options/defaultOptions.ts
|
|
2
2
|
const defaultOptions = {
|
|
3
3
|
autoDetectDeps: true,
|
|
4
4
|
gitignore: ".gitignore",
|
|
@@ -14,19 +14,26 @@ const defaultOptions = {
|
|
|
14
14
|
reportUnusedDisableDirectives: "warn"
|
|
15
15
|
},
|
|
16
16
|
globals: {
|
|
17
|
-
|
|
17
|
+
worker: true,
|
|
18
18
|
commonjs: false,
|
|
19
|
+
bun: true,
|
|
20
|
+
deno: true,
|
|
21
|
+
node: true,
|
|
22
|
+
nodeBuiltin: true,
|
|
19
23
|
browser: true,
|
|
20
|
-
|
|
21
|
-
serviceworker:
|
|
22
|
-
webextension:
|
|
24
|
+
sharedWorker: true,
|
|
25
|
+
serviceworker: true,
|
|
26
|
+
webextension: true,
|
|
27
|
+
audioWorklet: true,
|
|
28
|
+
vitest: false,
|
|
29
|
+
vue: true,
|
|
23
30
|
custom: {}
|
|
24
31
|
},
|
|
25
32
|
settings: {},
|
|
26
33
|
rules: {}
|
|
27
34
|
},
|
|
28
35
|
configs: {
|
|
29
|
-
oxlint: "
|
|
36
|
+
oxlint: ".oxlintrc.json",
|
|
30
37
|
base: {
|
|
31
38
|
maxDepth: 3,
|
|
32
39
|
maxNestedCallbacks: 3,
|
|
@@ -41,7 +48,6 @@ const defaultOptions = {
|
|
|
41
48
|
quotes: "single",
|
|
42
49
|
jsxQuotes: "prefer-double",
|
|
43
50
|
arrowParens: "always",
|
|
44
|
-
useTabs: true,
|
|
45
51
|
indent: 2,
|
|
46
52
|
maxConsecutiveEmptyLines: 1,
|
|
47
53
|
maxLineLength: 120,
|
|
@@ -80,6 +86,7 @@ const defaultOptions = {
|
|
|
80
86
|
sortType: "line-length",
|
|
81
87
|
overrides: {}
|
|
82
88
|
},
|
|
89
|
+
zod: { overrides: {} },
|
|
83
90
|
vue: {
|
|
84
91
|
accessibility: {
|
|
85
92
|
imageComponents: ["NuxtImg"],
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { defaultOptions } from "./defaultOptions.mjs";
|
|
2
1
|
import { isPackageDetected, logDetectedPackages } from "../isPackageDetected.mjs";
|
|
3
2
|
|
|
4
|
-
//#region src/
|
|
3
|
+
//#region src/helpers/options/enableDetectedConfigs.ts
|
|
5
4
|
function enableDetectedConfigs(options) {
|
|
6
5
|
options.configs ??= {};
|
|
7
6
|
options.configs.test ??= {};
|
|
@@ -14,11 +13,11 @@ function enableDetectedConfigs(options) {
|
|
|
14
13
|
options.configs.vue ??= isPackageDetected("vue", options);
|
|
15
14
|
options.configs.nuxt ??= isPackageDetected("nuxt", options);
|
|
16
15
|
options.configs.typescript ??= isPackageDetected("typescript", options);
|
|
16
|
+
options.configs.zod ??= isPackageDetected("zod", options);
|
|
17
17
|
options.configs.test.vitest ??= isPackageDetected("vitest", options);
|
|
18
18
|
options.configs.test.cypress ??= isPackageDetected("cypress", options);
|
|
19
19
|
options.configs.test.storybook ??= isPackageDetected("storybook", options);
|
|
20
20
|
options.configs.test.playwright ??= isPackageDetected("@playwright/test", options);
|
|
21
|
-
options.configs.oxlint ??= isPackageDetected("oxlint", options) ? defaultOptions.configs.oxlint : false;
|
|
22
21
|
options.tsConfig ??= options.configs.typescript ? {
|
|
23
22
|
rootDir: ".",
|
|
24
23
|
filename: "tsconfig.json"
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { defaultOptions } from "./defaultOptions.mjs";
|
|
2
|
-
import { isEmptyString } from "
|
|
2
|
+
import { isEmptyString } from "../../utils/isEmptyString.mjs";
|
|
3
3
|
import { enableDetectedConfigs } from "./enableDetectedConfigs.mjs";
|
|
4
4
|
import { createDefu } from "defu";
|
|
5
5
|
|
|
6
|
-
//#region src/
|
|
6
|
+
//#region src/helpers/options/mergeWithDefaults.ts
|
|
7
7
|
const mergeOptions = createDefu((object, key, value) => {
|
|
8
|
-
const stringKey = key.toString();
|
|
9
8
|
if ([
|
|
10
9
|
"allowedRelativeFontUnits",
|
|
11
|
-
"macrosOrder",
|
|
12
10
|
"blocksOrder",
|
|
11
|
+
"macrosOrder",
|
|
13
12
|
"attributesOrder"
|
|
14
|
-
].includes(
|
|
13
|
+
].includes(key.toString())) {
|
|
15
14
|
object[key] = value;
|
|
16
15
|
return true;
|
|
17
16
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isEnabled } from "./utils/isEnabled.mjs";
|
|
2
|
-
import { defaultOptions } from "./
|
|
2
|
+
import { defaultOptions } from "./helpers/options/defaultOptions.mjs";
|
|
3
3
|
import { getCSSConfig } from "./configs/css.mjs";
|
|
4
4
|
import { getVueConfig } from "./configs/vue.mjs";
|
|
5
|
+
import { getZodConfig } from "./configs/zod.mjs";
|
|
5
6
|
import { getBaseConfig } from "./configs/base.mjs";
|
|
6
7
|
import { getHTMLConfig } from "./configs/html.mjs";
|
|
7
8
|
import { getVitestConfig } from "./configs/vitest.mjs";
|
|
@@ -15,8 +16,8 @@ import { getTypeScriptConfig } from "./configs/typescript.mjs";
|
|
|
15
16
|
import { getPerfectionistConfig } from "./configs/perfectionist.mjs";
|
|
16
17
|
import { getRestrictedExports } from "./configs/restrictedExports.mjs";
|
|
17
18
|
import { getOXLintOverridesConfig } from "./configs/oxlintOverrides.mjs";
|
|
18
|
-
import { getIgnorePatterns } from "./
|
|
19
|
-
import { mergeWithDefaults } from "./
|
|
19
|
+
import { getIgnorePatterns } from "./helpers/ignores/getIgnorePatterns.mjs";
|
|
20
|
+
import { mergeWithDefaults } from "./helpers/options/mergeWithDefaults.mjs";
|
|
20
21
|
import { getVueComponentNamesConfig } from "./configs/vueComponentNames.mjs";
|
|
21
22
|
import { getVueServerComponentsConfig } from "./configs/vueServerComponents.mjs";
|
|
22
23
|
import eslintPluginOXLint from "eslint-plugin-oxlint";
|
|
@@ -34,7 +35,7 @@ import path from "node:path";
|
|
|
34
35
|
*/
|
|
35
36
|
function defineConfig(options = {}, ...configs) {
|
|
36
37
|
const mergedOptions = mergeWithDefaults(options);
|
|
37
|
-
const { gitignore, global: { rules, ignores, settings, linterOptions }, configs: {
|
|
38
|
+
const { gitignore, global: { rules, ignores, settings, linterOptions }, configs: { css, zod, vue, html, nuxt, oxlint, importX, tailwind, stylistic, typescript, perfectionist, base: { preferNamedExports }, test: { vitest, cypress, storybook, playwright } } } = mergedOptions;
|
|
38
39
|
const ignorePatterns = getIgnorePatterns({
|
|
39
40
|
gitignore,
|
|
40
41
|
patterns: ignores
|
|
@@ -57,6 +58,7 @@ function defineConfig(options = {}, ...configs) {
|
|
|
57
58
|
preferNamedExports && getRestrictedExports(),
|
|
58
59
|
isEnabled(stylistic) && getStylisticConfig(mergedOptions),
|
|
59
60
|
isEnabled(perfectionist) && getPerfectionistConfig(mergedOptions),
|
|
61
|
+
isEnabled(zod) && getZodConfig(mergedOptions),
|
|
60
62
|
isEnabled(tailwind) && getTailwindConfig(mergedOptions),
|
|
61
63
|
isEnabled(vue) && getVueConfig(mergedOptions),
|
|
62
64
|
isEnabled(vue) && getVueComponentNamesConfig(),
|