@hexadrop/eslint-config 0.0.1-beta.0 → 0.0.1-beta.10

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021-2023 hexadrop
3
+ Copyright (c) 2021-2024 Hexadrop
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <h1 align="center">
2
- hexadrop's ESLint configuration
2
+ Hexadrop's ESLint configuration
3
3
  </h1>
4
4
 
5
5
  <p align="center">
@@ -19,10 +19,6 @@ npm install --save-dev eslint @hexadrop/eslint-config
19
19
  bun add eslint @hexadrop/eslint-config --dev
20
20
  ```
21
21
 
22
- > [!IMPORTANT]
23
- > Since v4.0.0, this config is rewritten to the
24
- > new [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new).
25
-
26
22
  ## What it does
27
23
 
28
24
  - Auto fix for formatting (aimed to be used standalone **without** Prettier)
@@ -69,8 +65,6 @@ bun add eslint @hexadrop/eslint-config --dev
69
65
 
70
66
  ## Customization
71
67
 
72
- Since v4.0, we migrated to [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new). It provides much better organization and composition.
73
-
74
68
  Normally you only need to import the `hexadrop` preset:
75
69
 
76
70
  ```js
@@ -204,7 +198,7 @@ export default hexadrop(
204
198
 
205
199
  ### Config Composer
206
200
 
207
- Since v2.10.0, the factory function `hexadrop()` returns a [`FlatConfigComposer` object from `eslint-flat-config-utils`](https://github.com/antfu/eslint-flat-config-utils#composer) where you can chain the methods to compose the config even more flexibly.
201
+ The factory function `hexadrop()` returns a [`FlatConfigComposer` object from `eslint-flat-config-utils`](https://github.com/antfu/eslint-flat-config-utils#composer) where you can chain the methods to compose the config even more flexibly.
208
202
 
209
203
  ```js
210
204
  // eslint.config.js
@@ -260,7 +254,7 @@ There is a [visual tool](https://github.com/eslint/config-inspector) to help you
260
254
  Go to your project root that contains `eslint.config.js` and run:
261
255
 
262
256
  ```bash
263
- bunx @eslint/config-inspector
257
+ npx @eslint/config-inspector
264
258
  ```
265
259
 
266
260
  ## Inspiration and Credits
package/dist/index.cjs CHANGED
@@ -280,6 +280,7 @@ var MARKDOWN_CONFIG_NAME_SETUP_PARSER = `${MARKDOWN_CONFIG_NAME_SETUP}/parser`;
280
280
  // src/config/core/core.globs.ts
281
281
  var SOURCE_GLOBS = ["**/*.?([cm])[jt]s?(x)"];
282
282
  var JAVASCRIPT_GLOBS = ["**/*.?([cm])js?(x)"];
283
+ var ESLINT_CONFIG_GLOBS = ["**/eslint.config.js"];
283
284
 
284
285
  // src/config/json/json.config-name.ts
285
286
  var JSON_CONFIG_NAME = `${plugin_prefix_default}/json`;
@@ -880,7 +881,9 @@ var IMPORTS_CONFIG_NAME_RULES_TYPESCRIPT = `${IMPORTS_CONFIG_NAME_RULES}/typescr
880
881
  var IMPORTS_CONFIG_NAME_RULES_STATIC = `${IMPORTS_CONFIG_NAME_RULES}/static`;
881
882
  var IMPORTS_CONFIG_NAME_RULES_STATIC_MARKDOWN_SOURCE = `${IMPORTS_CONFIG_NAME_RULES_STATIC}/markdown/source`;
882
883
  var IMPORTS_CONFIG_NAME_RULES_STYLISTIC = `${IMPORTS_CONFIG_NAME_RULES}/stylistic`;
883
- var IMPORTS_CONFIG_NAME_RULES_STYLISTIC_MARKDOWN_SOURCE = `${IMPORTS_CONFIG_NAME_RULES_STYLISTIC}//markdown/source`;
884
+ var IMPORTS_CONFIG_NAME_RULES_STYLISTIC_ASTRO = `${IMPORTS_CONFIG_NAME_RULES_STYLISTIC}/astro`;
885
+ var IMPORTS_CONFIG_NAME_RULES_STYLISTIC_TYPESCRIPT_DTS = `${IMPORTS_CONFIG_NAME_RULES_STYLISTIC}/typescript/dts`;
886
+ var IMPORTS_CONFIG_NAME_RULES_STYLISTIC_MARKDOWN_SOURCE = `${IMPORTS_CONFIG_NAME_RULES_STYLISTIC}/markdown/source`;
884
887
 
885
888
  // src/config/imports/imports.config.ts
886
889
  async function imports(options) {
@@ -988,20 +991,17 @@ async function imports(options) {
988
991
  [`${importXPluginRename}/no-dynamic-require`]: "error"
989
992
  }
990
993
  }
994
+ },
995
+ {
996
+ files: ESLINT_CONFIG_GLOBS,
997
+ name: IMPORTS_CONFIG_NAME_RULES_WARNINGS_ESLINT_CONFIG,
998
+ rules: {
999
+ [`${importXPluginRename}/default`]: "off",
1000
+ [`${importXPluginRename}/no-deprecated`]: "off",
1001
+ [`${importXPluginRename}/no-named-as-default`]: "off",
1002
+ [`${importXPluginRename}/no-named-as-default-member`]: "off"
1003
+ }
991
1004
  }
992
- /*
993
- * TODO: Decide if we want to keep these rules
994
- * {
995
- * files: ESLINT_CONFIG_GLOBS,
996
- * name: IMPORTS_CONFIG_NAME_RULES_WARNINGS_ESLINT_CONFIG,
997
- * rules: {
998
- * [`${importXPluginRename}/default`]: 'off',
999
- * [`${importXPluginRename}/no-deprecated`]: 'off',
1000
- * [`${importXPluginRename}/no-named-as-default`]: 'off',
1001
- * [`${importXPluginRename}/no-named-as-default-member`]: 'off',
1002
- * },
1003
- * }
1004
- */
1005
1005
  );
1006
1006
  if (markdown2) {
1007
1007
  configs.push({
@@ -1059,6 +1059,15 @@ async function imports(options) {
1059
1059
  ]
1060
1060
  }
1061
1061
  });
1062
+ if (typescript2) {
1063
+ configs.push({
1064
+ files: DTS_GLOBS,
1065
+ name: IMPORTS_CONFIG_NAME_RULES_STYLISTIC_TYPESCRIPT_DTS,
1066
+ rules: {
1067
+ [`${importXPluginRename}/prefer-default-export`]: "off"
1068
+ }
1069
+ });
1070
+ }
1062
1071
  if (markdown2) {
1063
1072
  configs.push({
1064
1073
  files: GLOB_MARKDOWN_SOURCE,
@@ -1068,6 +1077,16 @@ async function imports(options) {
1068
1077
  }
1069
1078
  });
1070
1079
  }
1080
+ if (astro2) {
1081
+ configs.push({
1082
+ files: GLOB_ASTRO,
1083
+ name: IMPORTS_CONFIG_NAME_RULES_STYLISTIC_ASTRO,
1084
+ rules: {
1085
+ [`${importXPluginRename}/exports-last`]: ["off"],
1086
+ [`${importXPluginRename}/prefer-default-export`]: ["off"]
1087
+ }
1088
+ });
1089
+ }
1071
1090
  }
