@antfu/eslint-config 9.4.1 → 9.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -305,6 +305,55 @@ async function angular(options = {}) {
305
305
  ];
306
306
  }
307
307
  //#endregion
308
+ //#region src/configs/antislop.ts
309
+ async function antislop(options = {}) {
310
+ const { overrides = {}, slop = true, sonarjs = true, typescript = false } = options;
311
+ await ensurePackages([...slop ? ["eslint-plugin-slop"] : [], ...sonarjs ? ["eslint-plugin-sonarjs"] : []]);
312
+ const [pluginSlop, pluginSonarjs] = await Promise.all([slop ? interopDefault(import("eslint-plugin-slop")) : void 0, sonarjs ? interopDefault(import("eslint-plugin-sonarjs")) : void 0]);
313
+ return [{
314
+ name: "antfu/antislop/rules",
315
+ plugins: {
316
+ ...slop ? { slop: pluginSlop } : {},
317
+ ...sonarjs ? { sonarjs: pluginSonarjs } : {}
318
+ },
319
+ ...typeof slop === "object" ? { settings: { slop } } : {},
320
+ rules: {
321
+ ...slop ? {
322
+ "slop/max-comment-length": "error",
323
+ "slop/no-chained-type-assertions": "error",
324
+ "slop/no-em-dash": "error",
325
+ "slop/no-jargon": "error",
326
+ "slop/no-trivial-functions": "error",
327
+ "slop/no-trivial-type-aliases": "error",
328
+ "slop/prefer-jsdoc": "error"
329
+ } : {},
330
+ ...sonarjs ? {
331
+ "sonarjs/cognitive-complexity": "error",
332
+ "sonarjs/no-all-duplicated-branches": "error",
333
+ "sonarjs/no-collapsible-if": "error",
334
+ "sonarjs/no-commented-code": "error",
335
+ "sonarjs/no-dead-store": "error",
336
+ "sonarjs/no-duplicated-branches": "error",
337
+ "sonarjs/no-element-overwrite": "error",
338
+ "sonarjs/no-empty-collection": "error",
339
+ "sonarjs/no-gratuitous-expressions": "error",
340
+ "sonarjs/no-identical-conditions": "error",
341
+ "sonarjs/no-identical-expressions": "error",
342
+ "sonarjs/no-identical-functions": "error",
343
+ "sonarjs/no-invariant-returns": "error",
344
+ "sonarjs/no-inverted-boolean-check": "error",
345
+ "sonarjs/no-redundant-boolean": "error",
346
+ "sonarjs/no-redundant-jump": "error",
347
+ "sonarjs/no-unused-collection": "error",
348
+ "sonarjs/no-use-of-empty-return-value": "error",
349
+ "sonarjs/prefer-single-boolean-return": "error"
350
+ } : {},
351
+ ...typescript ? { "ts/no-explicit-any": "error" } : {},
352
+ ...overrides
353
+ }
354
+ }];
355
+ }
356
+ //#endregion
308
357
  //#region src/configs/astro.ts
