@shayanthenerd/eslint-config 0.14.0 → 0.16.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.
Files changed (53) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +209 -190
  3. package/dist/configs/astro.mjs +34 -0
  4. package/dist/configs/base.mjs +19 -10
  5. package/dist/configs/css.mjs +2 -2
  6. package/dist/configs/cypress.mjs +2 -2
  7. package/dist/configs/html.mjs +2 -3
  8. package/dist/configs/importX.mjs +8 -4
  9. package/dist/configs/oxlintOverrides.mjs +20 -14
  10. package/dist/configs/perfectionist.mjs +8 -4
  11. package/dist/configs/playwright.mjs +2 -2
  12. package/dist/configs/restrictedExports.mjs +1 -1
  13. package/dist/configs/storybook.mjs +2 -2
  14. package/dist/configs/stylistic.mjs +8 -4
  15. package/dist/configs/tailwind.mjs +14 -14
  16. package/dist/configs/typescript.mjs +8 -4
  17. package/dist/configs/vitest.mjs +2 -2
  18. package/dist/configs/vue.mjs +2 -2
  19. package/dist/configs/vueComponentNames.mjs +1 -1
  20. package/dist/configs/vueServerComponents.mjs +1 -1
  21. package/dist/configs/zod.mjs +8 -4
  22. package/dist/{utils → helpers}/globs.mjs +2 -1
  23. package/dist/{utils → helpers}/ignores/defaultIgnorePatterns.mjs +3 -1
  24. package/dist/{utils → helpers}/ignores/getIgnorePatterns.mjs +1 -1
  25. package/dist/{utils → helpers}/ignores/resolveGitignorePatterns.mjs +1 -1
  26. package/dist/{utils → helpers}/isPackageDetected.mjs +1 -1
  27. package/dist/{utils → helpers}/options/defaultOptions.mjs +15 -7
  28. package/dist/{utils → helpers}/options/enableDetectedConfigs.mjs +2 -3
  29. package/dist/{utils → helpers}/options/mergeWithDefaults.mjs +4 -5
  30. package/dist/{utils → helpers}/vue/getRestrictedVueElements.mjs +1 -1
  31. package/dist/{utils → helpers}/vue/getRestrictedVueInputs.mjs +1 -1
  32. package/dist/index.mjs +6 -4
  33. package/dist/oxlint.config.jsonc +120 -206
  34. package/dist/prettier.config.mjs +1 -1
  35. package/dist/rules/astro.mjs +61 -0
  36. package/dist/rules/css.mjs +1 -1
  37. package/dist/rules/html.mjs +3 -3
  38. package/dist/rules/importX.mjs +1 -1
  39. package/dist/rules/javascript.mjs +1 -2
  40. package/dist/rules/perfectionist.mjs +2 -2
  41. package/dist/rules/stylistic.mjs +10 -7
  42. package/dist/rules/tailwind.mjs +4 -4
  43. package/dist/rules/typescript.mjs +2 -2
  44. package/dist/rules/vue.mjs +6 -6
  45. package/dist/rules/vueAccessibility.mjs +1 -1
  46. package/dist/types/configOptions/base.d.mts +8 -8
  47. package/dist/types/configOptions/nuxt.d.mts +3 -3
  48. package/dist/types/configOptions/stylistic.d.mts +0 -15
  49. package/dist/types/configOptions/test.d.mts +4 -4
  50. package/dist/types/configOptions/vue.d.mts +1 -1
  51. package/dist/types/eslint-schema.d.mts +1031 -237
  52. package/dist/types/index.d.mts +46 -20
  53. package/package.json +142 -124
@@ -1,6 +1,6 @@
1
- import { globs } from "../utils/globs.mjs";
1
+ import { globs } from "../helpers/globs.mjs";
2
2
  import { isEnabled } from "../utils/isEnabled.mjs";
3
- import { defaultOptions } from "../utils/options/defaultOptions.mjs";
3
+ import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
4
4
  import { getImportXRules } from "../rules/importX.mjs";