1072
1091
  return configs;
1073
1092
  }
@@ -1303,6 +1322,7 @@ async function stylistic(options) {
1303
1322
  [`${stylisticPluginRename}/line-comment-position`]: ["error", { position: "above" }],
1304
1323
  [`${stylisticPluginRename}/max-len`]: "off",
1305
1324
  [`${stylisticPluginRename}/multiline-comment-style`]: ["error", "starred-block"],
1325
+ [`${stylisticPluginRename}/multiline-ternary`]: "off",
1306
1326
  [`${stylisticPluginRename}/no-extra-semi`]: "error",
1307
1327
  [`${stylisticPluginRename}/padding-line-between-statements`]: [
1308
1328
  "error",
@@ -1884,13 +1904,19 @@ function defaultOptions(options = {}) {
1884
1904
  } else if (installedTypescript) {
1885
1905
  if (options.typescript === void 0) {
1886
1906
  typescript2 = getCwdTsconfigPath() ?? true;
1887
- } else if (options.typescript === "string" || Array.isArray(options.typescript)) {
1907
+ } else if (options.typescript === "string") {
1888
1908
  typescript2 = options.typescript.length > 0 ? options.typescript : true;
1909
+ } else if (Array.isArray(options.typescript)) {
1910
+ typescript2 = options.typescript.length > 0 ? options.typescript.filter(Boolean) : true;
1889
1911
  }
1890
1912
  }
1891
1913
  return {
1892
1914
  astro: options.astro ?? installedAstro,
1893
- ignore: options.ignore ?? true,
1915
+ ignore: typeof options.ignore === "object" ? {
1916
+ ...options.ignore,
1917
+ files: typeof options.ignore.files === "string" ? options.ignore.files : options.ignore.files?.filter(Boolean) ?? [],
1918
+ globs: options.ignore.globs?.filter(Boolean) ?? []
1919
+ } : options.ignore ?? true,
1894
1920
  imports: options.imports ?? true,
1895
1921
  json: options.json ?? true,
1896
1922
  markdown: options.markdown ?? true,
@@ -1900,7 +1926,11 @@ function defaultOptions(options = {}) {
1900
1926
  node: true,
1901
1927
  webpack: false,
1902
1928
  ...options.module,
1903
- ignore: [String.raw`bun\:.*`, String.raw`astro\:.*`, ...options.module?.ignore ?? []]
1929
+ ignore: [
1930
+ String.raw`bun\:.*`,
1931
+ String.raw`astro\:.*`,
1932
+ ...options.module?.ignore?.filter(Boolean) ?? []
1933
+ ]
1904
1934
  },
1905
1935
  node: options.node ?? true,
1906
1936
  react: options.react ?? installedReact,