309
358
  async function astro(options = {}) {
310
359
  const { files = [GLOB_ASTRO], overrides = {}, stylistic = true } = options;
@@ -2507,7 +2556,7 @@ const defaultPluginRenaming = {
2507
2556
  * The merged ESLint configurations.
2508
2557
  */
2509
2558
  function antfu(options = {}, ...userConfigs) {
2510
- const { angular: enableAngular = false, astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], e18e: enableE18e = true, gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsdoc: enableJsdoc = true, jsx: enableJsx = true, nextjs: enableNextjs = false, node: enableNode = true, perfectionist: enablePerfectionist = true, pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"), react: enableReact = false, regexp: enableRegexp = true, solid: enableSolid = false, svelte: enableSvelte = false, type: appType = "app", typescript: enableTypeScript = isPackageExists("typescript") || isPackageExists("@typescript/native-preview"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
2559
+ const { angular: enableAngular = false, antislop: enableAntislop = false, astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], e18e: enableE18e = true, gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsdoc: enableJsdoc = true, jsx: enableJsx = true, nextjs: enableNextjs = false, node: enableNode = true, perfectionist: enablePerfectionist = true, pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"), react: enableReact = false, regexp: enableRegexp = true, solid: enableSolid = false, svelte: enableSvelte = false, type: appType = "app", typescript: enableTypeScript = isPackageExists("typescript") || isPackageExists("@typescript/native-preview"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
2511
2560
  let isInEditor = options.isInEditor;
2512
2561
  if (isInEditor == null) {
2513
2562
  isInEditor = isInEditorEnv();
@@ -2550,6 +2599,11 @@ function antfu(options = {}, ...userConfigs) {
2550
2599
  overrides: getOverrides(options, "typescript"),
2551
2600
  type: appType
2552
2601
  }));
2602
+ if (enableAntislop) configs.push(antislop({
2603
+ ...resolveSubOptions(options, "antislop"),
2604
+ overrides: getOverrides(options, "antislop"),
2605
+ typescript: !!enableTypeScript
2606
+ }));
2553
2607
  if (stylisticOptions) configs.push(stylistic({
2554
2608
  ...stylisticOptions,
2555
2609
  lessOpinionated: options.lessOpinionated,
@@ -2651,6 +2705,7 @@ function getOverrides(options, key) {
2651
2705
  //#region src/config-presets.ts
2652
2706
  const CONFIG_PRESET_FULL_ON = {
2653
2707
  angular: true,
2708
+ antislop: true,
2654
2709
  astro: true,
2655
2710
  formatters: true,
2656
2711
  gitignore: true,
@@ -2681,6 +2736,7 @@ const CONFIG_PRESET_FULL_ON = {
2681
2736
  };
2682
2737
  const CONFIG_PRESET_FULL_OFF = {
2683
2738
  angular: false,
2739
+ antislop: false,
2684
2740
  astro: false,
2685
2741
  formatters: false,
2686
2742
  gitignore: false,
@@ -2710,4 +2766,4 @@ const CONFIG_PRESET_FULL_OFF = {
2710
2766
  //#region src/index.ts
2711
2767
  var src_default = antfu;
2712
2768
  //#endregion
2713
- export { CONFIG_PRESET_FULL_OFF, CONFIG_PRESET_FULL_ON, 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_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, StylisticConfigDefaults, angular, antfu, astro, combine, command, comments, src_default as default, defaultPluginRenaming, disables, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, nextjs, node, parserPlain, perfectionist, pnpm, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
2769
+ export { CONFIG_PRESET_FULL_OFF, CONFIG_PRESET_FULL_ON, 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_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, StylisticConfigDefaults, angular, antfu, antislop, astro, combine, command, comments, src_default as default, defaultPluginRenaming, disables, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, nextjs, node, parserPlain, perfectionist, pnpm, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antfu/eslint-config",
3
3
  "type": "module",
4
- "version": "9.4.1",
4
+ "version": "9.5.0",
5
5
  "description": "Anthony's ESLint config",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
7
7
  "license": "MIT",
@@ -42,7 +42,9 @@
42
42
  "eslint-plugin-format": ">=0.1.0",
43
43
  "eslint-plugin-jsx-a11y": ">=6.10.2",
44
44
  "eslint-plugin-react-refresh": "^0.5.0",
45
+ "eslint-plugin-slop": ">=0.1.1",
45
46
  "eslint-plugin-solid": "^0.17.0",
47
+ "eslint-plugin-sonarjs": ">=4.0.0",
46
48
  "eslint-plugin-svelte": ">=2.35.1",
47
49
  "eslint-plugin-vuejs-accessibility": "^2.4.1",
48
50
  "prettier-plugin-astro": "^0.14.0",
@@ -89,9 +91,15 @@
89
91
  "eslint-plugin-react-refresh": {
90
92
  "optional": true
91
93
  },
94
+ "eslint-plugin-slop": {
95
+ "optional": true
96
+ },
92
97
  "eslint-plugin-solid": {
93
98
  "optional": true
94
99
  },
100
+ "eslint-plugin-sonarjs": {
101
+ "optional": true
102
+ },
95
103
  "eslint-plugin-svelte": {
96
104
  "optional": true
97
105
  },
@@ -151,7 +159,7 @@
151
159
  "@angular-eslint/eslint-plugin-template": "^22.2.0",
152
160
  "@angular-eslint/template-parser": "^22.2.0",
153
161
  "@angular/core": "^22.1.4",
154
- "@antfu/eslint-config": "9.4.1",
162
+ "@antfu/eslint-config": "9.5.0",
155
163
  "@antfu/ni": "^30.5.0",
156
164
  "@eslint-react/eslint-plugin": "^5.18.6",
157
165
  "@eslint/config-inspector": "^3.3.0",
@@ -169,7 +177,9 @@
169
177
  "eslint-plugin-format": "^2.0.1",
170
178
  "eslint-plugin-jsx-a11y": "^6.10.2",
171
179
  "eslint-plugin-react-refresh": "^0.5.5",
180
+ "eslint-plugin-slop": "^0.1.1",
172
181
  "eslint-plugin-solid": "^0.17.0",
182
+ "eslint-plugin-sonarjs": "^4.2.0",
173
183
  "eslint-plugin-svelte": "^3.23.0",
174
184
  "eslint-plugin-vuejs-accessibility": "^2.6.0",
175
185
  "eslint-typegen": "^2.3.1",