@dhzh/eslint-config 0.12.3 → 0.12.4

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/cli.cjs CHANGED
@@ -48,8 +48,8 @@ var import_picocolors = __toESM(require("picocolors"), 1);
48
48
  var package_default = {
49
49
  name: "@dhzh/eslint-config",
50
50
  type: "module",
51
- version: "0.12.3",
52
- packageManager: "pnpm@9.7.1",
51
+ version: "0.12.4",
52
+ packageManager: "pnpm@9.8.0",
53
53
  description: "Easton's ESLint config",
54
54
  author: "Easton Zheng <dhzhme@gmail.com>",
55
55
  license: "MIT",
@@ -77,7 +77,7 @@ var package_default = {
77
77
  dev: "npx @eslint/config-inspector --config eslint.config.ts",
78
78
  "build:inspector": "pnpm build && npx @eslint/config-inspector build",
79
79
  watch: "tsup --format esm,cjs --watch",
80
- lint: "eslint .",
80
+ lint: "eslint --flag unstable_ts_config .",
81
81
  typegen: "esno scripts/typegen.ts",
82
82
  prepack: "nr build",
83
83
  release: "bumpp && pnpm publish --access=public",
@@ -130,18 +130,18 @@ var package_default = {
130
130
  }
131
131
  },
132
132
  dependencies: {
133
- "@antfu/install-pkg": "^0.3.5",
133
+ "@antfu/install-pkg": "^0.4.0",
134
134
  "@clack/prompts": "^0.7.0",
135
135
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
136
- "@eslint-react/eslint-plugin": "^1.10.1",
136
+ "@eslint-react/eslint-plugin": "^1.12.1",
137
137
  "@stylistic/eslint-plugin": "^2.6.4",
138
- "@typescript-eslint/eslint-plugin": "^8.1.0",
139
- "@typescript-eslint/parser": "^8.1.0",
138
+ "@typescript-eslint/eslint-plugin": "^8.2.0",
139
+ "@typescript-eslint/parser": "^8.2.0",
140
140
  "@vitest/eslint-plugin": "^1.0.3",
141
141
  "eslint-config-flat-gitignore": "^0.1.8",
142
- "eslint-flat-config-utils": "^0.3.0",
142
+ "eslint-flat-config-utils": "^0.3.1",
143
143
  "eslint-merge-processors": "^0.1.0",
144
- "eslint-plugin-antfu": "^2.3.5",
144
+ "eslint-plugin-antfu": "^2.3.6",
145
145
  "eslint-plugin-command": "^0.2.3",
146
146
  "eslint-plugin-import-x": "^3.1.0",
147
147
  "eslint-plugin-jsdoc": "^50.2.2",
@@ -151,7 +151,7 @@ var package_default = {
151
151
  "eslint-plugin-no-only-tests": "^3.3.0",
152
152
  "eslint-plugin-perfectionist": "^3.2.0",
153
153
  "eslint-plugin-react-hooks": "^4.6.2",
154
- "eslint-plugin-react-refresh": "^0.4.9",
154
+ "eslint-plugin-react-refresh": "^0.4.11",
155
155
  "eslint-plugin-regexp": "^2.6.0",
156
156
  "eslint-plugin-toml": "^0.11.1",
157
157
  "eslint-plugin-unicorn": "^55.0.0",
@@ -171,29 +171,29 @@ var package_default = {
171
171
  },
172
172
  devDependencies: {
173
173
  "@antfu/ni": "^0.22.4",
174
- "@eslint/config-inspector": "^0.5.3",
174
+ "@eslint/config-inspector": "^0.5.4",
175
175
  "@prettier/plugin-xml": "^3.4.1",
176
176
  "@stylistic/eslint-plugin-migrate": "^2.6.4",
177
177
  "@types/eslint": "^9.6.0",
178
178
  "@types/fs-extra": "^11.0.4",
179
- "@types/node": "^22.3.0",
179
+ "@types/node": "^22.5.0",
180
180
  "@types/prompts": "^2.4.9",
181
181
  "@types/yargs": "^17.0.33",
182
182
  "@unocss/eslint-plugin": "^0.62.2",
183
183
  "astro-eslint-parser": "^1.0.2",
184
- bumpp: "^9.5.1",
184
+ bumpp: "^9.5.2",
185
185
  "bundle-require": "^5.0.0",
186
- eslint: "npm:eslint-ts-patch@9.5.0-0",
186
+ eslint: "^9.9.0",
187
187
  "eslint-plugin-astro": "^1.2.3",
188
188
  "eslint-plugin-format": "^0.1.2",
189
- "eslint-plugin-solid": "^0.14.1",
189
+ "eslint-plugin-solid": "^0.14.2",
190
190
  "eslint-plugin-svelte": "^2.43.0",
191
- "eslint-ts-patch": "9.5.0-0",
192
191
  "eslint-typegen": "^0.3.1",
193
192
  esno: "^4.7.0",
194
193
  execa: "^9.3.1",
195
194
  "fast-glob": "^3.3.2",
196
195
  "fs-extra": "^11.2.0",
196
+ jiti: "^1.21.6",
197
197
  "lint-staged": "^15.2.9",
198
198
  "prettier-plugin-astro": "^0.14.1",
199
199
  "prettier-plugin-slidev": "^1.0.5",
@@ -209,14 +209,14 @@ var package_default = {
209
209
  },
210
210
  resolutions: {
211
211
  "@eslint-community/eslint-utils": "^4.4.0",
212
- "@typescript-eslint/utils": "^8.1.0",
212
+ "@typescript-eslint/utils": "^8.2.0",
213
213
  tsx: "~4.17.0"
214
214
  },
215
215
  "simple-git-hooks": {
216
216
  "pre-commit": "npx lint-staged"
217
217
  },
218
218
  "lint-staged": {
219
- "*": "eslint --fix"
219
+ "*": "eslint --flag unstable_ts_config --fix"
220
220
  }
221
221
  };
222
222
 
package/dist/cli.js CHANGED
@@ -19,8 +19,8 @@ import c from "picocolors";
19
19
  var package_default = {
20
20
  name: "@dhzh/eslint-config",
21
21
  type: "module",
22
- version: "0.12.3",
23
- packageManager: "pnpm@9.7.1",
22
+ version: "0.12.4",
23
+ packageManager: "pnpm@9.8.0",
24
24
  description: "Easton's ESLint config",
25
25
  author: "Easton Zheng <dhzhme@gmail.com>",
26
26
  license: "MIT",
@@ -48,7 +48,7 @@ var package_default = {
48
48
  dev: "npx @eslint/config-inspector --config eslint.config.ts",
49
49
  "build:inspector": "pnpm build && npx @eslint/config-inspector build",
50
50
  watch: "tsup --format esm,cjs --watch",
51
- lint: "eslint .",
51
+ lint: "eslint --flag unstable_ts_config .",
52
52
  typegen: "esno scripts/typegen.ts",
53
53
  prepack: "nr build",
54
54
  release: "bumpp && pnpm publish --access=public",
@@ -101,18 +101,18 @@ var package_default = {
101
101
  }
102
102
  },
103
103
  dependencies: {
104
- "@antfu/install-pkg": "^0.3.5",
104
+ "@antfu/install-pkg": "^0.4.0",
105
105
  "@clack/prompts": "^0.7.0",
106
106
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
107
- "@eslint-react/eslint-plugin": "^1.10.1",
107
+ "@eslint-react/eslint-plugin": "^1.12.1",
108
108
  "@stylistic/eslint-plugin": "^2.6.4",
109
- "@typescript-eslint/eslint-plugin": "^8.1.0",
110
- "@typescript-eslint/parser": "^8.1.0",
109
+ "@typescript-eslint/eslint-plugin": "^8.2.0",
110
+ "@typescript-eslint/parser": "^8.2.0",
111
111
  "@vitest/eslint-plugin": "^1.0.3",
112
112
  "eslint-config-flat-gitignore": "^0.1.8",
113
- "eslint-flat-config-utils": "^0.3.0",
113
+ "eslint-flat-config-utils": "^0.3.1",
114
114
  "eslint-merge-processors": "^0.1.0",
115
- "eslint-plugin-antfu": "^2.3.5",
115
+ "eslint-plugin-antfu": "^2.3.6",
116
116
  "eslint-plugin-command": "^0.2.3",
117
117
  "eslint-plugin-import-x": "^3.1.0",
118
118
  "eslint-plugin-jsdoc": "^50.2.2",
@@ -122,7 +122,7 @@ var package_default = {
122
122
  "eslint-plugin-no-only-tests": "^3.3.0",
123
123
  "eslint-plugin-perfectionist": "^3.2.0",
124
124
  "eslint-plugin-react-hooks": "^4.6.2",
125
- "eslint-plugin-react-refresh": "^0.4.9",
125
+ "eslint-plugin-react-refresh": "^0.4.11",
126
126
  "eslint-plugin-regexp": "^2.6.0",
127
127
  "eslint-plugin-toml": "^0.11.1",
128
128
  "eslint-plugin-unicorn": "^55.0.0",
@@ -142,29 +142,29 @@ var package_default = {
142
142
  },
143
143
  devDependencies: {
144
144
  "@antfu/ni": "^0.22.4",
145
- "@eslint/config-inspector": "^0.5.3",
145
+ "@eslint/config-inspector": "^0.5.4",
146
146
  "@prettier/plugin-xml": "^3.4.1",
147
147
  "@stylistic/eslint-plugin-migrate": "^2.6.4",
148
148
  "@types/eslint": "^9.6.0",
149
149
  "@types/fs-extra": "^11.0.4",
150
- "@types/node": "^22.3.0",
150
+ "@types/node": "^22.5.0",
151
151
  "@types/prompts": "^2.4.9",
152
152
  "@types/yargs": "^17.0.33",
153
153
  "@unocss/eslint-plugin": "^0.62.2",
154
154
  "astro-eslint-parser": "^1.0.2",
155
- bumpp: "^9.5.1",
155
+ bumpp: "^9.5.2",
156
156
  "bundle-require": "^5.0.0",
157
- eslint: "npm:eslint-ts-patch@9.5.0-0",
157
+ eslint: "^9.9.0",
158
158
  "eslint-plugin-astro": "^1.2.3",
159
159
  "eslint-plugin-format": "^0.1.2",
160
- "eslint-plugin-solid": "^0.14.1",
160
+ "eslint-plugin-solid": "^0.14.2",
161
161
  "eslint-plugin-svelte": "^2.43.0",
162
- "eslint-ts-patch": "9.5.0-0",
163
162
  "eslint-typegen": "^0.3.1",
164
163
  esno: "^4.7.0",
165
164
  execa: "^9.3.1",
166
165
  "fast-glob": "^3.3.2",
167
166
  "fs-extra": "^11.2.0",
167
+ jiti: "^1.21.6",
168
168
  "lint-staged": "^15.2.9",
169
169
  "prettier-plugin-astro": "^0.14.1",
170
170
  "prettier-plugin-slidev": "^1.0.5",
@@ -180,14 +180,14 @@ var package_default = {
180
180
  },
181
181
  resolutions: {
182
182
  "@eslint-community/eslint-utils": "^4.4.0",
183
- "@typescript-eslint/utils": "^8.1.0",
183
+ "@typescript-eslint/utils": "^8.2.0",
184
184
  tsx: "~4.17.0"
185
185
  },
186
186
  "simple-git-hooks": {
187
187
  "pre-commit": "npx lint-staged"
188
188
  },
189
189
  "lint-staged": {
190
- "*": "eslint --fix"
190
+ "*": "eslint --flag unstable_ts_config --fix"
191
191
  }
192
192
  };
193
193
 
package/dist/index.cjs CHANGED
@@ -74,6 +74,7 @@ __export(src_exports, {
74
74
  imports: () => imports,
75
75
  interopDefault: () => interopDefault,
76
76
  isInEditorEnv: () => isInEditorEnv,
77
+ isInGitHooksOrLintStaged: () => isInGitHooksOrLintStaged,
77
78
  isPackageInScope: () => isPackageInScope,
78
79
  javascript: () => javascript,
79
80
  jsdoc: () => jsdoc,
@@ -279,8 +280,17 @@ async function ensurePackages(packages) {
279
280
  await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
280
281
  }
281
282
  }
283
+ function isInGitHooksOrLintStaged() {
284
+ return !!(import_node_process.default.env.GIT_PARAMS || import_node_process.default.env.VSCODE_GIT_COMMAND || import_node_process.default.env.npm_lifecycle_script?.startsWith("lint-staged"));
285
+ }
282
286
  function isInEditorEnv() {
283
- return !!((import_node_process.default.env.VSCODE_PID || import_node_process.default.env.VSCODE_CWD || import_node_process.default.env.JETBRAINS_IDE || import_node_process.default.env.VIM || import_node_process.default.env.NVIM) && !import_node_process.default.env.CI);
287
+ if (import_node_process.default.env.CI) {
288
+ return false;
289
+ }
290
+ if (isInGitHooksOrLintStaged()) {
291
+ return false;
292
+ }
293
+ return !!(import_node_process.default.env.VSCODE_PID || import_node_process.default.env.VSCODE_CWD || import_node_process.default.env.JETBRAINS_IDE || import_node_process.default.env.VIM || import_node_process.default.env.NVIM);
284
294
  }
285
295
 
286
296
  // src/configs/astro.ts
@@ -1884,6 +1894,7 @@ async function typescript(options = {}) {
1884
1894
  const {
1885
1895
  componentExts = [],
1886
1896
  overrides = {},
1897
+ overridesTypeAware = {},
1887
1898
  parserOptions = {},
1888
1899
  type = "app"
1889
1900
  } = options;
@@ -2018,7 +2029,10 @@ async function typescript(options = {}) {
2018
2029
  files: filesTypeAware,
2019
2030
  ignores: ignoresTypeAware,
2020
2031
  name: "antfu/typescript/rules-type-aware",
2021
- rules: typeAwareRules
2032
+ rules: {
2033
+ ...typeAwareRules,
2034
+ ...overridesTypeAware
2035
+ }
2022
2036
  }] : [],
2023
2037
  {
2024
2038
  files: ["**/*.d.?([cm])ts"],
@@ -2409,7 +2423,6 @@ function dhzh(options = {}, ...userConfigs) {
2409
2423
  autoRenamePlugins = true,
2410
2424
  componentExts = [],
2411
2425
  gitignore: enableGitignore = true,
2412
- isInEditor = isInEditorEnv(),
2413
2426
  jsx: enableJsx = true,
2414
2427
  react: enableReact = false,
2415
2428
  regexp: enableRegexp = true,
@@ -2419,6 +2432,13 @@ function dhzh(options = {}, ...userConfigs) {
2419
2432
  unocss: enableUnoCSS = false,
2420
2433
  vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
2421
2434
  } = options;
2435
+ let isInEditor = options.isInEditor;
2436
+ if (isInEditor == null) {
2437
+ isInEditor = isInEditorEnv();
2438
+ if (isInEditor) {
2439
+ console.log("[@antfu/eslint-config] Detected running in editor, some rules are disabled.");
2440
+ }
2441
+ }
2422
2442
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2423
2443
  if (stylisticOptions && !("jsx" in stylisticOptions)) {
2424
2444
  stylisticOptions.jsx = enableJsx;
@@ -2637,6 +2657,7 @@ var src_default = dhzh;
2637
2657
  imports,
2638
2658
  interopDefault,
2639
2659
  isInEditorEnv,
2660
+ isInGitHooksOrLintStaged,
2640
2661
  isPackageInScope,
2641
2662
  javascript,
2642
2663
  jsdoc,
package/dist/index.d.cts CHANGED
@@ -3007,12 +3007,12 @@ interface RuleOptions {
3007
3007
  'react-naming-convention/use-state'?: Linter.RuleEntry<[]>
3008
3008
  'react-refresh/only-export-components'?: Linter.RuleEntry<ReactRefreshOnlyExportComponents>
3009
3009
  /**
3010
- * avoid using shorthand boolean attribute
3010
+ * disallow using shorthand boolean attributes
3011
3011
  * @see https://eslint-react.xyz/docs/rules/avoid-shorthand-boolean
3012
3012
  */
3013
3013
  'react/avoid-shorthand-boolean'?: Linter.RuleEntry<[]>
3014
3014
  /**
3015
- * avoid using shorthand fragment syntax
3015
+ * disallow using shorthand fragment syntax
3016
3016
  * @see https://eslint-react.xyz/docs/rules/avoid-shorthand-fragment
3017
3017
  */
3018
3018
  'react/avoid-shorthand-fragment'?: Linter.RuleEntry<[]>
@@ -5676,7 +5676,7 @@ interface RuleOptions {
5676
5676
  */
5677
5677
  'ts/unified-signatures'?: Linter.RuleEntry<TsUnifiedSignatures>
5678
5678
  /**
5679
- * Enforce typing arguments in `.catch()` callbacks as `unknown`
5679
+ * Enforce typing arguments in Promise rejection callbacks as `unknown`
5680
5680
  * @see https://typescript-eslint.io/rules/use-unknown-in-catch-callback-variable
5681
5681
  */
5682
5682
  'ts/use-unknown-in-catch-callback-variable'?: Linter.RuleEntry<[]>
@@ -7801,24 +7801,25 @@ type AccessorPairs = []|[{
7801
7801
  // ----- antfu/consistent-list-newline -----
7802
7802
  type AntfuConsistentListNewline = []|[{
7803
7803
  ArrayExpression?: boolean
7804
+ ArrayPattern?: boolean
7804
7805
  ArrowFunctionExpression?: boolean
7805
7806
  CallExpression?: boolean
7806
7807
  ExportNamedDeclaration?: boolean
7807
7808
  FunctionDeclaration?: boolean
7808
7809
  FunctionExpression?: boolean
7809
7810
  ImportDeclaration?: boolean
7811
+ JSONArrayExpression?: boolean
7812
+ JSONObjectExpression?: boolean
7813
+ JSXOpeningElement?: boolean
7810
7814
  NewExpression?: boolean
7811
7815
  ObjectExpression?: boolean
7816
+ ObjectPattern?: boolean
7817
+ TSFunctionType?: boolean
7812
7818
  TSInterfaceDeclaration?: boolean
7813
7819
  TSTupleType?: boolean
7814
7820
  TSTypeLiteral?: boolean
7815
7821
  TSTypeParameterDeclaration?: boolean
7816
7822
  TSTypeParameterInstantiation?: boolean
7817
- ObjectPattern?: boolean
7818
- ArrayPattern?: boolean
7819
- JSXOpeningElement?: boolean
7820
- JSONArrayExpression?: boolean
7821
- JSONObjectExpression?: boolean
7822
7823
  }]
7823
7824
  // ----- antfu/indent-unindent -----
7824
7825
  type AntfuIndentUnindent = []|[{
@@ -9825,18 +9826,11 @@ type NoRestrictedImports = ((string | {
9825
9826
  importNames?: string[]
9826
9827
  allowImportNames?: string[]
9827
9828
  })[]
9828
- patterns?: (string[] | {
9829
-
9830
- importNames?: [string, ...(string)[]]
9831
-
9832
- allowImportNames?: [string, ...(string)[]]
9833
-
9834
- group: [string, ...(string)[]]
9835
- importNamePattern?: string
9836
- allowImportNamePattern?: string
9837
- message?: string
9838
- caseSensitive?: boolean
9839
- }[])
9829
+ patterns?: (string[] | ({
9830
+ [k: string]: unknown | undefined
9831
+ } | {
9832
+ [k: string]: unknown | undefined
9833
+ })[])
9840
9834
  }])
9841
9835
  // ----- no-restricted-modules -----
9842
9836
  type NoRestrictedModules = ((string | {
@@ -10679,6 +10673,9 @@ type ReactHooksExhaustiveDeps = []|[{
10679
10673
  }]
10680
10674
  // ----- react-naming-convention/component-name -----
10681
10675
  type ReactNamingConventionComponentName = []|[(("PascalCase" | "CONSTANT_CASE") | {
10676
+ allowAllCaps?: boolean
10677
+ allowLeadingUnderscore?: boolean
10678
+ allowNamespace?: boolean
10682
10679
  excepts?: string[]
10683
10680
  rule?: ("PascalCase" | "CONSTANT_CASE")
10684
10681
  })]
@@ -12978,7 +12975,8 @@ type TsNoRestrictedImports = ((string | {
12978
12975
 
12979
12976
  allowImportNames?: [string, ...(string)[]]
12980
12977
 
12981
- group: [string, ...(string)[]]
12978
+ group?: [string, ...(string)[]]
12979
+ regex?: string
12982
12980
  importNamePattern?: string
12983
12981
  allowImportNamePattern?: string
12984
12982
  message?: string
@@ -15057,6 +15055,10 @@ interface OptionsTypeScriptWithTypes {
15057
15055
  * @see https://typescript-eslint.io/linting/typed-linting/
15058
15056
  */
15059
15057
  tsconfigPath?: string;
15058
+ /**
15059
+ * Override type aware rules.
15060
+ */
15061
+ overridesTypeAware?: TypedFlatConfigItem['rules'];
15060
15062
  }
15061
15063
  interface OptionsHasTypeScript {
15062
15064
  typescript?: boolean;
@@ -15480,6 +15482,7 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
15480
15482
  } ? U : T>;
15481
15483
  declare function isPackageInScope(name: string): boolean;
15482
15484
  declare function ensurePackages(packages: (string | undefined)[]): Promise<void>;
15485
+ declare function isInGitHooksOrLintStaged(): boolean;
15483
15486
  declare function isInEditorEnv(): boolean;
15484
15487
 
15485
- export { type Awaitable, type ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsProjectType, type OptionsRegExp, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type ResolvedOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type StylisticOptions, type TypedFlatConfigItem, astro, combine, command, comments, dhzh as default, defaultPluginRenaming, dhzh, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, node, parserPlain, perfectionist, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
15488
+ export { type Awaitable, type ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsProjectType, type OptionsRegExp, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type ResolvedOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type StylisticOptions, type TypedFlatConfigItem, astro, combine, command, comments, dhzh as default, defaultPluginRenaming, dhzh, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, node, parserPlain, perfectionist, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
package/dist/index.d.ts CHANGED
@@ -3007,12 +3007,12 @@ interface RuleOptions {
3007
3007
  'react-naming-convention/use-state'?: Linter.RuleEntry<[]>
3008
3008
  'react-refresh/only-export-components'?: Linter.RuleEntry<ReactRefreshOnlyExportComponents>
3009
3009
  /**
3010
- * avoid using shorthand boolean attribute
3010
+ * disallow using shorthand boolean attributes
3011
3011
  * @see https://eslint-react.xyz/docs/rules/avoid-shorthand-boolean
3012
3012
  */
3013
3013
  'react/avoid-shorthand-boolean'?: Linter.RuleEntry<[]>
3014
3014
  /**
3015
- * avoid using shorthand fragment syntax
3015
+ * disallow using shorthand fragment syntax
3016
3016
  * @see https://eslint-react.xyz/docs/rules/avoid-shorthand-fragment
3017
3017
  */
3018
3018
  'react/avoid-shorthand-fragment'?: Linter.RuleEntry<[]>
@@ -5676,7 +5676,7 @@ interface RuleOptions {
5676
5676
  */
5677
5677
  'ts/unified-signatures'?: Linter.RuleEntry<TsUnifiedSignatures>
5678
5678
  /**
5679
- * Enforce typing arguments in `.catch()` callbacks as `unknown`
5679
+ * Enforce typing arguments in Promise rejection callbacks as `unknown`
5680
5680
  * @see https://typescript-eslint.io/rules/use-unknown-in-catch-callback-variable
5681
5681
  */
5682
5682
  'ts/use-unknown-in-catch-callback-variable'?: Linter.RuleEntry<[]>
@@ -7801,24 +7801,25 @@ type AccessorPairs = []|[{
7801
7801
  // ----- antfu/consistent-list-newline -----
7802
7802
  type AntfuConsistentListNewline = []|[{
7803
7803
  ArrayExpression?: boolean
7804
+ ArrayPattern?: boolean
7804
7805
  ArrowFunctionExpression?: boolean
7805
7806
  CallExpression?: boolean
7806
7807
  ExportNamedDeclaration?: boolean
7807
7808
  FunctionDeclaration?: boolean
7808
7809
  FunctionExpression?: boolean
7809
7810
  ImportDeclaration?: boolean
7811
+ JSONArrayExpression?: boolean
7812
+ JSONObjectExpression?: boolean
7813
+ JSXOpeningElement?: boolean
7810
7814
  NewExpression?: boolean
7811
7815
  ObjectExpression?: boolean
7816
+ ObjectPattern?: boolean
7817
+ TSFunctionType?: boolean
7812
7818
  TSInterfaceDeclaration?: boolean
7813
7819
  TSTupleType?: boolean
7814
7820
  TSTypeLiteral?: boolean
7815
7821
  TSTypeParameterDeclaration?: boolean
7816
7822
  TSTypeParameterInstantiation?: boolean
7817
- ObjectPattern?: boolean
7818
- ArrayPattern?: boolean
7819
- JSXOpeningElement?: boolean
7820
- JSONArrayExpression?: boolean
7821
- JSONObjectExpression?: boolean
7822
7823
  }]
7823
7824
  // ----- antfu/indent-unindent -----
7824
7825
  type AntfuIndentUnindent = []|[{
@@ -9825,18 +9826,11 @@ type NoRestrictedImports = ((string | {
9825
9826
  importNames?: string[]
9826
9827
  allowImportNames?: string[]
9827
9828
  })[]
9828
- patterns?: (string[] | {
9829
-
9830
- importNames?: [string, ...(string)[]]
9831
-
9832
- allowImportNames?: [string, ...(string)[]]
9833
-
9834
- group: [string, ...(string)[]]
9835
- importNamePattern?: string
9836
- allowImportNamePattern?: string
9837
- message?: string
9838
- caseSensitive?: boolean
9839
- }[])
9829
+ patterns?: (string[] | ({
9830
+ [k: string]: unknown | undefined
9831
+ } | {
9832
+ [k: string]: unknown | undefined
9833
+ })[])
9840
9834
  }])
9841
9835
  // ----- no-restricted-modules -----
9842
9836
  type NoRestrictedModules = ((string | {
@@ -10679,6 +10673,9 @@ type ReactHooksExhaustiveDeps = []|[{
10679
10673
  }]
10680
10674
  // ----- react-naming-convention/component-name -----
10681
10675
  type ReactNamingConventionComponentName = []|[(("PascalCase" | "CONSTANT_CASE") | {
10676
+ allowAllCaps?: boolean
10677
+ allowLeadingUnderscore?: boolean
10678
+ allowNamespace?: boolean
10682
10679
  excepts?: string[]
10683
10680
  rule?: ("PascalCase" | "CONSTANT_CASE")
10684
10681
  })]
@@ -12978,7 +12975,8 @@ type TsNoRestrictedImports = ((string | {
12978
12975
 
12979
12976
  allowImportNames?: [string, ...(string)[]]
12980
12977
 
12981
- group: [string, ...(string)[]]
12978
+ group?: [string, ...(string)[]]
12979
+ regex?: string
12982
12980
  importNamePattern?: string
12983
12981
  allowImportNamePattern?: string
12984
12982
  message?: string
@@ -15057,6 +15055,10 @@ interface OptionsTypeScriptWithTypes {
15057
15055
  * @see https://typescript-eslint.io/linting/typed-linting/
15058
15056
  */
15059
15057
  tsconfigPath?: string;
15058
+ /**
15059
+ * Override type aware rules.
15060
+ */
15061
+ overridesTypeAware?: TypedFlatConfigItem['rules'];
15060
15062
  }
15061
15063
  interface OptionsHasTypeScript {
15062
15064
  typescript?: boolean;
@@ -15480,6 +15482,7 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
15480
15482
  } ? U : T>;
15481
15483
  declare function isPackageInScope(name: string): boolean;
15482
15484
  declare function ensurePackages(packages: (string | undefined)[]): Promise<void>;
15485
+ declare function isInGitHooksOrLintStaged(): boolean;
15483
15486
  declare function isInEditorEnv(): boolean;
15484
15487
 
15485
- export { type Awaitable, type ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsProjectType, type OptionsRegExp, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type ResolvedOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type StylisticOptions, type TypedFlatConfigItem, astro, combine, command, comments, dhzh as default, defaultPluginRenaming, dhzh, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, node, parserPlain, perfectionist, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
15488
+ export { type Awaitable, type ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, type OptionsComponentExts, type OptionsConfig, type OptionsFiles, type OptionsFormatters, type OptionsHasTypeScript, type OptionsIsInEditor, type OptionsOverrides, type OptionsProjectType, type OptionsRegExp, type OptionsStylistic, type OptionsTypeScriptParserOptions, type OptionsTypeScriptWithTypes, type OptionsTypescript, type OptionsUnoCSS, type OptionsVue, type ResolvedOptions, type Rules, type StylisticConfig, StylisticConfigDefaults, type StylisticOptions, type TypedFlatConfigItem, astro, combine, command, comments, dhzh as default, defaultPluginRenaming, dhzh, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, node, parserPlain, perfectionist, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
package/dist/index.js CHANGED
@@ -169,8 +169,17 @@ async function ensurePackages(packages) {
169
169
  await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
170
170
  }
171
171
  }
172
+ function isInGitHooksOrLintStaged() {
173
+ return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
174
+ }
172
175
  function isInEditorEnv() {
173
- return !!((process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM) && !process.env.CI);
176
+ if (process.env.CI) {
177
+ return false;
178
+ }
179
+ if (isInGitHooksOrLintStaged()) {
180
+ return false;
181
+ }
182
+ return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
174
183
  }
175
184
 
176
185
  // src/configs/astro.ts
@@ -1774,6 +1783,7 @@ async function typescript(options = {}) {
1774
1783
  const {
1775
1784
  componentExts = [],
1776
1785
  overrides = {},
1786
+ overridesTypeAware = {},
1777
1787
  parserOptions = {},
1778
1788
  type = "app"
1779
1789
  } = options;
@@ -1908,7 +1918,10 @@ async function typescript(options = {}) {
1908
1918
  files: filesTypeAware,
1909
1919
  ignores: ignoresTypeAware,
1910
1920
  name: "antfu/typescript/rules-type-aware",
1911
- rules: typeAwareRules
1921
+ rules: {
1922
+ ...typeAwareRules,
1923
+ ...overridesTypeAware
1924
+ }
1912
1925
  }] : [],
1913
1926
  {
1914
1927
  files: ["**/*.d.?([cm])ts"],
@@ -2299,7 +2312,6 @@ function dhzh(options = {}, ...userConfigs) {
2299
2312
  autoRenamePlugins = true,
2300
2313
  componentExts = [],
2301
2314
  gitignore: enableGitignore = true,
2302
- isInEditor = isInEditorEnv(),
2303
2315
  jsx: enableJsx = true,
2304
2316
  react: enableReact = false,
2305
2317
  regexp: enableRegexp = true,
@@ -2309,6 +2321,13 @@ function dhzh(options = {}, ...userConfigs) {
2309
2321
  unocss: enableUnoCSS = false,
2310
2322
  vue: enableVue = VuePackages.some((i) => isPackageExists4(i))
2311
2323
  } = options;
2324
+ let isInEditor = options.isInEditor;
2325
+ if (isInEditor == null) {
2326
+ isInEditor = isInEditorEnv();
2327
+ if (isInEditor) {
2328
+ console.log("[@antfu/eslint-config] Detected running in editor, some rules are disabled.");
2329
+ }
2330
+ }
2312
2331
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2313
2332
  if (stylisticOptions && !("jsx" in stylisticOptions)) {
2314
2333
  stylisticOptions.jsx = enableJsx;
@@ -2527,6 +2546,7 @@ export {
2527
2546
  imports,
2528
2547
  interopDefault,
2529
2548
  isInEditorEnv,
2549
+ isInGitHooksOrLintStaged,
2530
2550
  isPackageInScope,
2531
2551
  javascript,
2532
2552
  jsdoc,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dhzh/eslint-config",
3
3
  "type": "module",
4
- "version": "0.12.3",
4
+ "version": "0.12.4",
5
5
  "description": "Easton's ESLint config",
6
6
  "author": "Easton Zheng <dhzhme@gmail.com>",
7
7
  "license": "MIT",
@@ -69,18 +69,18 @@
69
69
  }
70
70
  },
71
71
  "dependencies": {
72
- "@antfu/install-pkg": "^0.3.5",
72
+ "@antfu/install-pkg": "^0.4.0",
73
73
  "@clack/prompts": "^0.7.0",
74
74
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
75
- "@eslint-react/eslint-plugin": "^1.10.1",
75
+ "@eslint-react/eslint-plugin": "^1.12.1",
76
76
  "@stylistic/eslint-plugin": "^2.6.4",
77
- "@typescript-eslint/eslint-plugin": "^8.1.0",
78
- "@typescript-eslint/parser": "^8.1.0",
77
+ "@typescript-eslint/eslint-plugin": "^8.2.0",
78
+ "@typescript-eslint/parser": "^8.2.0",
79
79
  "@vitest/eslint-plugin": "^1.0.3",
80
80
  "eslint-config-flat-gitignore": "^0.1.8",
81
- "eslint-flat-config-utils": "^0.3.0",
81
+ "eslint-flat-config-utils": "^0.3.1",
82
82
  "eslint-merge-processors": "^0.1.0",
83
- "eslint-plugin-antfu": "^2.3.5",
83
+ "eslint-plugin-antfu": "^2.3.6",
84
84
  "eslint-plugin-command": "^0.2.3",
85
85
  "eslint-plugin-import-x": "^3.1.0",
86
86
  "eslint-plugin-jsdoc": "^50.2.2",
@@ -90,7 +90,7 @@
90
90
  "eslint-plugin-no-only-tests": "^3.3.0",
91
91
  "eslint-plugin-perfectionist": "^3.2.0",
92
92
  "eslint-plugin-react-hooks": "^4.6.2",
93
- "eslint-plugin-react-refresh": "^0.4.9",
93
+ "eslint-plugin-react-refresh": "^0.4.11",
94
94
  "eslint-plugin-regexp": "^2.6.0",
95
95
  "eslint-plugin-toml": "^0.11.1",
96
96
  "eslint-plugin-unicorn": "^55.0.0",
@@ -110,29 +110,29 @@
110
110
  },
111
111
  "devDependencies": {
112
112
  "@antfu/ni": "^0.22.4",
113
- "@eslint/config-inspector": "^0.5.3",
113
+ "@eslint/config-inspector": "^0.5.4",
114
114
  "@prettier/plugin-xml": "^3.4.1",
115
115
  "@stylistic/eslint-plugin-migrate": "^2.6.4",
116
116
  "@types/eslint": "^9.6.0",
117
117
  "@types/fs-extra": "^11.0.4",
118
- "@types/node": "^22.3.0",
118
+ "@types/node": "^22.5.0",
119
119
  "@types/prompts": "^2.4.9",
120
120
  "@types/yargs": "^17.0.33",
121
121
  "@unocss/eslint-plugin": "^0.62.2",
122
122
  "astro-eslint-parser": "^1.0.2",
123
- "bumpp": "^9.5.1",
123
+ "bumpp": "^9.5.2",
124
124
  "bundle-require": "^5.0.0",
125
- "eslint": "npm:eslint-ts-patch@9.5.0-0",
125
+ "eslint": "^9.9.0",
126
126
  "eslint-plugin-astro": "^1.2.3",
127
127
  "eslint-plugin-format": "^0.1.2",
128
- "eslint-plugin-solid": "^0.14.1",
128
+ "eslint-plugin-solid": "^0.14.2",
129
129
  "eslint-plugin-svelte": "^2.43.0",
130
- "eslint-ts-patch": "9.5.0-0",
131
130
  "eslint-typegen": "^0.3.1",
132
131
  "esno": "^4.7.0",
133
132
  "execa": "^9.3.1",
134
133
  "fast-glob": "^3.3.2",
135
134
  "fs-extra": "^11.2.0",
135
+ "jiti": "^1.21.6",
136
136
  "lint-staged": "^15.2.9",
137
137
  "prettier-plugin-astro": "^0.14.1",
138
138
  "prettier-plugin-slidev": "^1.0.5",
@@ -148,14 +148,14 @@
148
148
  },
149
149
  "resolutions": {
150
150
  "@eslint-community/eslint-utils": "^4.4.0",
151
- "@typescript-eslint/utils": "^8.1.0",
151
+ "@typescript-eslint/utils": "^8.2.0",
152
152
  "tsx": "~4.17.0"
153
153
  },
154
154
  "simple-git-hooks": {
155
155
  "pre-commit": "npx lint-staged"
156
156
  },
157
157
  "lint-staged": {
158
- "*": "eslint --fix"
158
+ "*": "eslint --flag unstable_ts_config --fix"
159
159
  },
160
160
  "scripts": {
161
161
  "build": "nr typegen && tsup --format esm,cjs --clean --dts",
@@ -163,7 +163,7 @@
163
163
  "dev": "npx @eslint/config-inspector --config eslint.config.ts",
164
164
  "build:inspector": "pnpm build && npx @eslint/config-inspector build",
165
165
  "watch": "tsup --format esm,cjs --watch",
166
- "lint": "eslint .",
166
+ "lint": "eslint --flag unstable_ts_config .",
167
167
  "typegen": "esno scripts/typegen.ts",
168
168
  "release": "bumpp && pnpm publish --access=public",
169
169
  "typecheck": "tsc --noEmit"