@infernodesign/eslint-config 2.14.2 → 2.15.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.js CHANGED
@@ -1466,6 +1466,7 @@ async function perfectionist() {
1466
1466
  plugins: { perfectionist: pluginPerfectionist },
1467
1467
  rules: {
1468
1468
  ...pluginPerfectionist.configs["recommended-alphabetical"].rules,
1469
+ "sort-imports": "off",
1469
1470
  "perfectionist/sort-enums": ["error", {
1470
1471
  fallbackSort: { type: "unsorted" },
1471
1472
  newlinesBetween: "ignore",
@@ -1505,10 +1506,10 @@ async function perfectionist() {
1505
1506
  "side-effect",
1506
1507
  "unknown"
1507
1508
  ],
1508
- partitionByComment: true,
1509
1509
  newlinesBetween: 1,
1510
1510
  newlinesInside: 0,
1511
1511
  order: "asc",
1512
+ partitionByComment: true,
1512
1513
  type: "alphabetical"
1513
1514
  }],
1514
1515
  "perfectionist/sort-interfaces": ["error", {
@@ -1874,6 +1875,154 @@ function mergeSanitySettings(existing, next) {
1874
1875
  };
1875
1876
  }
1876
1877
  //#endregion
1878
+ //#region src/configs/shadcn.ts
1879
+ const ShadcnPluginName = "@shadcn/lint";
1880
+ const defaultComponentFiles = ["**/components/ui/**"];
1881
+ const presetRules = {
1882
+ none: {},
1883
+ recommended: {
1884
+ "shadcn/no-arbitrary-values": ["error", { allow: ["layout"] }],
1885
+ "shadcn/no-inline-styles": "error",
1886
+ "shadcn/no-raw-colors": "error",
1887
+ "shadcn/no-restyle": ["error", { allow: ["layout"] }],
1888
+ "shadcn/no-unknown-classes": "warn",
1889
+ "shadcn/require-static-classes": "error"
1890
+ },
1891
+ warn: {
1892
+ "shadcn/no-arbitrary-values": ["warn", { allow: ["layout"] }],
1893
+ "shadcn/no-inline-styles": "warn",
1894
+ "shadcn/no-raw-colors": "warn",
1895
+ "shadcn/no-restyle": ["warn", { allow: ["layout"] }],
1896
+ "shadcn/no-unknown-classes": "warn",
1897
+ "shadcn/require-static-classes": "warn"
1898
+ }
1899
+ };
1900
+ const componentOverrideRules = {
1901
+ "shadcn/no-arbitrary-values": "off",
1902
+ "shadcn/no-restyle": "off",
1903
+ "shadcn/require-static-classes": "off"
1904
+ };
1905
+ const warnings$1 = /* @__PURE__ */ new Set();
1906
+ /**
1907
+ * Create the `@shadcn/lint` design system config.
1908
+ *
1909
+ * Layers rules as preset < policy `rules` < `overrides`. The built-in component-directory
1910
+ * override is replaced by the policy `overrides` whenever the policy defines them.
1911
+ *
1912
+ * @param {OptionsShadcn & OptionsOverrides & { svelte?: boolean, vue?: boolean }} options - The shadcn options.
1913
+ * The `svelte` and `vue` flags add `.svelte` and `.vue` files to the default `files`.
1914
+ * @returns {Promise<TypedFlatConfigItem[]>} The shadcn config items.
1915
+ */
1916
+ async function shadcn(options = {}) {
1917
+ const { componentFiles = defaultComponentFiles, files = [
1918
+ GLOB_SRC,
1919
+ ...options.vue ? [GLOB_VUE] : [],
1920
+ ...options.svelte ? [GLOB_SVELTE] : []
1921
+ ], overrides = {}, preset = "recommended" } = options;
1922
+ await ensurePackages([ShadcnPluginName]);
1923
+ const pluginShadcn = await interopDefault(import(ShadcnPluginName));
1924
+ const rules = presetRules[preset];
1925
+ if (!rules) throw new Error(`[${PACKAGE_NAME}] Unknown shadcn preset "${preset}"`);
1926
+ const policy = loadShadcnPolicy(options);
1927
+ const hasSettings = !!options.settings && Object.keys(options.settings).length > 0;
1928
+ const overrideConfigs = policy?.overrides ? policy.overrides.map((entry, index) => ({
1929
+ files: entry.files,
1930
+ name: `config/shadcn/policy/${index}`,
1931
+ rules: entry.rules
1932
+ })) : componentFiles.length > 0 ? [{
1933
+ files: componentFiles,
1934
+ name: "config/shadcn/components",
1935
+ rules: componentOverrideRules
1936
+ }] : [];
1937
+ return [
1938
+ {
1939
+ name: "config/shadcn/setup",
1940
+ plugins: { shadcn: pluginShadcn }
1941
+ },
1942
+ {
1943
+ files,
1944
+ name: "config/shadcn/rules",
1945
+ rules: {
1946
+ ...rules,
1947
+ ...policy?.rules,
1948
+ ...overrides
1949
+ },
1950
+ ...hasSettings ? { settings: { shadcn: options.settings } } : {}
1951
+ },
1952
+ ...overrideConfigs
1953
+ ];
1954
+ }
1955
+ /**
1956
+ * Load and validate the `design-system.lint.json` policy file, if one is configured.
1957
+ *
1958
+ * A missing file warns once and is ignored. An unreadable, malformed, or wrongly shaped file throws.
1959
+ *
1960
+ * @param {OptionsShadcn} options - The shadcn options providing `policy` and `cwd`.
1961
+ * @returns {ResolvedShadcnPolicy | undefined} The validated policy, or `undefined` when none is loaded.
1962
+ */
1963
+ function loadShadcnPolicy(options) {
1964
+ if (!options.policy) return;
1965
+ const cwd = path.resolve(process.cwd(), options.cwd ?? ".");
1966
+ const policyPath = path.isAbsolute(options.policy) ? options.policy : path.resolve(cwd, options.policy);
1967
+ if (!existsSync(policyPath)) {
1968
+ warnOnce$1(`[${PACKAGE_NAME}] shadcn policy file "${policyPath}" was not found; continuing without it.`);
1969
+ return;
1970
+ }
1971
+ let parsed;
1972
+ try {
1973
+ parsed = JSON.parse(readFileSync(policyPath, "utf8"));
1974
+ } catch (error) {
1975
+ const message = error instanceof Error ? error.message : String(error);
1976
+ throw new Error(`[${PACKAGE_NAME}] Failed to read shadcn policy file "${policyPath}": ${message}`);
1977
+ }
1978
+ /**
1979
+ * Build the error thrown for a policy file with an invalid shape.
1980
+ *
1981
+ * @param {string} reason - What is wrong with the policy.
1982
+ * @returns {Error} The error to throw.
1983
+ */
1984
+ const invalid = (reason) => /* @__PURE__ */ new Error(`[${PACKAGE_NAME}] Invalid shadcn policy file "${policyPath}": ${reason}`);
1985
+ if (!isPlainObject(parsed)) throw invalid("the root must be an object");
1986
+ const policy = {};
1987
+ if (parsed.rules !== void 0) {
1988
+ if (!isPlainObject(parsed.rules)) throw invalid("\"rules\" must be an object");
1989
+ policy.rules = parsed.rules;
1990
+ }
1991
+ if (parsed.overrides !== void 0) {
1992
+ if (!Array.isArray(parsed.overrides)) throw invalid("\"overrides\" must be an array");
1993
+ policy.overrides = parsed.overrides.map((entry, index) => {
1994
+ if (!isPlainObject(entry)) throw invalid(`"overrides[${index}]" must be an object`);
1995
+ const { files, rules } = entry;
1996
+ if (!Array.isArray(files) || files.length === 0 || !files.every((file) => typeof file === "string")) throw invalid(`"overrides[${index}].files" must be a non-empty array of strings`);
1997
+ if (!isPlainObject(rules)) throw invalid(`"overrides[${index}].rules" must be an object`);
1998
+ return {
1999
+ files,
2000
+ rules
2001
+ };
2002
+ });
2003
+ }
2004
+ return policy;
2005
+ }
2006
+ /**
2007
+ * Check whether a value is a plain object (not `null` and not an array).
2008
+ *
2009
+ * @param {unknown} value - The value to check.
2010
+ * @returns {boolean} `true` when the value is a plain object.
2011
+ */
2012
+ function isPlainObject(value) {
2013
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2014
+ }
2015
+ /**
2016
+ * Warn only once per process for a repeated shadcn policy message.
2017
+ *
2018
+ * @param {string} message - The warning message.
2019
+ */
2020
+ function warnOnce$1(message) {
2021
+ if (warnings$1.has(message)) return;
2022
+ warnings$1.add(message);
2023
+ console.warn(message);
2024
+ }
2025
+ //#endregion
1877
2026
  //#region src/configs/solid.ts
1878
2027
  async function solid(options = {}) {
1879
2028
  const { files = [GLOB_JSX, GLOB_TSX], overrides = {}, typescript = true } = options;
@@ -3236,7 +3385,7 @@ const defaultPluginRenaming = {
3236
3385
  * The merged ESLint configurations.
3237
3386
  */
3238
3387
  function config(options = {}, ...userConfigs) {
3239
- const { astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], e18e: enableE18e = true, gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsdoc: enableJSDoc = false, jsx: enableJsx = true, medusa: enableMedusa = false, nextjs: enableNextjs = false, pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"), react: enableReact = false, regexp: enableRegexp = true, sanity: enableSanity = false, solid: enableSolid = false, storybook: enableStorybook = false, svelte: enableSvelte = false, tailwindcss: enableTailwindcss = false, typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
3388
+ const { astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], e18e: enableE18e = true, gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsdoc: enableJSDoc = false, jsx: enableJsx = true, medusa: enableMedusa = false, nextjs: enableNextjs = false, pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"), react: enableReact = false, regexp: enableRegexp = true, sanity: enableSanity = false, shadcn: enableShadcn = false, solid: enableSolid = false, storybook: enableStorybook = false, svelte: enableSvelte = false, tailwindcss: enableTailwindcss = false, typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
3240
3389
  let isInEditor = options.isInEditor;
3241
3390
  if (isInEditor == null) {
3242
3391
  isInEditor = isInEditorEnv();
@@ -3304,6 +3453,12 @@ function config(options = {}, ...userConfigs) {
3304
3453
  tsconfigPath
3305
3454
  }));
3306
3455
  }
3456
+ if (enableShadcn) configs.push(shadcn({
3457
+ ...resolveSubOptions(options, "shadcn"),
3458
+ overrides: getOverrides(options, "shadcn"),
3459
+ svelte: !!enableSvelte,
3460
+ vue: !!enableVue
3461
+ }));
3307
3462
  if (options.test ?? true) configs.push(test({
3308
3463
  isInEditor,
3309
3464
  overrides: getOverrides(options, "test")
@@ -3413,6 +3568,7 @@ const CONFIG_PRESET_FULL_ON = {
3413
3568
  preset: "strict",
3414
3569
  schemaPath: "schema.json"
3415
3570
  },
3571
+ shadcn: true,
3416
3572
  solid: true,
3417
3573
  storybook: true,
3418
3574
  stylistic: { experimental: true },
@@ -3445,6 +3601,7 @@ const CONFIG_PRESET_FULL_OFF = {
3445
3601
  react: false,
3446
3602
  regexp: false,
3447
3603
  sanity: false,
3604
+ shadcn: false,
3448
3605
  solid: false,
3449
3606
  storybook: false,
3450
3607
  stylistic: false,
@@ -3459,4 +3616,4 @@ const CONFIG_PRESET_FULL_OFF = {
3459
3616
  yaml: false
3460
3617
  };
3461
3618
  //#endregion
3462
- 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_SANITY, GLOB_SCSS, GLOB_SEARCH_EXCLUDE, GLOB_SRC, GLOB_SRC_EXT, GLOB_STORYBOOK, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, PACKAGE_NAME, StylisticConfigDefaults, astro, combine, command, comments, config, config as inferno, defaultPluginRenaming, disables, e18e, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInCursorAgent, isInEditorEnv, isInGitHooksOrLintStaged, isInVSCodeESLintExtension, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, medusa, nextjs, node, normalizeRules, packageExportsSortOrder, packageSortOrder, parserPlain, perfectionist, pnpm, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, sanity, solid, sortPackageJson, sortTsconfig, storybook, stylistic, svelte, tailwindcss, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
3619
+ 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_SANITY, GLOB_SCSS, GLOB_SEARCH_EXCLUDE, GLOB_SRC, GLOB_SRC_EXT, GLOB_STORYBOOK, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, PACKAGE_NAME, StylisticConfigDefaults, astro, combine, command, comments, config, config as inferno, defaultPluginRenaming, disables, e18e, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInCursorAgent, isInEditorEnv, isInGitHooksOrLintStaged, isInVSCodeESLintExtension, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, medusa, nextjs, node, normalizeRules, packageExportsSortOrder, packageSortOrder, parserPlain, perfectionist, pnpm, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, sanity, shadcn, solid, sortPackageJson, sortTsconfig, storybook, stylistic, svelte, tailwindcss, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@infernodesign/eslint-config",
3
3
  "description": "ESLint config for Inferno Design.",
4
- "version": "2.14.2",
4
+ "version": "2.15.0",
5
5
  "type": "module",
6
6
  "author": "Inferno Design <support@infernodesign.com>",
7
7
  "license": "MIT",
@@ -57,19 +57,19 @@
57
57
  "@eslint/config-helpers": "0.7.0",
58
58
  "@eslint/markdown": "8.0.3",
59
59
  "@stylistic/eslint-plugin": "5.10.0",
60
- "@typescript-eslint/eslint-plugin": "8.71.0",
61
- "@typescript-eslint/parser": "8.71.0",
62
- "@typescript-eslint/utils": "8.71.0",
60
+ "@typescript-eslint/eslint-plugin": "8.71.2",
61
+ "@typescript-eslint/parser": "8.71.2",
62
+ "@typescript-eslint/utils": "8.71.2",
63
63
  "@vitest/eslint-plugin": "1.6.27",
64
64
  "ansis": "4.4.0",
65
- "cac": "7.0.0",
65
+ "cac": "7.1.0",
66
66
  "eslint-config-flat-gitignore": "2.4.0",
67
67
  "eslint-flat-config-utils": "3.2.0",
68
68
  "eslint-merge-processors": "2.0.0",
69
69
  "eslint-plugin-antfu": "3.2.3",
70
70
  "eslint-plugin-command": "4.0.0",
71
71
  "eslint-plugin-import-lite": "0.6.0",
72
- "eslint-plugin-jsdoc": "65.1.0",
72
+ "eslint-plugin-jsdoc": "65.3.2",
73
73
  "eslint-plugin-jsonc": "3.4.2",
74
74
  "eslint-plugin-n": "18.4.1",
75
75
  "eslint-plugin-no-only-tests": "3.4.0",
@@ -77,10 +77,10 @@
77
77
  "eslint-plugin-pnpm": "1.9.1",
78
78
  "eslint-plugin-regexp": "3.3.1",
79
79
  "eslint-plugin-toml": "1.5.0",
80
- "eslint-plugin-unicorn": "77.0.0",
80
+ "eslint-plugin-unicorn": "78.0.0",
81
81
  "eslint-plugin-unused-imports": "4.4.1",
82
82
  "eslint-plugin-vue": "10.11.1",
83
- "eslint-plugin-yml": "3.8.1",
83
+ "eslint-plugin-yml": "3.9.0",
84
84
  "eslint-processor-vue-blocks": "2.0.0",
85
85
  "globals": "17.13.0",
86
86
  "jsonc-eslint-parser": "3.3.0",
@@ -91,66 +91,68 @@
91
91
  "yaml-eslint-parser": "2.1.0"
92
92
  },
93
93
  "devDependencies": {
94
- "@eslint-react/eslint-plugin": "5.24.4",
94
+ "@eslint-react/eslint-plugin": "5.26.5",
95
95
  "@eslint/config-inspector": "3.5.0",
96
96
  "@infernodesign/typescript-config": "workspace:*",
97
97
  "@medusajs/eslint-plugin": "2.21.2",
98
- "@next/eslint-plugin-next": "16.3.8",
98
+ "@next/eslint-plugin-next": "16.4.0",
99
99
  "@prettier/plugin-xml": "3.4.2",
100
- "@sanity-labs/eslint-plugin": "1.0.1",
101
- "@types/bun": "1.4.2",
100
+ "@sanity-labs/eslint-plugin": "1.0.2",
101
+ "@shadcn/lint": "0.2.1",
102
+ "@types/bun": "1.4.3",
102
103
  "@types/eslint-plugin-jsx-a11y": "6.10.1",
103
- "@types/node": "26.6.4",
104
- "@unocss/eslint-plugin": "66.10.5",
104
+ "@types/node": "26.6.5",
105
+ "@unocss/eslint-plugin": "66.11.0",
105
106
  "astro-eslint-parser": "3.2.0",
106
107
  "eslint": "10.12.0",
107
108
  "eslint-plugin-astro": "3.2.1",
108
- "eslint-plugin-better-tailwindcss": "4.8.0",
109
+ "eslint-plugin-better-tailwindcss": "4.9.0",
109
110
  "eslint-plugin-erasable-syntax-only": "0.7.2",
110
111
  "eslint-plugin-format": "2.0.1",
111
112
  "eslint-plugin-jsx-a11y": "6.10.2",
112
113
  "eslint-plugin-react-refresh": "0.5.7",
113
114
  "eslint-plugin-solid": "0.18.1",
114
- "eslint-plugin-storybook": "10.6.1",
115
- "eslint-plugin-svelte": "3.23.0",
116
- "eslint-plugin-vuejs-accessibility": "2.6.0",
115
+ "eslint-plugin-storybook": "10.6.2",
116
+ "eslint-plugin-svelte": "3.23.1",
117
+ "eslint-plugin-vuejs-accessibility": "2.6.2",
117
118
  "eslint-typegen": "2.3.1",
118
- "execa": "10.0.1",
119
+ "execa": "10.1.1",
119
120
  "find-up-simple": "1.0.1",
120
121
  "jiti": "2.7.0",
121
122
  "pnpm-workspace-yaml": "1.9.1",
122
- "prettier-plugin-astro": "1.1.0",
123
+ "prettier-plugin-astro": "1.1.1",
123
124
  "prettier-plugin-slidev": "1.0.5",
124
- "svelte": "5.57.1",
125
- "svelte-eslint-parser": "1.8.1",
125
+ "svelte": "5.57.2",
126
+ "svelte-eslint-parser": "1.9.0",
126
127
  "tinyglobby": "0.2.17",
127
- "tsdown": "0.23.0",
128
+ "tsdown": "0.23.1",
128
129
  "typescript": "6.0.3",
129
- "vitest": "5.0.3",
130
- "vue": "3.5.43"
130
+ "vitest": "5.0.4",
131
+ "vue": "3.5.44"
131
132
  },
132
133
  "peerDependencies": {
133
- "@eslint-react/eslint-plugin": "^5.24.4",
134
+ "@eslint-react/eslint-plugin": "^5.26.5",
134
135
  "@medusajs/eslint-plugin": "^2.21.2",
135
- "@next/eslint-plugin-next": "^16.3.8",
136
+ "@next/eslint-plugin-next": "^16.4.0",
136
137
  "@prettier/plugin-xml": "^3.4.2",
137
- "@sanity-labs/eslint-plugin": "^1.0.1",
138
- "@unocss/eslint-plugin": "^66.10.5",
138
+ "@sanity-labs/eslint-plugin": "^1.0.2",
139
+ "@shadcn/lint": "^0.2.1",
140
+ "@unocss/eslint-plugin": "^66.11.0",
139
141
  "astro-eslint-parser": "^3.2.0",
140
142
  "eslint": "^10.12.0",
141
143
  "eslint-plugin-astro": "^3.2.1",
142
- "eslint-plugin-better-tailwindcss": "^4.8.0",
144
+ "eslint-plugin-better-tailwindcss": "^4.9.0",
143
145
  "eslint-plugin-erasable-syntax-only": "^0.7.2",
144
146
  "eslint-plugin-format": "^2.0.1",
145
147
  "eslint-plugin-jsx-a11y": "^6.10.2",
146
148
  "eslint-plugin-react-refresh": "^0.5.7",
147
149
  "eslint-plugin-solid": "^0.18.1",
148
- "eslint-plugin-storybook": "^10.6.1",
149
- "eslint-plugin-svelte": "^3.23.0",
150
- "eslint-plugin-vuejs-accessibility": "^2.6.0",
151
- "prettier-plugin-astro": "^1.1.0",
150
+ "eslint-plugin-storybook": "^10.6.2",
151
+ "eslint-plugin-svelte": "^3.23.1",
152
+ "eslint-plugin-vuejs-accessibility": "^2.6.2",
153
+ "prettier-plugin-astro": "^1.1.1",
152
154
  "prettier-plugin-slidev": "^1.0.5",
153
- "svelte-eslint-parser": "^1.8.1"
155
+ "svelte-eslint-parser": "^1.9.0"
154
156
  },
155
157
  "peerDependenciesMeta": {
156
158
  "@eslint-react/eslint-plugin": {
@@ -168,6 +170,9 @@
168
170
  "@sanity-labs/eslint-plugin": {
169
171
  "optional": true
170
172
  },
173
+ "@shadcn/lint": {
174
+ "optional": true
175
+ },
171
176
  "@unocss/eslint-plugin": {
172
177
  "optional": true
173
178
  },