@shayanthenerd/eslint-config 0.24.0 → 0.25.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 CHANGED
@@ -461,7 +461,6 @@ _.vscode/settings.json_:
461
461
  functionStyle?: 'expression' | 'declaration',
462
462
  maxDepth?: number,
463
463
  maxNestedCallbacks?: number,
464
- preferNamedExports?: boolean,
465
464
  overrides?: Overrides,
466
465
  },
467
466
  css?: boolean | {
@@ -3,16 +3,6 @@ const srcExtensions = "?([mc])[jt]s?(x)";
3
3
  const vueExtensions = `{vue,${srcExtensions}}`;
4
4
  const globs = {
5
5
  src: `**/*.${srcExtensions}`,
6
- restrictedDefaultExports: `**/{${[
7
- "shared",
8
- "dto?(s)",
9
- "model?(s)",
10
- "helper?(s)",
11
- "module?(s)",
12
- "util?(s|ities)",
13
- "composable?(s)",
14
- "repo?(s|sitory|sitories)"
15
- ].join(",")}}/**/*.${srcExtensions}`,
16
6
  packageJson: "**/package.json",
17
7
  markdown: "**/*.md",
18
8
  html: "**/*.html",
@@ -7,7 +7,7 @@ const detectedPackages = [];
7
7
  function logDetectedPackages() {
8
8
  if (detectedPackages.length > 0) {
9
9
  detectedPackages.sort();
10
- console.info(styleText("green", "✔"), "Automatic dependency detection enabled ESLint configurations for", `${detectedPackages.map((packageName) => styleText("blue", packageName)).join(", ")}.`);
10
+ console.info(`${styleText("green", "✔")} Active ESLint integrations:`, detectedPackages.map((packageName) => styleText("blue", packageName)).join(", "));
11
11
  }
12
12
  }
13
13
  function isPackageDetected(packageName, options) {
@@ -4,7 +4,6 @@ const defaultOptions = {
4
4
  env: "node",
5
5
  gitignore: ".gitignore",
6
6
  packageDir: ".",
7
- tsConfig: false,
8
7
  project: {
9
8
  basePath: ".",
10
9
  globals: {
@@ -39,7 +38,6 @@ const defaultOptions = {
39
38
  functionStyle: "declaration",
40
39
  maxDepth: 3,
41
40
  maxNestedCallbacks: 3,
42
- preferNamedExports: true,
43
41
  overrides: {}
44
42
  },
45
43
  css: {
@@ -104,7 +102,7 @@ const defaultOptions = {
104
102
  typescript: {
105
103
  allowedDefaultProjects: [],
106
104
  methodSignatureStyle: "method",
107
- removeUnusedImports: true,
105
+ removeUnusedImports: false,
108
106
  typeDefinitionStyle: "interface",
109
107
  overrides: {}
110
108
  },
@@ -1,6 +1,20 @@
1
1
  import { isPackageDetected, logDetectedPackages } from "../isPackageDetected.mjs";
2
2
  //#region src/helpers/options/enableDetectedConfigs.ts
3
3
  function enableDetectedConfigs(options) {
4
+ const autoDetectedDeps = {
5
+ typescript: isPackageDetected("typescript", options),
6
+ zod: isPackageDetected("zod", options),
7
+ astro: isPackageDetected("astro", options),
8
+ vue: isPackageDetected("vue", options),
9
+ nuxt: isPackageDetected("nuxt", options),
10
+ nuxtUI: isPackageDetected("@nuxt/ui", options),
11
+ nuxtIcon: isPackageDetected("@nuxt/icon", options),
12
+ nuxtImage: isPackageDetected("@nuxt/image", options),
13
+ vitest: isPackageDetected("vitest", options),
14
+ cypress: isPackageDetected("cypress", options),
15
+ storybook: isPackageDetected("storybook", options),
16
+ playwright: isPackageDetected("@playwright/test", options)
17
+ };
4
18
  options.configs ??= {};
5
19
  options.configs.test ??= {};
6
20
  options.configs.node ??= true;
@@ -13,28 +27,28 @@ function enableDetectedConfigs(options) {
13
27
  options.configs.importX ??= true;
14
28
  options.configs.stylistic ??= true;
15
29
  options.configs.perfectionist ??= true;
16
- options.configs.vue ??= isPackageDetected("vue", options);
17
- options.configs.nuxt ??= isPackageDetected("nuxt", options);
18
- options.configs.astro ??= isPackageDetected("astro", options);
19
- options.configs.typescript ??= isPackageDetected("typescript", options);
20
- options.configs.zod ??= isPackageDetected("zod", options);
21
- options.configs.test.vitest ??= isPackageDetected("vitest", options);
22
- options.configs.test.cypress ??= isPackageDetected("cypress", options);
23
- options.configs.test.storybook ??= isPackageDetected("storybook", options);
24
- options.configs.test.playwright ??= isPackageDetected("@playwright/test", options);
30
+ options.configs.typescript ??= autoDetectedDeps.typescript;
31
+ options.configs.zod ??= autoDetectedDeps.zod;
32
+ options.configs.vue ??= autoDetectedDeps.vue;
33
+ options.configs.nuxt ??= autoDetectedDeps.nuxt;
34
+ options.configs.astro ??= autoDetectedDeps.astro;
35
+ options.configs.test.vitest ??= autoDetectedDeps.vitest;
36
+ options.configs.test.cypress ??= autoDetectedDeps.cypress;
37
+ options.configs.test.storybook ??= autoDetectedDeps.storybook;
38
+ options.configs.test.playwright ??= autoDetectedDeps.playwright;
25
39
  options.tsConfig ??= options.configs.typescript ? {
26
40
  rootDir: ".",
27
41
  filename: "tsconfig.json"
28
- } : false;
29
- if (options.configs.typescript && options.configs.vue) {
42
+ } : void 0;
43
+ if (options.configs.vue && options.configs.typescript) {
30
44
  options.configs.vue = options.configs.vue === true ? {} : options.configs.vue;
31
45
  options.configs.vue.blockLang = { script: "ts" };
32
46
  }
33
47
  if (options.configs.nuxt) {
34
48
  if (options.configs.nuxt === true) options.configs.nuxt = {};
35
- options.configs.nuxt.ui ??= isPackageDetected("@nuxt/ui", options);
36
- options.configs.nuxt.icon ??= isPackageDetected("@nuxt/icon", options);
37
- options.configs.nuxt.image ??= isPackageDetected("@nuxt/image", options);
49
+ options.configs.nuxt.ui ??= autoDetectedDeps.nuxtUI;
50
+ options.configs.nuxt.icon ??= autoDetectedDeps.nuxtIcon;
51
+ options.configs.nuxt.image ??= autoDetectedDeps.nuxtImage;
38
52
  }
39
53
  if (options.autoDetectDeps === "verbose") logDetectedPackages();
40
54
  return options;
package/dist/index.mjs CHANGED
@@ -24,7 +24,6 @@ import { getIgnorePatterns } from "./helpers/ignores/getIgnorePatterns.mjs";
24
24
  import { mergeWithDefaults } from "./helpers/options/mergeWithDefaults.mjs";
25
25
  import { getVueComponentNamesConfig } from "./configs/vueComponentNames.mjs";
26
26
  import { getVueServerComponentsConfig } from "./configs/vueServerComponents.mjs";
27
- import { getRestrictedDefaultExports } from "./configs/restrictedDefaultExports.mjs";
28
27
  import { defineConfig as defineConfig$1, globalIgnores } from "eslint/config";
29
28
  //#region src/index.ts
30
29
  /**
@@ -71,7 +70,7 @@ function defineConfig(...args) {
71
70
  configs = secondArgument ?? [];
72
71
  }
73
72
  const mergedOptions = mergeWithDefaults(options);
74
- const { gitignore, project: { rules, ignores, settings, linterOptions }, configs: { css, vue, zod, html, node, nuxt, astro, unicorn, importX, promise, markdown, tailwind, stylistic, typescript, packageJson, perfectionist, base: { preferNamedExports }, test: { vitest, cypress, storybook, playwright } } } = mergedOptions;
73
+ const { gitignore, project: { rules, ignores, settings, linterOptions }, configs: { css, vue, zod, html, node, nuxt, astro, unicorn, importX, promise, markdown, tailwind, stylistic, typescript, packageJson, perfectionist, test: { vitest, cypress, storybook, playwright } } } = mergedOptions;
75
74
  const ignorePatterns = getIgnorePatterns({
76
75
  gitignore,
77
76
  patterns: ignores
@@ -89,7 +88,6 @@ function defineConfig(...args) {
89
88
  isEnabled(unicorn) && getUnicornConfig(mergedOptions),
90
89
  isEnabled(promise) && getPromiseConfig(mergedOptions),
91
90
  isEnabled(importX) && getImportXConfig(mergedOptions),
92
- preferNamedExports && getRestrictedDefaultExports(),
93
91
  isEnabled(stylistic) && getStylisticConfig(mergedOptions),
94
92
  isEnabled(perfectionist) && getPerfectionistConfig(mergedOptions),
95
93
  isEnabled(node) && getNodeConfig(mergedOptions),
@@ -198,7 +198,7 @@ function getJavaScriptRules(options) {
198
198
  "no-useless-rename": "error",
199
199
  "no-useless-return": "error",
200
200
  "no-var": "error",
201
- "no-void": "error",
201
+ "no-void": ["error", { allowAsStatement: true }],
202
202
  "no-with": "error",
203
203
  "object-shorthand": "warn",
204
204
  "operator-assignment": "error",
@@ -37,10 +37,6 @@ const packageJsonRules = {
37
37
  "funding"
38
38
  ] }],
39
39
  "package-json/restrict-top-level-properties": ["warn", { ban: [
40
- {
41
- property: "packageManager",
42
- message: "use `devEngines.packageManager`."
43
- },
44
40
  {
45
41
  property: "bun",
46
42
  message: "use bunfig.toml."
@@ -110,7 +110,6 @@ function getTypeScriptRules(options) {
110
110
  requireDefaultForNonUnion: true,
111
111
  considerDefaultExhaustiveForUnions: true
112
112
  }],
113
- "@typescript-eslint/explicit-module-boundary-types": "warn",
114
113
  "@typescript-eslint/no-unused-private-class-members": "error",
115
114
  "@typescript-eslint/no-unnecessary-parameter-property-assignment": "warn",
116
115
  "@typescript-eslint/method-signature-style": ["warn", methodSignatureStyle],
@@ -80,20 +80,16 @@ interface Options {
80
80
  /**
81
81
  * The path and the name of the root TypeScript config file.
82
82
  *
83
- * If you don't use TypeScript, provide the path and the name of the root JavaScript config file.
84
- *
85
83
  * This is used by
86
84
  * - [better-tailwindcss: `tsconfig` option](https://github.com/schoero/eslint-plugin-better-tailwindcss/blob/main/docs/settings/settings.md#tsconfig)
87
85
  * - [perfectionist/sort-imports: `tsconfig` option](https://perfectionist.dev/rules/sort-imports#tsconfig)
88
86
  *
89
- * @default undefined // `{ rootDir: '.', filename: 'tsconfig.json' }` if "typescript" is detected in the dependencies when `autoDetectDeps` is enabled
87
+ * @default undefined // `{ rootDir: '.', filename: 'tsconfig.json' }` if TypeScript integration is enabled
90
88
  */
91
89
  tsConfig?: false | {
92
90
  /**
93
91
  * The name of the root TypeScript config file.
94
92
  *
95
- * If you don't use TypeScript, provide the name of the root JavaScript config file.
96
- *
97
93
  * It will fall back to the default value if set to an empty string (`''`).
98
94
  *
99
95
  * @default 'tsconfig.json'
@@ -101,8 +97,6 @@ interface Options {
101
97
  filename?: string;
102
98
  /**
103
99
  * The directory of the root TypeScript config file.
104
- *
105
- * If you don't use TypeScript, provide the directory of the root JavaScript config file.
106
100
  *
107
101
  * It will fall back to the default value if set to an empty string (`''`).
108
102
  *
@@ -31,22 +31,6 @@ interface BaseOptions extends ConfigWithOverrides<CoreRules> {
31
31
  * @see [max-nested-callbacks](https://eslint.org/docs/latest/rules/max-nested-callbacks)
32
32
  */
33
33
  maxNestedCallbacks?: Exclude<MaxNestedCallbacksOptions, Record<string, unknown>>;
34
- /**
35
- * Enforce named exports in the following directories:
36
- * - shared
37
- * - dto, dtos
38
- * - model, models
39
- * - helper, helpers
40
- * - module, modules
41
- * - util, utils, utilities
42
- * - composable, composables
43
- * - repo, repos, repository, repositories
44
- *
45
- * @default true
46
- *
47
- * @see [no-restricted-exports: `restrictDefaultExports` option](https://eslint.org/docs/latest/rules/no-restricted-exports#options)
48
- */
49
- preferNamedExports?: boolean;
50
34
  }
51
35
  //#endregion
52
36
  export type { BaseOptions };
@@ -29,7 +29,7 @@ interface TypeScriptOptions extends ConfigWithOverrides<ConfigRules> {
29
29
  *
30
30
  * If set to `false`, unused imports will only be reported.
31
31
  *
32
- * @default true
32
+ * @default false
33
33
  *
34
34
  * @see [@typescript-eslint/no-unused-vars: `enableAutofixRemoval.imports` option](https://typescript-eslint.io/rules/no-unused-vars/#enableautofixremovalimports)
35
35
  */
@@ -65,7 +65,7 @@ interface VueOptions extends ConfigWithOverrides<ConfigRules> {
65
65
  *
66
66
  * @default
67
67
  * {
68
- * script: 'js', // `'ts'` if "typescript" is detected in the dependencies when `autoDetectDeps` is enabled
68
+ * script: 'js', // `'ts'` if TypeScript integration is enabled
69
69
  * style: 'implicit',
70
70
  * }
71
71
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shayanthenerd/eslint-config",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "description": "A modern, flexible ESLint configuration for enforcing best practices and maintaining a consistent coding style",
5
5
  "keywords": [
6
6
  "eslint",
@@ -76,6 +76,7 @@
76
76
  "eslint-plugin-vue": "10.9.2",
77
77
  "eslint-plugin-vuejs-accessibility": "2.5.0",
78
78
  "eslint-plugin-zod": "4.7.0",
79
+ "eslint-plugin-zod-mini": "1.4.0",
79
80
  "globals": "17.6.0",
80
81
  "local-pkg": "1.2.1",
81
82
  "tailwind-csstree": "0.3.3",
@@ -86,8 +87,7 @@
86
87
  "@eslint/config-inspector": "3.0.4",
87
88
  "@types/node": "25.9.3",
88
89
  "actions-up": "1.14.2",
89
- "eslint": "10.4.1",
90
- "eslint-plugin-zod-mini": "1.4.0",
90
+ "eslint": "10.5.0",
91
91
  "eslint-typegen": "2.3.1",
92
92
  "nano-staged": "1.0.2",
93
93
  "prettier": "3.8.4",
@@ -113,7 +113,7 @@
113
113
  },
114
114
  "packageManager": {
115
115
  "name": "pnpm",
116
- "version": "^11.0.0",
116
+ "version": "11.6.0",
117
117
  "onFail": "warn"
118
118
  }
119
119
  },
@@ -1,16 +0,0 @@
1
- import { globs } from "../helpers/globs.mjs";
2
- //#region src/configs/restrictedDefaultExports.ts
3
- function getRestrictedDefaultExports() {
4
- return {
5
- name: "shayanthenerd/restrict-default-exports",
6
- files: [globs.restrictedDefaultExports],
7
- rules: { "no-restricted-exports": ["error", { restrictDefaultExports: {
8
- named: true,
9
- direct: true,
10
- namedFrom: true,
11
- namespaceFrom: true
12
- } }] }
13
- };
14
- }
15
- //#endregion
16
- export { getRestrictedDefaultExports };