5
5
  import { mergeConfigs } from "eslint-flat-config-utils";
6
6
  import eslintPluginImportX from "eslint-plugin-import-x";
@@ -8,11 +8,15 @@ import eslintPluginUnusedImports from "eslint-plugin-unused-imports";
8
8
 
9
9
  //#region src/configs/importX.ts
10
10
  function getImportXConfig(options) {
11
- const { vue, importX, typescript } = options.configs;
11
+ const { vue, astro, importX, typescript } = options.configs;
12
12
  const { overrides, removeUnusedImports } = isEnabled(importX) ? importX : defaultOptions.configs.importX;
13
13
  return mergeConfigs({
14
14
  name: "shayanthenerd/imports",
15
- files: isEnabled(vue) ? [globs.src, globs.vue] : [globs.src],
15
+ files: [
16
+ globs.src,
17
+ isEnabled(vue) ? globs.vue : "",
18
+ isEnabled(astro) ? globs.astro : ""
19
+ ].filter(Boolean),
16
20
  plugins: {
17
21
  "import-x": eslintPluginImportX,
18
22
  ...removeUnusedImports && { "unused-imports": eslintPluginUnusedImports }
@@ -1,31 +1,37 @@
1
- import { globs } from "../utils/globs.mjs";
1
+ import { globs } from "../helpers/globs.mjs";
2
2
  import { isEnabled } from "../utils/isEnabled.mjs";
3
- import { getJavaScriptRules } from "../rules/javascript.mjs";
4
- import { getVitestRules } from "../rules/vitest.mjs";
5
- import { getPlaywrightRules } from "../rules/playwright.mjs";
6
- import { getTypeScriptRules } from "../rules/typescript.mjs";
3
+ import { getVueConfig } from "./vue.mjs";
4
+ import { getBaseConfig } from "./base.mjs";
5
+ import { getVitestConfig } from "./vitest.mjs";
6
+ import { getPlaywrightConfig } from "./playwright.mjs";
7
+ import { getTypeScriptConfig } from "./typescript.mjs";
8
+ import eslintPluginVue from "eslint-plugin-vue";
7
9
  import typescriptESLint from "typescript-eslint";
8
10
  import eslintPluginVitest from "@vitest/eslint-plugin";
9
- import eslintPluginImportX from "eslint-plugin-import-x";
10
11
  import eslintPluginPlaywright from "eslint-plugin-playwright";
11
12
 
12
13
  //#region src/configs/oxlintOverrides.ts
14
+ /**
15
+ * Prevent OXLint from overriding rules that are customizable via the configuration options.
16
+ */
13
17
  function getOXLintOverridesConfig(options) {
14
- const { vue, importX, typescript, test: { vitest, playwright } } = options.configs;
15
- const vitestRules = getVitestRules(options);
16
- const javascriptRules = getJavaScriptRules(options);
17
- const typescriptRules = getTypeScriptRules(options);
18
- const playwrightRules = getPlaywrightRules(options);
18
+ const { vue, astro, typescript, test: { vitest, playwright } } = options.configs;
19
+ const vueRules = getVueConfig(options).rules;
20
+ const vitestRules = getVitestConfig(options).rules;
21
+ const javascriptRules = getBaseConfig(options).rules;
22
+ const typescriptRules = getTypeScriptConfig(options).rules;
23
+ const playwrightRules = getPlaywrightConfig(options).rules;
19
24
  return {
20
25
  name: "shayanthenerd/oxlint/overrides",
21
26
  files: [
22
27
  globs.src,
23
28
  isEnabled(vue) ? globs.vue : "",
29
+ isEnabled(astro) ? globs.astro : "",
24
30
  isEnabled(vitest) || isEnabled(playwright) ? globs.test : ""
25
31
  ].filter(Boolean),
26
32
  plugins: {
33
+ ...isEnabled(vue) && { vue: eslintPluginVue },
27
34
  ...isEnabled(vitest) && { vitest: eslintPluginVitest },
28
- ...isEnabled(importX) && { "import-x": eslintPluginImportX },
29
35
  ...isEnabled(playwright) && { playwright: eslintPluginPlaywright },
30
36
  ...isEnabled(typescript) && { "@typescript-eslint": typescriptESLint.plugin }
31
37
  },
@@ -33,11 +39,11 @@ function getOXLintOverridesConfig(options) {
33
39
  "max-depth": javascriptRules["max-depth"],
34
40
  "func-style": javascriptRules["func-style"],
35
41
  "max-nested-callbacks": javascriptRules["max-nested-callbacks"],
36
- "@typescript-eslint/explicit-module-boundary-types": typescriptRules["@typescript-eslint/explicit-module-boundary-types"],
37
42
  "@typescript-eslint/consistent-type-definitions": isEnabled(typescript) ? typescriptRules["@typescript-eslint/consistent-type-definitions"] : "off",
38
43
  "playwright/max-nested-describe": isEnabled(playwright) ? playwrightRules["playwright/max-nested-describe"] : "off",
39
44
  "vitest/consistent-test-it": isEnabled(vitest) ? vitestRules["vitest/consistent-test-it"] : "off",
40
- "vitest/max-nested-describe": isEnabled(vitest) ? vitestRules["vitest/max-nested-describe"] : "off"
45
+ "vitest/max-nested-describe": isEnabled(vitest) ? vitestRules["vitest/max-nested-describe"] : "off",
46
+ "vue/define-props-destructuring": isEnabled(vue) ? vueRules["vue/define-props-destructuring"] : "off"
41
47
  }
42
48
  };
43
49
  }
@@ -1,17 +1,21 @@
1
- import { globs } from "../utils/globs.mjs";
1
+ import { globs } from "../helpers/globs.mjs";
2
2
  import { isEnabled } from "../utils/isEnabled.mjs";
3
- import { defaultOptions } from "../utils/options/defaultOptions.mjs";
3
+ import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
4
4
  import { getPerfectionistRules } from "../rules/perfectionist.mjs";
5
5
  import { mergeConfigs } from "eslint-flat-config-utils";
6
6
  import eslintPluginPerfectionist from "eslint-plugin-perfectionist";
7
7
 
8
8
  //#region src/configs/perfectionist.ts
9
9
  function getPerfectionistConfig(options) {
10
- const { vue, perfectionist } = options.configs;
10
+ const { vue, astro, perfectionist } = options.configs;
11
11
  const { sortType, overrides } = isEnabled(perfectionist) ? perfectionist : defaultOptions.configs.perfectionist;
12
12
  return mergeConfigs({
13
13
  name: "shayanthenerd/perfectionist",
14
- files: isEnabled(vue) ? [globs.src, globs.vue] : [globs.src],
14
+ files: [
15
+ globs.src,
16
+ isEnabled(vue) ? globs.vue : "",
17
+ isEnabled(astro) ? globs.astro : ""
18
+ ].filter(Boolean),
15
19
  plugins: { perfectionist: eslintPluginPerfectionist },
16
20
  settings: { perfectionist: {
17
21
  type: sortType,
@@ -1,6 +1,6 @@
1
- import { globs } from "../utils/globs.mjs";
1
+ import { globs } from "../helpers/globs.mjs";
2
2
  import { isEnabled } from "../utils/isEnabled.mjs";
3
- import { defaultOptions } from "../utils/options/defaultOptions.mjs";
3
+ import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
4
4
  import { getPlaywrightRules } from "../rules/playwright.mjs";
5
5
  import { mergeConfigs } from "eslint-flat-config-utils";
6
6
  import eslintPluginPlaywright from "eslint-plugin-playwright";
@@ -1,4 +1,4 @@
1
- import { globs } from "../utils/globs.mjs";
1
+ import { globs } from "../helpers/globs.mjs";
2
2
 
3
3
  //#region src/configs/restrictedExports.ts
4
4
  function getRestrictedExports() {
@@ -1,6 +1,6 @@
1
- import { globs } from "../utils/globs.mjs";
1
+ import { globs } from "../helpers/globs.mjs";
2
2
  import { isEnabled } from "../utils/isEnabled.mjs";
3
- import { defaultOptions } from "../utils/options/defaultOptions.mjs";
3
+ import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
4
4
  import { getStorybookRules } from "../rules/storybook.mjs";
5
5
  import { mergeConfigs } from "eslint-flat-config-utils";
6
6
  import eslintPluginStorybook from "eslint-plugin-storybook";
@@ -1,17 +1,21 @@
1
- import { globs } from "../utils/globs.mjs";
1
+ import { globs } from "../helpers/globs.mjs";
2
2
  import { isEnabled } from "../utils/isEnabled.mjs";
3
- import { defaultOptions } from "../utils/options/defaultOptions.mjs";
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";
7
7
 
8
8
  //#region src/configs/stylistic.ts
9
9
  function getStylisticConfig(options) {
10
- const { vue, stylistic } = options.configs;
10
+ const { vue, astro, stylistic } = options.configs;
11
11
  const { overrides } = isEnabled(stylistic) ? stylistic : defaultOptions.configs.stylistic;
12
12
  return mergeConfigs({
13
13
  name: "shayanthenerd/stylistic",
14
- files: isEnabled(vue) ? [globs.src, globs.vue] : [globs.src],
14
+ files: [
15
+ globs.src,
16
+ isEnabled(vue) ? globs.vue : "",
17
+ isEnabled(astro) ? globs.astro : ""
18
+ ].filter(Boolean),
15
19
  plugins: { "@stylistic": eslintPluginStylistic },
16
20
  rules: getStylisticRules(options)
17
21
  }, overrides);
@@ -1,40 +1,40 @@
1
- import { globs } from "../utils/globs.mjs";
1
+ import { globs } from "../helpers/globs.mjs";
2
2
  import { isEnabled } from "../utils/isEnabled.mjs";
3
- import { defaultOptions } from "../utils/options/defaultOptions.mjs";
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";
7
- import eslintPluginVue from "eslint-plugin-vue";
8
- import eslintPluginHTML from "@html-eslint/eslint-plugin";
9
7
  import eslintPluginTailwind from "eslint-plugin-better-tailwindcss";
10
8
 
11
9
  //#region src/configs/tailwind.ts
12
- const eslintParserHTML = (eslintPluginHTML.configs?.["flat/recommended"])?.languageOptions?.parser;
13
- const eslintParserVue = eslintPluginVue.configs["flat/recommended"].find((config) => {
14
- return config.name === "vue/base/setup-for-vue";
15
- })?.languageOptions?.parser;
16
10
  const vueAttributes = [["^v-bind:ui$", [{ match: "objectValues" }]], ["^(?:v-bind:)?(class|activeClass|inactiveClass)$", [
17
11
  { match: "strings" },
18
12
  { match: "objectKeys" },
19
13
  { match: "objectValues" }
20
14
  ]]];
15
+ const astroAttributes = [["^class:list$", [
16
+ { match: "strings" },
17
+ { match: "objectKeys" },
18
+ { match: "objectValues" }
19
+ ]]];
21
20
  function getTailwindConfig(options) {
22
- const { tsConfig, configs: { vue, html, tailwind } } = options;
21
+ const { tsConfig, configs: { vue, html, astro, tailwind } } = options;
23
22
  const { config, entryPoint, overrides } = isEnabled(tailwind) ? tailwind : defaultOptions.configs.tailwind;
23
+ const attributes = isEnabled(vue) || isEnabled(astro) ? [...isEnabled(vue) ? vueAttributes : [], ...isEnabled(astro) ? astroAttributes : []].filter(Boolean) : void 0;
24
24
  return mergeConfigs({
25
25
  name: "shayanthenerd/tailwind",
26
26
  files: [
27
27
  globs.src,
28
- html ? globs.html : "",
29
- vue ? globs.vue : ""
28
+ isEnabled(vue) ? globs.vue : "",
29
+ isEnabled(html) ? globs.html : "",
30
+ isEnabled(astro) ? globs.astro : ""
30
31
  ].filter(Boolean),
31
32
  plugins: { "better-tailwindcss": eslintPluginTailwind },
32
- languageOptions: { parserOptions: { parser: isEnabled(html) ? eslintParserHTML : eslintParserVue } },
33
33
  settings: { "better-tailwindcss": {
34
34
  entryPoint: entryPoint || void 0,
35
35
  tailwindConfig: config || void 0,
36
- attributes: isEnabled(vue) ? vueAttributes : void 0,
37
- tsconfig: tsConfig ? path.resolve(tsConfig.rootDir, tsConfig.filename) : void 0
36
+ tsconfig: tsConfig ? path.resolve(tsConfig.rootDir, tsConfig.filename) : void 0,
37
+ attributes
38
38
  } },
39
39
  rules: getTailwindRules(options)
40
40
  }, overrides);
@@ -1,6 +1,6 @@
1
- import { globs } from "../utils/globs.mjs";
1
+ import { globs } from "../helpers/globs.mjs";
2
2
  import { isEnabled } from "../utils/isEnabled.mjs";
3
- import { defaultOptions } from "../utils/options/defaultOptions.mjs";
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";
@@ -8,12 +8,16 @@ import { parser, plugin } from "typescript-eslint";
8
8
 
9
9
  //#region src/configs/typescript.ts
10
10
  function getTypeScriptConfig(options) {
11
- const { tsConfig, configs: { vue, typescript } } = options;
11
+ const { tsConfig, configs: { vue, astro, typescript } } = options;
12
12
  const { allowedDefaultProjects } = isEnabled(typescript) ? typescript : defaultOptions.configs.typescript;
13
13
  const { overrides } = isEnabled(typescript) ? typescript : defaultOptions.configs.typescript;
14
14
  return mergeConfigs({
15
15
  name: "shayanthenerd/typescript",
16
- files: isEnabled(vue) ? [globs.ts, globs.vue] : [globs.ts],
16
+ files: [
17
+ globs.src,
18
+ isEnabled(vue) ? globs.vue : "",
19
+ isEnabled(astro) ? globs.astro : ""
20
+ ].filter(Boolean),
17
21
  plugins: { "@typescript-eslint": plugin },
18
22
  languageOptions: {
19
23
  parser,
@@ -1,6 +1,6 @@
1
- import { globs } from "../utils/globs.mjs";
1
+ import { globs } from "../helpers/globs.mjs";
2
2
  import { isEnabled } from "../utils/isEnabled.mjs";
3
- import { defaultOptions } from "../utils/options/defaultOptions.mjs";
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";
@@ -1,6 +1,6 @@
1
- import { globs } from "../utils/globs.mjs";
1
+ import { globs } from "../helpers/globs.mjs";
2
2
  import { isEnabled } from "../utils/isEnabled.mjs";
3
- import { defaultOptions } from "../utils/options/defaultOptions.mjs";
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";
@@ -1,4 +1,4 @@
1
- import { globs } from "../utils/globs.mjs";
1
+ import { globs } from "../helpers/globs.mjs";
2
2
 
3
3
  //#region src/configs/vueComponentNames.ts
4
4
  function getVueComponentNamesConfig() {
@@ -1,4 +1,4 @@
1
- import { globs } from "../utils/globs.mjs";
1
+ import { globs } from "../helpers/globs.mjs";
2
2
 
3
3
  //#region src/configs/vueServerComponents.ts
4
4
  function getVueServerComponentsConfig() {
@@ -1,17 +1,21 @@
1
- import { globs } from "../utils/globs.mjs";
1
+ import { globs } from "../helpers/globs.mjs";
2
2
  import { isEnabled } from "../utils/isEnabled.mjs";
3
- import { defaultOptions } from "../utils/options/defaultOptions.mjs";
3
+ import { defaultOptions } from "../helpers/options/defaultOptions.mjs";
4
4
  import { getZodRules } from "../rules/zod.mjs";
5
5
  import { mergeConfigs } from "eslint-flat-config-utils";
6
6
  import eslintPluginZodX from "eslint-plugin-zod-x";
7
7
 
8
8
  //#region src/configs/zod.ts
9
9
  function getZodConfig(options) {
10
- const { zod, vue } = options.configs;
10
+ const { zod, vue, astro } = options.configs;
11
11
  const { overrides } = isEnabled(zod) ? zod : defaultOptions.configs.zod;
12
12
  return mergeConfigs({
13
13
  name: "shayanthenerd/zod",
14
- files: isEnabled(vue) ? [globs.src, globs.vue] : [globs.src],
14
+ files: [
15
+ globs.src,
16
+ isEnabled(vue) ? globs.vue : "",
17
+ isEnabled(astro) ? globs.astro : ""
18
+ ].filter(Boolean),
15
19
  plugins: { "zod-x": eslintPluginZodX },
16
20
  rules: getZodRules()
17
21
  }, overrides);
@@ -1,4 +1,4 @@
1
- //#region src/utils/globs.ts
1
+ //#region src/helpers/globs.ts
2
2
  const srcExtensions = "?([mc])[jt]s?(x)";
3
3
  const vueExtensions = `{vue,${srcExtensions}}`;
4
4
  const globs = {
@@ -19,6 +19,7 @@ const globs = {
19
19
  vue: `**/*.${vueExtensions}`,
20
20
  vueServerComponents: `**/*.server.${vueExtensions}`,
21
21
  vueAppErrorLayoutsPages: `**/{{app,error},{layouts,pages}/**/*}.${vueExtensions}`,
22
+ astro: "**/*.astro",
22
23
  storybook: `**/*.(story|stories).${srcExtensions}`,
23
24
  test: `**/{__tests__/*,*.{test,spec,cy,bench?(mark)}.${srcExtensions}`
24
25
  };
@@ -1,4 +1,4 @@
1
- //#region src/utils/ignores/defaultIgnorePatterns.ts
1
+ //#region src/helpers/ignores/defaultIgnorePatterns.ts
2
2
  const defaultIgnorePatterns = [
3
3
  "**/*.min.*",
4
4
  "**/jspm_packages",
@@ -36,6 +36,7 @@ const defaultIgnorePatterns = [
36
36
  "**/.yarn",
37
37
  "**/.nuxt",
38
38
  "**/.next",
39
+ "**/.astro",
39
40
  "**/.vitest",
40
41
  "**/.vercel",
41
42
  "**/.svelte-kit",
@@ -47,6 +48,7 @@ const defaultIgnorePatterns = [
47
48
  "**/.idea",
48
49
  "**/.fleet",
49
50
  "**/.history",
51
+ "**/.DS_Store",
50
52
  "**/LICENSE*",
51
53
  "**/CHANGELOG*.md",
52
54
  "**/CODEOWNERS.md",
@@ -1,7 +1,7 @@
1
1
  import { defaultIgnorePatterns } from "./defaultIgnorePatterns.mjs";
2
2
  import { resolveGitignorePatterns } from "./resolveGitignorePatterns.mjs";
3
3
 
4
- //#region src/utils/ignores/getIgnorePatterns.ts
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/utils/ignores/resolveGitignorePatterns.ts
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,7 +3,7 @@ import path from "node:path";
3
3
  import { styleText } from "node:util";
4
4
  import { isPackageExists } from "local-pkg";
5
5
 
6
- //#region src/utils/isPackageDetected.ts
6
+ //#region src/helpers/isPackageDetected.ts
7
7
  const detectedPackages = [];
8
8
  function logDetectedPackages() {
9
9
  if (detectedPackages.length > 0) {
@@ -1,4 +1,4 @@
1
- //#region src/utils/options/defaultOptions.ts
1
+ //#region src/helpers/options/defaultOptions.ts
2
2
  const defaultOptions = {
3
3
  autoDetectDeps: true,
4
4
  gitignore: ".gitignore",
@@ -14,19 +14,27 @@ const defaultOptions = {
14
14
  reportUnusedDisableDirectives: "warn"
15
15
  },
16
16
  globals: {
17
- node: true,
17
+ worker: true,
18
18
  commonjs: false,
19
+ bun: true,
20
+ deno: true,
21
+ node: true,
22
+ nodeBuiltin: true,
19
23
  browser: true,
20
- worker: true,
21
- serviceworker: false,
22
- webextension: false,
24
+ sharedWorker: true,
25
+ serviceworker: true,
26
+ webextension: true,
27
+ audioWorklet: true,
28
+ vitest: false,
29
+ vue: true,
30
+ astro: true,
23
31
  custom: {}
24
32
  },
25
33
  settings: {},
26
34
  rules: {}
27
35
  },
28
36
  configs: {
29
- oxlint: "./.oxlintrc.json",
37
+ oxlint: ".oxlintrc.json",
30
38
  base: {
31
39
  maxDepth: 3,
32
40
  maxNestedCallbacks: 3,
@@ -41,7 +49,6 @@ const defaultOptions = {
41
49
  quotes: "single",
42
50
  jsxQuotes: "prefer-double",
43
51
  arrowParens: "always",
44
- useTabs: true,
45
52
  indent: 2,
46
53
  maxConsecutiveEmptyLines: 1,
47
54
  maxLineLength: 120,
@@ -154,6 +161,7 @@ const defaultOptions = {
154
161
  icon: { component: "Icon" },
155
162
  ui: { prefix: "U" }
156
163
  },
164
+ astro: { overrides: {} },
157
165
  test: {
158
166
  storybook: { overrides: {} },
159
167
  vitest: { overrides: {} },
@@ -1,7 +1,6 @@
1
- import { defaultOptions } from "./defaultOptions.mjs";
2
1
  import { isPackageDetected, logDetectedPackages } from "../isPackageDetected.mjs";
3
2
 
4
- //#region src/utils/options/enableDetectedConfigs.ts
3
+ //#region src/helpers/options/enableDetectedConfigs.ts
5
4
  function enableDetectedConfigs(options) {
6
5
  options.configs ??= {};
7
6
  options.configs.test ??= {};
@@ -13,13 +12,13 @@ function enableDetectedConfigs(options) {
13
12
  options.configs.perfectionist ??= true;
14
13
  options.configs.vue ??= isPackageDetected("vue", options);
15
14
  options.configs.nuxt ??= isPackageDetected("nuxt", options);
15
+ options.configs.astro ??= isPackageDetected("astro", options);
16
16
  options.configs.typescript ??= isPackageDetected("typescript", options);
17
17
  options.configs.zod ??= isPackageDetected("zod", options);
18
18
  options.configs.test.vitest ??= isPackageDetected("vitest", options);
19
19
  options.configs.test.cypress ??= isPackageDetected("cypress", options);
20
20
  options.configs.test.storybook ??= isPackageDetected("storybook", options);
21
21
  options.configs.test.playwright ??= isPackageDetected("@playwright/test", options);
22
- options.configs.oxlint ??= isPackageDetected("oxlint", options) ? defaultOptions.configs.oxlint : false;
23
22
  options.tsConfig ??= options.configs.typescript ? {
24
23
  rootDir: ".",
25
24
  filename: "tsconfig.json"
@@ -1,17 +1,16 @@
1
1
  import { defaultOptions } from "./defaultOptions.mjs";
2
- import { isEmptyString } from "../isEmptyString.mjs";
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/utils/options/mergeWithDefaults.ts
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(stringKey)) {
13
+ ].includes(key.toString())) {
15
14
  object[key] = value;
16
15
  return true;
17
16
  }
@@ -1,4 +1,4 @@
1
- //#region src/utils/vue/getRestrictedVueElements.ts
1
+ //#region src/helpers/vue/getRestrictedVueElements.ts
2
2
  const alternativeComponentPairs = Object.entries({
3
3
  kbd: "Kbd",
4
4
  form: "Form",
@@ -1,4 +1,4 @@
1
- //#region src/utils/vue/getRestrictedVueInputs.ts
1
+ //#region src/helpers/vue/getRestrictedVueInputs.ts
2
2
  const alternativeComponentPairs = Object.entries({
3
3
  range: "Slider",
4
4
  date: "Calendar",
package/dist/index.mjs CHANGED
@@ -1,10 +1,11 @@
1
1
  import { isEnabled } from "./utils/isEnabled.mjs";
2
- import { defaultOptions } from "./utils/options/defaultOptions.mjs";
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
5
  import { getZodConfig } from "./configs/zod.mjs";
6
6
  import { getBaseConfig } from "./configs/base.mjs";
7
7
  import { getHTMLConfig } from "./configs/html.mjs";
8
+ import { getAstroConfig } from "./configs/astro.mjs";
8
9
  import { getVitestConfig } from "./configs/vitest.mjs";
9
10
  import { getCypressConfig } from "./configs/cypress.mjs";
10
11
  import { getImportXConfig } from "./configs/importX.mjs";
@@ -16,8 +17,8 @@ import { getTypeScriptConfig } from "./configs/typescript.mjs";
16
17
  import { getPerfectionistConfig } from "./configs/perfectionist.mjs";
17
18
  import { getRestrictedExports } from "./configs/restrictedExports.mjs";
18
19
  import { getOXLintOverridesConfig } from "./configs/oxlintOverrides.mjs";
19
- import { getIgnorePatterns } from "./utils/ignores/getIgnorePatterns.mjs";
20
- import { mergeWithDefaults } from "./utils/options/mergeWithDefaults.mjs";
20
+ import { getIgnorePatterns } from "./helpers/ignores/getIgnorePatterns.mjs";
21
+ import { mergeWithDefaults } from "./helpers/options/mergeWithDefaults.mjs";
21
22
  import { getVueComponentNamesConfig } from "./configs/vueComponentNames.mjs";
22
23
  import { getVueServerComponentsConfig } from "./configs/vueServerComponents.mjs";
23
24
  import eslintPluginOXLint from "eslint-plugin-oxlint";
@@ -35,7 +36,7 @@ import path from "node:path";
35
36
  */
36
37
  function defineConfig(options = {}, ...configs) {
37
38
  const mergedOptions = mergeWithDefaults(options);
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;
39
+ const { gitignore, global: { rules, ignores, settings, linterOptions }, configs: { css, zod, vue, html, nuxt, astro, oxlint, importX, tailwind, stylistic, typescript, perfectionist, base: { preferNamedExports }, test: { vitest, cypress, storybook, playwright } } } = mergedOptions;
39
40
  const ignorePatterns = getIgnorePatterns({
40
41
  gitignore,
41
42
  patterns: ignores
@@ -63,6 +64,7 @@ function defineConfig(options = {}, ...configs) {
63
64
  isEnabled(vue) && getVueConfig(mergedOptions),
64
65
  isEnabled(vue) && getVueComponentNamesConfig(),
65
66
  isEnabled(vue) && isEnabled(nuxt) && getVueServerComponentsConfig(),
67
+ isEnabled(astro) && getAstroConfig(mergedOptions),
66
68
  isEnabled(storybook) && getStorybookConfig(mergedOptions),
67
69
  isEnabled(vitest) && getVitestConfig(mergedOptions),
68
70
  isEnabled(cypress) && getCypressConfig(mergedOptions),