@coderwyd/eslint-config 2.1.7 → 2.2.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/README.md CHANGED
@@ -189,6 +189,13 @@ interface OptionsConfig {
189
189
  */
190
190
  svelte?: boolean | OptionsOverrides
191
191
 
192
+ /**
193
+ * Enable tainwindcss rules.
194
+ *
195
+ * @default auto-detect based on the dependencies
196
+ */
197
+ tailwindcss?: boolean | OptionsOverrides
198
+
192
199
  /**
193
200
  * Enable unocss rules.
194
201
  *
@@ -247,21 +254,6 @@ interface OptionsConfig {
247
254
  * @default auto-detect based on the process.env
248
255
  */
249
256
  isInEditor?: boolean
250
-
251
- /**
252
- * Provide overrides for rules for each integration.
253
- *
254
- * @deprecated use `overrides` option in each integration key instead
255
- */
256
- overrides?: {
257
- javascript?: FlatConfigItem['rules']
258
- typescript?: FlatConfigItem['rules']
259
- test?: FlatConfigItem['rules']
260
- vue?: FlatConfigItem['rules']
261
- jsonc?: FlatConfigItem['rules']
262
- react?: FlatConfigItem['rules']
263
- svelte?: FlatConfigItem['rules']
264
- }
265
257
  }
266
258
  ```
267
259
 
package/dist/cli.cjs CHANGED
@@ -46,15 +46,15 @@ var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
46
46
  var import_picocolors = __toESM(require("picocolors"), 1);
47
47
 
48
48
  // package.json
49
- var version = "2.1.7";
49
+ var version = "2.2.0";
50
50
  var devDependencies = {
51
51
  "@antfu/ni": "^0.21.12",
52
52
  "@types/eslint": "^8.56.2",
53
53
  "@types/fs-extra": "^11.0.4",
54
- "@types/node": "^20.10.8",
54
+ "@types/node": "^20.11.19",
55
55
  "@types/prompts": "^2.4.9",
56
56
  "@types/yargs": "^17.0.32",
57
- "@unocss/eslint-plugin": "^0.58.4",
57
+ "@unocss/eslint-plugin": "^0.58.5",
58
58
  bumpp: "^9.3.0",
59
59
  eslint: "^8.56.0",
60
60
  "eslint-flat-config-viewer": "^0.1.11",
@@ -66,11 +66,11 @@ var devDependencies = {
66
66
  execa: "^8.0.1",
67
67
  "fast-glob": "^3.3.2",
68
68
  "fs-extra": "^11.2.0",
69
- "lint-staged": "^15.2.1",
69
+ "lint-staged": "^15.2.2",
70
70
  rimraf: "^5.0.5",
71
71
  "simple-git-hooks": "^2.9.0",
72
72
  "svelte-eslint-parser": "^0.33.1",
73
- tsup: "^8.0.1",
73
+ tsup: "^8.0.2",
74
74
  typescript: "^5.3.3"
75
75
  };
76
76
 
package/dist/cli.js CHANGED
@@ -17,15 +17,15 @@ import parse from "parse-gitignore";
17
17
  import c from "picocolors";
18
18
 
19
19
  // package.json
20
- var version = "2.1.7";
20
+ var version = "2.2.0";
21
21
  var devDependencies = {
22
22
  "@antfu/ni": "^0.21.12",
23
23
  "@types/eslint": "^8.56.2",
24
24
  "@types/fs-extra": "^11.0.4",
25
- "@types/node": "^20.10.8",
25
+ "@types/node": "^20.11.19",
26
26
  "@types/prompts": "^2.4.9",
27
27
  "@types/yargs": "^17.0.32",
28
- "@unocss/eslint-plugin": "^0.58.4",
28
+ "@unocss/eslint-plugin": "^0.58.5",
29
29
  bumpp: "^9.3.0",
30
30
  eslint: "^8.56.0",
31
31
  "eslint-flat-config-viewer": "^0.1.11",
@@ -37,11 +37,11 @@ var devDependencies = {
37
37
  execa: "^8.0.1",
38
38
  "fast-glob": "^3.3.2",
39
39
  "fs-extra": "^11.2.0",
40
- "lint-staged": "^15.2.1",
40
+ "lint-staged": "^15.2.2",
41
41
  rimraf: "^5.0.5",
42
42
  "simple-git-hooks": "^2.9.0",
43
43
  "svelte-eslint-parser": "^0.33.1",
44
- tsup: "^8.0.1",
44
+ tsup: "^8.0.2",
45
45
  typescript: "^5.3.3"
46
46
  };
47
47
 
package/dist/index.cjs CHANGED
@@ -33,9 +33,8 @@ __export(src_exports, {
33
33
  defineConfig: () => defineConfig
34
34
  });
35
35
  module.exports = __toCommonJS(src_exports);
36
- var import_node_process3 = __toESM(require("process"), 1);
36
+ var import_node_process4 = __toESM(require("process"), 1);
37
37
  var import_node_fs = __toESM(require("fs"), 1);
38
- var import_local_pkg3 = require("local-pkg");
39
38
 
40
39
  // src/constants/prettier.ts
41
40
  var DEFAULT_PRETTIER_RULES = {
@@ -201,7 +200,7 @@ async function imports() {
201
200
  // src/configs/javascript.ts
202
201
  var import_globals = __toESM(require("globals"), 1);
203
202
  async function javascript(options = {}) {
204
- const { isInEditor = false, overrides = {} } = options;
203
+ const { isInEditor: isInEditor2 = false, overrides = {} } = options;
205
204
  return [
206
205
  {
207
206
  languageOptions: {
@@ -419,7 +418,7 @@ async function javascript(options = {}) {
419
418
  ],
420
419
  "symbol-description": "error",
421
420
  "unicode-bom": ["error", "never"],
422
- "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
421
+ "unused-imports/no-unused-imports": isInEditor2 ? "off" : "error",
423
422
  "unused-imports/no-unused-vars": [
424
423
  "error",
425
424
  {
@@ -540,7 +539,6 @@ function resolveSubOptions(options, key) {
540
539
  function getOverrides(options, key) {
541
540
  const sub = resolveSubOptions(options, key);
542
541
  return {
543
- ...options.overrides?.[key],
544
542
  ..."overrides" in sub ? sub.overrides || {} : {}
545
543
  };
546
544
  }
@@ -1310,7 +1308,7 @@ async function vue(options = {}) {
1310
1308
 
1311
1309
  // src/configs/test.ts
1312
1310
  async function test(options = {}) {
1313
- const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
1311
+ const { files = GLOB_TESTS, isInEditor: isInEditor2 = false, overrides = {} } = options;
1314
1312
  const [pluginVitest, pluginNoOnlyTests] = await Promise.all([
1315
1313
  interopDefault(import("eslint-plugin-vitest")),
1316
1314
  // @ts-expect-error missing types
@@ -1341,7 +1339,7 @@ async function test(options = {}) {
1341
1339
  ],
1342
1340
  "test/no-identical-title": "error",
1343
1341
  "test/no-import-node-test": "error",
1344
- "test/no-only-tests": isInEditor ? "off" : "error",
1342
+ "test/no-only-tests": isInEditor2 ? "off" : "error",
1345
1343
  "test/prefer-hooks-in-order": "error",
1346
1344
  "test/prefer-lowercase-title": "error",
1347
1345
  ...overrides
@@ -1481,7 +1479,6 @@ async function unocss(options = {}) {
1481
1479
 
1482
1480
  // src/configs/formatter.ts
1483
1481
  async function formatter(options = {}, prettierRules2 = {}) {
1484
- await ensurePackages(["eslint-plugin-prettier"]);
1485
1482
  const {
1486
1483
  css = true,
1487
1484
  graphql,
@@ -1656,6 +1653,41 @@ async function svelte(options = {}) {
1656
1653
  ];
1657
1654
  }
1658
1655
 
1656
+ // src/configs/tailwindcss.ts
1657
+ async function tailwindcss(options = {}) {
1658
+ const { overrides } = options;
1659
+ const pluginTailwindcss = await interopDefault(
1660
+ import("eslint-plugin-tailwindcss")
1661
+ );
1662
+ return [
1663
+ {
1664
+ name: "coderwyd:tailwindcss",
1665
+ plugins: {
1666
+ tailwindcss: pluginTailwindcss
1667
+ },
1668
+ rules: {
1669
+ "tailwindcss/classnames-order": "warn",
1670
+ "tailwindcss/enforces-negative-arbitrary-values": "warn",
1671
+ "tailwindcss/enforces-shorthand": "warn",
1672
+ "tailwindcss/migration-from-tailwind-2": "warn",
1673
+ "tailwindcss/no-arbitrary-value": "off",
1674
+ "tailwindcss/no-contradicting-classname": "error",
1675
+ "tailwindcss/no-custom-classname": "off",
1676
+ ...overrides
1677
+ }
1678
+ }
1679
+ ];
1680
+ }
1681
+
1682
+ // src/env.ts
1683
+ var import_node_process3 = __toESM(require("process"), 1);
1684
+ var import_local_pkg3 = require("local-pkg");
1685
+ var isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM) && !import_node_process3.default.env.CI);
1686
+ var hasTypeScript = (0, import_local_pkg3.isPackageExists)("typescript");
1687
+ var hasVue = (0, import_local_pkg3.isPackageExists)("vue") || (0, import_local_pkg3.isPackageExists)("nuxt") || (0, import_local_pkg3.isPackageExists)("vitepress") || (0, import_local_pkg3.isPackageExists)("@slidev/cli");
1688
+ var hasUnocss = (0, import_local_pkg3.isPackageExists)("unocss") || (0, import_local_pkg3.isPackageExists)("@unocss/webpack") || (0, import_local_pkg3.isPackageExists)("@unocss/nuxt");
1689
+ var hasTailwindCSS = (0, import_local_pkg3.isPackageExists)("tailwindcss") && !hasUnocss;
1690
+
1659
1691
  // src/index.ts
1660
1692
  var flatConfigProps = [
1661
1693
  "name",
@@ -1668,18 +1700,18 @@ var flatConfigProps = [
1668
1700
  "rules",
1669
1701
  "settings"
1670
1702
  ];
1671
- var VuePackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
1672
1703
  async function defineConfig(options = {}, ...userConfigs) {
1673
1704
  const {
1674
1705
  componentExts = [],
1675
1706
  gitignore: enableGitignore = true,
1676
- isInEditor = !!((import_node_process3.default.env.VSCODE_PID || import_node_process3.default.env.JETBRAINS_IDE || import_node_process3.default.env.VIM) && !import_node_process3.default.env.CI),
1707
+ isInEditor: isInEditor2 = isInEditor,
1677
1708
  react: enableReact = false,
1678
1709
  svelte: enableSvelte = false,
1679
- typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
1710
+ tailwindcss: enableTailwindCSS = hasTailwindCSS,
1711
+ typescript: enableTypeScript = hasTypeScript,
1680
1712
  unocss: enableUnoCSS = false,
1681
1713
  usePrettierrc = true,
1682
- vue: enableVue = VuePackages.some((i) => (0, import_local_pkg3.isPackageExists)(i))
1714
+ vue: enableVue = hasVue
1683
1715
  } = options;
1684
1716
  const configs = [];
1685
1717
  if (enableGitignore) {
@@ -1701,7 +1733,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1701
1733
  configs.push(
1702
1734
  ignores(),
1703
1735
  javascript({
1704
- isInEditor,
1736
+ isInEditor: isInEditor2,
1705
1737
  overrides: getOverrides(options, "javascript")
1706
1738
  }),
1707
1739
  comments(),
@@ -1726,7 +1758,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1726
1758
  if (options.test ?? true) {
1727
1759
  configs.push(
1728
1760
  test({
1729
- isInEditor,
1761
+ isInEditor: isInEditor2,
1730
1762
  overrides: getOverrides(options, "test")
1731
1763
  })
1732
1764
  );
@@ -1764,6 +1796,14 @@ async function defineConfig(options = {}, ...userConfigs) {
1764
1796
  })
1765
1797
  );
1766
1798
  }
1799
+ if (enableTailwindCSS) {
1800
+ configs.push(
1801
+ tailwindcss({
1802
+ ...resolveSubOptions(options, "tailwindcss"),
1803
+ overrides: getOverrides(options, "tailwindcss")
1804
+ })
1805
+ );
1806
+ }
1767
1807
  if (options.jsonc ?? true) {
1768
1808
  configs.push(
1769
1809
  jsonc({
@@ -1781,7 +1821,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1781
1821
  }
1782
1822
  if (usePrettierrc) {
1783
1823
  const prettierConfig = await loadPrettierConfig(
1784
- options.cwd ?? import_node_process3.default.cwd()
1824
+ options.cwd ?? import_node_process4.default.cwd()
1785
1825
  );
1786
1826
  Object.assign(prettierRules2, prettierConfig);
1787
1827
  }
package/dist/index.d.cts CHANGED
@@ -1,22 +1,306 @@
1
1
  import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
2
2
  import { ParserOptions } from '@typescript-eslint/parser';
3
- import { FlatESLintConfigItem, MergeIntersection, RenamePrefix, TypeScriptRules, VitestRules, NRules, Prefix, ReactHooksRules, ReactRules, JSDocRules, ImportRules, EslintRules, JsoncRules, VueRules, UnicornRules, EslintCommentsRules, RuleConfig } from '@antfu/eslint-define-config';
3
+ import { RuleConfig, FlatESLintConfigItem, MergeIntersection, RenamePrefix, TypeScriptRules, VitestRules, NRules, Prefix, ReactHooksRules, ReactRules, JSDocRules, ImportRules, EslintRules, JsoncRules, VueRules, UnicornRules, EslintCommentsRules } from '@antfu/eslint-define-config';
4
+ import { RequiredOptions, LiteralUnion, BuiltInParserName } from 'prettier';
4
5
  import { Linter } from 'eslint';
5
6
  import { Rules } from 'eslint-plugin-antfu';
6
- import { RequiredOptions, LiteralUnion, BuiltInParserName } from 'prettier';
7
7
 
8
- type PrettierCustomParser = 'astro' | 'svelte' | 'toml';
9
- type PrettierParser = BuiltInParserName | PrettierCustomParser;
8
+ type PrettierCustomParser = 'toml'
9
+ type PrettierParser = BuiltInParserName | PrettierCustomParser
10
10
  interface PrettierOptions extends RequiredOptions {
11
- parser: LiteralUnion<PrettierParser>;
11
+ parser: LiteralUnion<PrettierParser>
12
+ }
13
+ type PartialPrettierExtendedOptions = Partial<PrettierOptions>
14
+
15
+ /**
16
+ * Use Prettier to format code.
17
+ *
18
+ */
19
+ type PrettierRuleConfig = RuleConfig<PrettierOptions>
20
+
21
+ /**
22
+ * Use Prettier to format code.
23
+ *
24
+ */
25
+ interface PrettierRule {
26
+ /**
27
+ * Use Prettier to format code.
28
+ *
29
+ */
30
+ 'prettier/prettier': PrettierRuleConfig
31
+ }
32
+
33
+ /**
34
+ * Option.
35
+ */
36
+ interface ClassnamesOrderOption {
37
+ callees?: string[]
38
+ ignoredKeys?: string[]
39
+ config?: string | Record<string, any>
40
+ removeDuplicates?: boolean
41
+ tags?: string[]
42
+
43
+ [k: string]: any
44
+ }
45
+
46
+ /**
47
+ * Options.
48
+ */
49
+ type ClassnamesOrderOptions = [ClassnamesOrderOption?]
50
+
51
+ /**
52
+ * Enforce a consistent and logical order of the Tailwind CSS classnames.
53
+ * @see [classnames-order](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/classnames-order.md)
54
+ */
55
+ type ClassnamesOrderRuleConfig = RuleConfig<ClassnamesOrderOptions>
56
+
57
+ /**
58
+ * Enforce a consistent and logical order of the Tailwind CSS classnames.
59
+ * @see [classnames-order](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/classnames-order.md)
60
+ */
61
+ interface ClassnamesOrderRule {
62
+ /**
63
+ * Enforce a consistent and logical order of the Tailwind CSS classnames.
64
+ * @see [classnames-order](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/classnames-order.md)
65
+ */
66
+ 'tailwindcss/classnames-order': ClassnamesOrderRuleConfig
12
67
  }
13
- type PartialPrettierExtendedOptions = Partial<PrettierOptions>;
68
+
69
+ /**
70
+ * Option.
71
+ */
72
+ interface EnforcesNegativeArbitraryValuesOption {
73
+ callees?: string[]
74
+ ignoredKeys?: string[]
75
+ config?: string | Record<string, any>
76
+ tags?: string[]
77
+
78
+ [k: string]: any
79
+ }
80
+
81
+ /**
82
+ * Options.
83
+ */
84
+ type EnforcesNegativeArbitraryValuesOptions = [
85
+ EnforcesNegativeArbitraryValuesOption?,
86
+ ]
87
+
88
+ /**
89
+ * Warns about dash prefixed classnames using arbitrary values.
90
+ * @see [enforces-negative-arbitrary-values](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-negative-arbitrary-values.md)
91
+ */
92
+ type EnforcesNegativeArbitraryValuesRuleConfig =
93
+ RuleConfig<EnforcesNegativeArbitraryValuesOptions>
94
+
95
+ /**
96
+ * Warns about dash prefixed classnames using arbitrary values.
97
+ * @see [enforces-negative-arbitrary-values](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-negative-arbitrary-values.md)
98
+ */
99
+ interface EnforcesNegativeArbitraryValuesRule {
100
+ /**
101
+ * Warns about dash prefixed classnames using arbitrary values.
102
+ * @see [enforces-negative-arbitrary-values](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-negative-arbitrary-values.md)
103
+ */
104
+ 'tailwindcss/enforces-negative-arbitrary-values': EnforcesNegativeArbitraryValuesRuleConfig
105
+ }
106
+
107
+ /**
108
+ * Option.
109
+ */
110
+ interface EnforcesShorthandOption {
111
+ callees?: string[]
112
+ ignoredKeys?: string[]
113
+ config?: string | Record<string, any>
114
+ tags?: string[]
115
+
116
+ [k: string]: any
117
+ }
118
+
119
+ /**
120
+ * Options.
121
+ */
122
+ type EnforcesShorthandOptions = [EnforcesShorthandOption?]
123
+
124
+ /**
125
+ * Enforces the usage of shorthand Tailwind CSS classnames.
126
+ * @see [enforces-shorthand](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-shorthand.md)
127
+ */
128
+ type EnforcesShorthandRuleConfig = RuleConfig<EnforcesShorthandOptions>
129
+
130
+ /**
131
+ * Enforces the usage of shorthand Tailwind CSS classnames.
132
+ * @see [enforces-shorthand](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-shorthand.md)
133
+ */
134
+ interface EnforcesShorthandRule {
135
+ /**
136
+ * Enforces the usage of shorthand Tailwind CSS classnames.
137
+ * @see [enforces-shorthand](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-shorthand.md)
138
+ */
139
+ 'tailwindcss/enforces-shorthand': EnforcesShorthandRuleConfig
140
+ }
141
+
142
+ /**
143
+ * Option.
144
+ */
145
+ interface MigrationFromTailwind_2Option {
146
+ callees?: string[]
147
+ ignoredKeys?: string[]
148
+ config?: string | Record<string, any>
149
+ tags?: string[]
150
+
151
+ [k: string]: any
152
+ }
153
+
154
+ /**
155
+ * Options.
156
+ */
157
+ type MigrationFromTailwind_2Options = [MigrationFromTailwind_2Option?]
158
+
159
+ /**
160
+ * Detect obsolete classnames when upgrading to Tailwind CSS v3.
161
+ * @see [migration-from-tailwind-2](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/migration-from-tailwind-2.md)
162
+ */
163
+ type MigrationFromTailwind_2RuleConfig =
164
+ RuleConfig<MigrationFromTailwind_2Options>
165
+
166
+ /**
167
+ * Detect obsolete classnames when upgrading to Tailwind CSS v3.
168
+ * @see [migration-from-tailwind-2](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/migration-from-tailwind-2.md)
169
+ */
170
+ interface MigrationFromTailwind_2Rule {
171
+ /**
172
+ * Detect obsolete classnames when upgrading to Tailwind CSS v3.
173
+ * @see [migration-from-tailwind-2](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/migration-from-tailwind-2.md)
174
+ */
175
+ 'tailwindcss/migration-from-tailwind-2': MigrationFromTailwind_2RuleConfig
176
+ }
177
+
178
+ /**
179
+ * Option.
180
+ */
181
+ interface NoArbitraryValueOption {
182
+ callees?: string[]
183
+ ignoredKeys?: string[]
184
+ config?: string | Record<string, any>
185
+ tags?: string[]
186
+
187
+ [k: string]: any
188
+ }
189
+
190
+ /**
191
+ * Options.
192
+ */
193
+ type NoArbitraryValueOptions = [NoArbitraryValueOption?]
194
+
195
+ /**
196
+ * Forbid using arbitrary values in classnames.
197
+ * @see [no-arbitrary-value](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-arbitrary-value.md)
198
+ */
199
+ type NoArbitraryValueRuleConfig = RuleConfig<NoArbitraryValueOptions>
200
+
201
+ /**
202
+ * Forbid using arbitrary values in classnames.
203
+ * @see [no-arbitrary-value](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-arbitrary-value.md)
204
+ */
205
+ interface NoArbitraryValueRule {
206
+ /**
207
+ * Forbid using arbitrary values in classnames.
208
+ * @see [no-arbitrary-value](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-arbitrary-value.md)
209
+ */
210
+ 'tailwindcss/no-arbitrary-value': NoArbitraryValueRuleConfig
211
+ }
212
+
213
+ /**
214
+ * Option.
215
+ */
216
+ interface NoContradictingClassnameOption {
217
+ callees?: string[]
218
+ ignoredKeys?: string[]
219
+ config?: string | Record<string, any>
220
+ tags?: string[]
221
+
222
+ [k: string]: any
223
+ }
224
+
225
+ /**
226
+ * Options.
227
+ */
228
+ type NoContradictingClassnameOptions = [NoContradictingClassnameOption?]
229
+
230
+ /**
231
+ * Avoid contradicting Tailwind CSS classnames (e.g. "w-3 w-5").
232
+ * @see [no-contradicting-classname](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-contradicting-classname.md)
233
+ */
234
+ type NoContradictingClassnameRuleConfig =
235
+ RuleConfig<NoContradictingClassnameOptions>
236
+
237
+ /**
238
+ * Avoid contradicting Tailwind CSS classnames (e.g. "w-3 w-5").
239
+ * @see [no-contradicting-classname](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-contradicting-classname.md)
240
+ */
241
+ interface NoContradictingClassnameRule {
242
+ /**
243
+ * Avoid contradicting Tailwind CSS classnames (e.g. "w-3 w-5").
244
+ * @see [no-contradicting-classname](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-contradicting-classname.md)
245
+ */
246
+ 'tailwindcss/no-contradicting-classname': NoContradictingClassnameRuleConfig
247
+ }
248
+
249
+ /**
250
+ * Option.
251
+ */
252
+ interface NoCustomClassnameOption {
253
+ callees?: string[]
254
+ ignoredKeys?: string[]
255
+ config?: string | Record<string, any>
256
+ cssFiles?: string[]
257
+ cssFilesRefreshRate?: number
258
+ tags?: string[]
259
+ whitelist?: string[]
260
+
261
+ [k: string]: any
262
+ }
263
+
264
+ /**
265
+ * Options.
266
+ */
267
+ type NoCustomClassnameOptions = [NoCustomClassnameOption?]
268
+
269
+ /**
270
+ * Detect classnames which do not belong to Tailwind CSS.
271
+ * @see [no-custom-classname](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-custom-classname.md)
272
+ */
273
+ type NoCustomClassnameRuleConfig = RuleConfig<NoCustomClassnameOptions>
274
+
275
+ /**
276
+ * Detect classnames which do not belong to Tailwind CSS.
277
+ * @see [no-custom-classname](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-custom-classname.md)
278
+ */
279
+ interface NoCustomClassnameRule {
280
+ /**
281
+ * Detect classnames which do not belong to Tailwind CSS.
282
+ * @see [no-custom-classname](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-custom-classname.md)
283
+ */
284
+ 'tailwindcss/no-custom-classname': NoCustomClassnameRuleConfig
285
+ }
286
+
287
+ /**
288
+ * All TailwindCss rules.
289
+ */
290
+ type TailwindCssRules = ClassnamesOrderRule &
291
+ EnforcesNegativeArbitraryValuesRule &
292
+ EnforcesShorthandRule &
293
+ MigrationFromTailwind_2Rule &
294
+ NoArbitraryValueRule &
295
+ NoContradictingClassnameRule &
296
+ NoCustomClassnameRule
297
+
14
298
  type WrapRuleConfig<T extends {
15
299
  [key: string]: any;
16
300
  }> = {
17
301
  [K in keyof T]: T[K] extends RuleConfig ? T[K] : RuleConfig<T[K]>;
18
302
  };
19
- type EslintFlatRules = WrapRuleConfig<MergeIntersection<RenamePrefix<TypeScriptRules, '@typescript-eslint/', 'ts/'> & RenamePrefix<VitestRules, 'vitest/', 'test/'> & RenamePrefix<NRules, 'n/', 'node/'> & Prefix<Rules, 'antfu/'> & ReactHooksRules & ReactRules & JSDocRules & ImportRules & EslintRules & JsoncRules & VueRules & UnicornRules & EslintCommentsRules & {
303
+ type EslintFlatRules = WrapRuleConfig<MergeIntersection<RenamePrefix<TypeScriptRules, '@typescript-eslint/', 'ts/'> & RenamePrefix<VitestRules, 'vitest/', 'test/'> & RenamePrefix<NRules, 'n/', 'node/'> & Prefix<Rules, 'antfu/'> & ReactHooksRules & ReactRules & JSDocRules & ImportRules & EslintRules & JsoncRules & VueRules & UnicornRules & PrettierRule & TailwindCssRules & EslintCommentsRules & {
20
304
  'test/no-only-tests': RuleConfig<[]>;
21
305
  }>>;
22
306
  type FlatConfigItem = Omit<FlatESLintConfigItem<EslintFlatRules, false>, 'plugins'> & {
@@ -177,6 +461,12 @@ interface OptionsConfig extends OptionsComponentExts {
177
461
  * @default false
178
462
  */
179
463
  svelte?: boolean | OptionsOverrides;
464
+ /**
465
+ * Enable tainwindcss rules.
466
+ *
467
+ * @default auto-detect based on the dependencies
468
+ */
469
+ tailwindcss?: boolean | OptionsOverrides;
180
470
  /**
181
471
  * Enable unocss rules.
182
472
  *
@@ -231,20 +521,6 @@ interface OptionsConfig extends OptionsComponentExts {
231
521
  * @default auto-detect based on the process.env
232
522
  */
233
523
  isInEditor?: boolean;
234
- /**
235
- * Provide overrides for rules for each integration.
236
- *
237
- * @deprecated use `overrides` option in each integration key instead
238
- */
239
- overrides?: {
240
- javascript?: FlatConfigItem['rules'];
241
- typescript?: FlatConfigItem['rules'];
242
- test?: FlatConfigItem['rules'];
243
- vue?: FlatConfigItem['rules'];
244
- jsonc?: FlatConfigItem['rules'];
245
- react?: FlatConfigItem['rules'];
246
- svelte?: FlatConfigItem['rules'];
247
- };
248
524
  }
249
525
 
250
526
  /**
package/dist/index.d.ts CHANGED
@@ -1,22 +1,306 @@
1
1
  import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
2
2
  import { ParserOptions } from '@typescript-eslint/parser';
3
- import { FlatESLintConfigItem, MergeIntersection, RenamePrefix, TypeScriptRules, VitestRules, NRules, Prefix, ReactHooksRules, ReactRules, JSDocRules, ImportRules, EslintRules, JsoncRules, VueRules, UnicornRules, EslintCommentsRules, RuleConfig } from '@antfu/eslint-define-config';
3
+ import { RuleConfig, FlatESLintConfigItem, MergeIntersection, RenamePrefix, TypeScriptRules, VitestRules, NRules, Prefix, ReactHooksRules, ReactRules, JSDocRules, ImportRules, EslintRules, JsoncRules, VueRules, UnicornRules, EslintCommentsRules } from '@antfu/eslint-define-config';
4
+ import { RequiredOptions, LiteralUnion, BuiltInParserName } from 'prettier';
4
5
  import { Linter } from 'eslint';
5
6
  import { Rules } from 'eslint-plugin-antfu';
6
- import { RequiredOptions, LiteralUnion, BuiltInParserName } from 'prettier';
7
7
 
8
- type PrettierCustomParser = 'astro' | 'svelte' | 'toml';
9
- type PrettierParser = BuiltInParserName | PrettierCustomParser;
8
+ type PrettierCustomParser = 'toml'
9
+ type PrettierParser = BuiltInParserName | PrettierCustomParser
10
10
  interface PrettierOptions extends RequiredOptions {
11
- parser: LiteralUnion<PrettierParser>;
11
+ parser: LiteralUnion<PrettierParser>
12
+ }
13
+ type PartialPrettierExtendedOptions = Partial<PrettierOptions>
14
+
15
+ /**
16
+ * Use Prettier to format code.
17
+ *
18
+ */
19
+ type PrettierRuleConfig = RuleConfig<PrettierOptions>
20
+
21
+ /**
22
+ * Use Prettier to format code.
23
+ *
24
+ */
25
+ interface PrettierRule {
26
+ /**
27
+ * Use Prettier to format code.
28
+ *
29
+ */
30
+ 'prettier/prettier': PrettierRuleConfig
31
+ }
32
+
33
+ /**
34
+ * Option.
35
+ */
36
+ interface ClassnamesOrderOption {
37
+ callees?: string[]
38
+ ignoredKeys?: string[]
39
+ config?: string | Record<string, any>
40
+ removeDuplicates?: boolean
41
+ tags?: string[]
42
+
43
+ [k: string]: any
44
+ }
45
+
46
+ /**
47
+ * Options.
48
+ */
49
+ type ClassnamesOrderOptions = [ClassnamesOrderOption?]
50
+
51
+ /**
52
+ * Enforce a consistent and logical order of the Tailwind CSS classnames.
53
+ * @see [classnames-order](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/classnames-order.md)
54
+ */
55
+ type ClassnamesOrderRuleConfig = RuleConfig<ClassnamesOrderOptions>
56
+
57
+ /**
58
+ * Enforce a consistent and logical order of the Tailwind CSS classnames.
59
+ * @see [classnames-order](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/classnames-order.md)
60
+ */
61
+ interface ClassnamesOrderRule {
62
+ /**
63
+ * Enforce a consistent and logical order of the Tailwind CSS classnames.
64
+ * @see [classnames-order](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/classnames-order.md)
65
+ */
66
+ 'tailwindcss/classnames-order': ClassnamesOrderRuleConfig
12
67
  }
13
- type PartialPrettierExtendedOptions = Partial<PrettierOptions>;
68
+
69
+ /**
70
+ * Option.
71
+ */
72
+ interface EnforcesNegativeArbitraryValuesOption {
73
+ callees?: string[]
74
+ ignoredKeys?: string[]
75
+ config?: string | Record<string, any>
76
+ tags?: string[]
77
+
78
+ [k: string]: any
79
+ }
80
+
81
+ /**
82
+ * Options.
83
+ */
84
+ type EnforcesNegativeArbitraryValuesOptions = [
85
+ EnforcesNegativeArbitraryValuesOption?,
86
+ ]
87
+
88
+ /**
89
+ * Warns about dash prefixed classnames using arbitrary values.
90
+ * @see [enforces-negative-arbitrary-values](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-negative-arbitrary-values.md)
91
+ */
92
+ type EnforcesNegativeArbitraryValuesRuleConfig =
93
+ RuleConfig<EnforcesNegativeArbitraryValuesOptions>
94
+
95
+ /**
96
+ * Warns about dash prefixed classnames using arbitrary values.
97
+ * @see [enforces-negative-arbitrary-values](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-negative-arbitrary-values.md)
98
+ */
99
+ interface EnforcesNegativeArbitraryValuesRule {
100
+ /**
101
+ * Warns about dash prefixed classnames using arbitrary values.
102
+ * @see [enforces-negative-arbitrary-values](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-negative-arbitrary-values.md)
103
+ */
104
+ 'tailwindcss/enforces-negative-arbitrary-values': EnforcesNegativeArbitraryValuesRuleConfig
105
+ }
106
+
107
+ /**
108
+ * Option.
109
+ */
110
+ interface EnforcesShorthandOption {
111
+ callees?: string[]
112
+ ignoredKeys?: string[]
113
+ config?: string | Record<string, any>
114
+ tags?: string[]
115
+
116
+ [k: string]: any
117
+ }
118
+
119
+ /**
120
+ * Options.
121
+ */
122
+ type EnforcesShorthandOptions = [EnforcesShorthandOption?]
123
+
124
+ /**
125
+ * Enforces the usage of shorthand Tailwind CSS classnames.
126
+ * @see [enforces-shorthand](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-shorthand.md)
127
+ */
128
+ type EnforcesShorthandRuleConfig = RuleConfig<EnforcesShorthandOptions>
129
+
130
+ /**
131
+ * Enforces the usage of shorthand Tailwind CSS classnames.
132
+ * @see [enforces-shorthand](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-shorthand.md)
133
+ */
134
+ interface EnforcesShorthandRule {
135
+ /**
136
+ * Enforces the usage of shorthand Tailwind CSS classnames.
137
+ * @see [enforces-shorthand](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-shorthand.md)
138
+ */
139
+ 'tailwindcss/enforces-shorthand': EnforcesShorthandRuleConfig
140
+ }
141
+
142
+ /**
143
+ * Option.
144
+ */
145
+ interface MigrationFromTailwind_2Option {
146
+ callees?: string[]
147
+ ignoredKeys?: string[]
148
+ config?: string | Record<string, any>
149
+ tags?: string[]
150
+
151
+ [k: string]: any
152
+ }
153
+
154
+ /**
155
+ * Options.
156
+ */
157
+ type MigrationFromTailwind_2Options = [MigrationFromTailwind_2Option?]
158
+
159
+ /**
160
+ * Detect obsolete classnames when upgrading to Tailwind CSS v3.
161
+ * @see [migration-from-tailwind-2](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/migration-from-tailwind-2.md)
162
+ */
163
+ type MigrationFromTailwind_2RuleConfig =
164
+ RuleConfig<MigrationFromTailwind_2Options>
165
+
166
+ /**
167
+ * Detect obsolete classnames when upgrading to Tailwind CSS v3.
168
+ * @see [migration-from-tailwind-2](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/migration-from-tailwind-2.md)
169
+ */
170
+ interface MigrationFromTailwind_2Rule {
171
+ /**
172
+ * Detect obsolete classnames when upgrading to Tailwind CSS v3.
173
+ * @see [migration-from-tailwind-2](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/migration-from-tailwind-2.md)
174
+ */
175
+ 'tailwindcss/migration-from-tailwind-2': MigrationFromTailwind_2RuleConfig
176
+ }
177
+
178
+ /**
179
+ * Option.
180
+ */
181
+ interface NoArbitraryValueOption {
182
+ callees?: string[]
183
+ ignoredKeys?: string[]
184
+ config?: string | Record<string, any>
185
+ tags?: string[]
186
+
187
+ [k: string]: any
188
+ }
189
+
190
+ /**
191
+ * Options.
192
+ */
193
+ type NoArbitraryValueOptions = [NoArbitraryValueOption?]
194
+
195
+ /**
196
+ * Forbid using arbitrary values in classnames.
197
+ * @see [no-arbitrary-value](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-arbitrary-value.md)
198
+ */
199
+ type NoArbitraryValueRuleConfig = RuleConfig<NoArbitraryValueOptions>
200
+
201
+ /**
202
+ * Forbid using arbitrary values in classnames.
203
+ * @see [no-arbitrary-value](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-arbitrary-value.md)
204
+ */
205
+ interface NoArbitraryValueRule {
206
+ /**
207
+ * Forbid using arbitrary values in classnames.
208
+ * @see [no-arbitrary-value](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-arbitrary-value.md)
209
+ */
210
+ 'tailwindcss/no-arbitrary-value': NoArbitraryValueRuleConfig
211
+ }
212
+
213
+ /**
214
+ * Option.
215
+ */
216
+ interface NoContradictingClassnameOption {
217
+ callees?: string[]
218
+ ignoredKeys?: string[]
219
+ config?: string | Record<string, any>
220
+ tags?: string[]
221
+
222
+ [k: string]: any
223
+ }
224
+
225
+ /**
226
+ * Options.
227
+ */
228
+ type NoContradictingClassnameOptions = [NoContradictingClassnameOption?]
229
+
230
+ /**
231
+ * Avoid contradicting Tailwind CSS classnames (e.g. "w-3 w-5").
232
+ * @see [no-contradicting-classname](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-contradicting-classname.md)
233
+ */
234
+ type NoContradictingClassnameRuleConfig =
235
+ RuleConfig<NoContradictingClassnameOptions>
236
+
237
+ /**
238
+ * Avoid contradicting Tailwind CSS classnames (e.g. "w-3 w-5").
239
+ * @see [no-contradicting-classname](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-contradicting-classname.md)
240
+ */
241
+ interface NoContradictingClassnameRule {
242
+ /**
243
+ * Avoid contradicting Tailwind CSS classnames (e.g. "w-3 w-5").
244
+ * @see [no-contradicting-classname](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-contradicting-classname.md)
245
+ */
246
+ 'tailwindcss/no-contradicting-classname': NoContradictingClassnameRuleConfig
247
+ }
248
+
249
+ /**
250
+ * Option.
251
+ */
252
+ interface NoCustomClassnameOption {
253
+ callees?: string[]
254
+ ignoredKeys?: string[]
255
+ config?: string | Record<string, any>
256
+ cssFiles?: string[]
257
+ cssFilesRefreshRate?: number
258
+ tags?: string[]
259
+ whitelist?: string[]
260
+
261
+ [k: string]: any
262
+ }
263
+
264
+ /**
265
+ * Options.
266
+ */
267
+ type NoCustomClassnameOptions = [NoCustomClassnameOption?]
268
+
269
+ /**
270
+ * Detect classnames which do not belong to Tailwind CSS.
271
+ * @see [no-custom-classname](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-custom-classname.md)
272
+ */
273
+ type NoCustomClassnameRuleConfig = RuleConfig<NoCustomClassnameOptions>
274
+
275
+ /**
276
+ * Detect classnames which do not belong to Tailwind CSS.
277
+ * @see [no-custom-classname](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-custom-classname.md)
278
+ */
279
+ interface NoCustomClassnameRule {
280
+ /**
281
+ * Detect classnames which do not belong to Tailwind CSS.
282
+ * @see [no-custom-classname](https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-custom-classname.md)
283
+ */
284
+ 'tailwindcss/no-custom-classname': NoCustomClassnameRuleConfig
285
+ }
286
+
287
+ /**
288
+ * All TailwindCss rules.
289
+ */
290
+ type TailwindCssRules = ClassnamesOrderRule &
291
+ EnforcesNegativeArbitraryValuesRule &
292
+ EnforcesShorthandRule &
293
+ MigrationFromTailwind_2Rule &
294
+ NoArbitraryValueRule &
295
+ NoContradictingClassnameRule &
296
+ NoCustomClassnameRule
297
+
14
298
  type WrapRuleConfig<T extends {
15
299
  [key: string]: any;
16
300
  }> = {
17
301
  [K in keyof T]: T[K] extends RuleConfig ? T[K] : RuleConfig<T[K]>;
18
302
  };
19
- type EslintFlatRules = WrapRuleConfig<MergeIntersection<RenamePrefix<TypeScriptRules, '@typescript-eslint/', 'ts/'> & RenamePrefix<VitestRules, 'vitest/', 'test/'> & RenamePrefix<NRules, 'n/', 'node/'> & Prefix<Rules, 'antfu/'> & ReactHooksRules & ReactRules & JSDocRules & ImportRules & EslintRules & JsoncRules & VueRules & UnicornRules & EslintCommentsRules & {
303
+ type EslintFlatRules = WrapRuleConfig<MergeIntersection<RenamePrefix<TypeScriptRules, '@typescript-eslint/', 'ts/'> & RenamePrefix<VitestRules, 'vitest/', 'test/'> & RenamePrefix<NRules, 'n/', 'node/'> & Prefix<Rules, 'antfu/'> & ReactHooksRules & ReactRules & JSDocRules & ImportRules & EslintRules & JsoncRules & VueRules & UnicornRules & PrettierRule & TailwindCssRules & EslintCommentsRules & {
20
304
  'test/no-only-tests': RuleConfig<[]>;
21
305
  }>>;
22
306
  type FlatConfigItem = Omit<FlatESLintConfigItem<EslintFlatRules, false>, 'plugins'> & {
@@ -177,6 +461,12 @@ interface OptionsConfig extends OptionsComponentExts {
177
461
  * @default false
178
462
  */
179
463
  svelte?: boolean | OptionsOverrides;
464
+ /**
465
+ * Enable tainwindcss rules.
466
+ *
467
+ * @default auto-detect based on the dependencies
468
+ */
469
+ tailwindcss?: boolean | OptionsOverrides;
180
470
  /**
181
471
  * Enable unocss rules.
182
472
  *
@@ -231,20 +521,6 @@ interface OptionsConfig extends OptionsComponentExts {
231
521
  * @default auto-detect based on the process.env
232
522
  */
233
523
  isInEditor?: boolean;
234
- /**
235
- * Provide overrides for rules for each integration.
236
- *
237
- * @deprecated use `overrides` option in each integration key instead
238
- */
239
- overrides?: {
240
- javascript?: FlatConfigItem['rules'];
241
- typescript?: FlatConfigItem['rules'];
242
- test?: FlatConfigItem['rules'];
243
- vue?: FlatConfigItem['rules'];
244
- jsonc?: FlatConfigItem['rules'];
245
- react?: FlatConfigItem['rules'];
246
- svelte?: FlatConfigItem['rules'];
247
- };
248
524
  }
249
525
 
250
526
  /**
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  // src/index.ts
2
- import process3 from "node:process";
2
+ import process4 from "node:process";
3
3
  import fs from "node:fs";
4
- import { isPackageExists as isPackageExists3 } from "local-pkg";
5
4
 
6
5
  // src/constants/prettier.ts
7
6
  var DEFAULT_PRETTIER_RULES = {
@@ -167,7 +166,7 @@ async function imports() {
167
166
  // src/configs/javascript.ts
168
167
  import globals from "globals";
169
168
  async function javascript(options = {}) {
170
- const { isInEditor = false, overrides = {} } = options;
169
+ const { isInEditor: isInEditor2 = false, overrides = {} } = options;
171
170
  return [
172
171
  {
173
172
  languageOptions: {
@@ -385,7 +384,7 @@ async function javascript(options = {}) {
385
384
  ],
386
385
  "symbol-description": "error",
387
386
  "unicode-bom": ["error", "never"],
388
- "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
387
+ "unused-imports/no-unused-imports": isInEditor2 ? "off" : "error",
389
388
  "unused-imports/no-unused-vars": [
390
389
  "error",
391
390
  {
@@ -506,7 +505,6 @@ function resolveSubOptions(options, key) {
506
505
  function getOverrides(options, key) {
507
506
  const sub = resolveSubOptions(options, key);
508
507
  return {
509
- ...options.overrides?.[key],
510
508
  ..."overrides" in sub ? sub.overrides || {} : {}
511
509
  };
512
510
  }
@@ -1276,7 +1274,7 @@ async function vue(options = {}) {
1276
1274
 
1277
1275
  // src/configs/test.ts
1278
1276
  async function test(options = {}) {
1279
- const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
1277
+ const { files = GLOB_TESTS, isInEditor: isInEditor2 = false, overrides = {} } = options;
1280
1278
  const [pluginVitest, pluginNoOnlyTests] = await Promise.all([
1281
1279
  interopDefault(import("eslint-plugin-vitest")),
1282
1280
  // @ts-expect-error missing types
@@ -1307,7 +1305,7 @@ async function test(options = {}) {
1307
1305
  ],
1308
1306
  "test/no-identical-title": "error",
1309
1307
  "test/no-import-node-test": "error",
1310
- "test/no-only-tests": isInEditor ? "off" : "error",
1308
+ "test/no-only-tests": isInEditor2 ? "off" : "error",
1311
1309
  "test/prefer-hooks-in-order": "error",
1312
1310
  "test/prefer-lowercase-title": "error",
1313
1311
  ...overrides
@@ -1447,7 +1445,6 @@ async function unocss(options = {}) {
1447
1445
 
1448
1446
  // src/configs/formatter.ts
1449
1447
  async function formatter(options = {}, prettierRules2 = {}) {
1450
- await ensurePackages(["eslint-plugin-prettier"]);
1451
1448
  const {
1452
1449
  css = true,
1453
1450
  graphql,
@@ -1622,6 +1619,41 @@ async function svelte(options = {}) {
1622
1619
  ];
1623
1620
  }
1624
1621
 
1622
+ // src/configs/tailwindcss.ts
1623
+ async function tailwindcss(options = {}) {
1624
+ const { overrides } = options;
1625
+ const pluginTailwindcss = await interopDefault(
1626
+ import("eslint-plugin-tailwindcss")
1627
+ );
1628
+ return [
1629
+ {
1630
+ name: "coderwyd:tailwindcss",
1631
+ plugins: {
1632
+ tailwindcss: pluginTailwindcss
1633
+ },
1634
+ rules: {
1635
+ "tailwindcss/classnames-order": "warn",
1636
+ "tailwindcss/enforces-negative-arbitrary-values": "warn",
1637
+ "tailwindcss/enforces-shorthand": "warn",
1638
+ "tailwindcss/migration-from-tailwind-2": "warn",
1639
+ "tailwindcss/no-arbitrary-value": "off",
1640
+ "tailwindcss/no-contradicting-classname": "error",
1641
+ "tailwindcss/no-custom-classname": "off",
1642
+ ...overrides
1643
+ }
1644
+ }
1645
+ ];
1646
+ }
1647
+
1648
+ // src/env.ts
1649
+ import process3 from "node:process";
1650
+ import { isPackageExists as isPackageExists3 } from "local-pkg";
1651
+ var isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI);
1652
+ var hasTypeScript = isPackageExists3("typescript");
1653
+ var hasVue = isPackageExists3("vue") || isPackageExists3("nuxt") || isPackageExists3("vitepress") || isPackageExists3("@slidev/cli");
1654
+ var hasUnocss = isPackageExists3("unocss") || isPackageExists3("@unocss/webpack") || isPackageExists3("@unocss/nuxt");
1655
+ var hasTailwindCSS = isPackageExists3("tailwindcss") && !hasUnocss;
1656
+
1625
1657
  // src/index.ts
1626
1658
  var flatConfigProps = [
1627
1659
  "name",
@@ -1634,18 +1666,18 @@ var flatConfigProps = [
1634
1666
  "rules",
1635
1667
  "settings"
1636
1668
  ];
1637
- var VuePackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
1638
1669
  async function defineConfig(options = {}, ...userConfigs) {
1639
1670
  const {
1640
1671
  componentExts = [],
1641
1672
  gitignore: enableGitignore = true,
1642
- isInEditor = !!((process3.env.VSCODE_PID || process3.env.JETBRAINS_IDE || process3.env.VIM) && !process3.env.CI),
1673
+ isInEditor: isInEditor2 = isInEditor,
1643
1674
  react: enableReact = false,
1644
1675
  svelte: enableSvelte = false,
1645
- typescript: enableTypeScript = isPackageExists3("typescript"),
1676
+ tailwindcss: enableTailwindCSS = hasTailwindCSS,
1677
+ typescript: enableTypeScript = hasTypeScript,
1646
1678
  unocss: enableUnoCSS = false,
1647
1679
  usePrettierrc = true,
1648
- vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
1680
+ vue: enableVue = hasVue
1649
1681
  } = options;
1650
1682
  const configs = [];
1651
1683
  if (enableGitignore) {
@@ -1667,7 +1699,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1667
1699
  configs.push(
1668
1700
  ignores(),
1669
1701
  javascript({
1670
- isInEditor,
1702
+ isInEditor: isInEditor2,
1671
1703
  overrides: getOverrides(options, "javascript")
1672
1704
  }),
1673
1705
  comments(),
@@ -1692,7 +1724,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1692
1724
  if (options.test ?? true) {
1693
1725
  configs.push(
1694
1726
  test({
1695
- isInEditor,
1727
+ isInEditor: isInEditor2,
1696
1728
  overrides: getOverrides(options, "test")
1697
1729
  })
1698
1730
  );
@@ -1730,6 +1762,14 @@ async function defineConfig(options = {}, ...userConfigs) {
1730
1762
  })
1731
1763
  );
1732
1764
  }
1765
+ if (enableTailwindCSS) {
1766
+ configs.push(
1767
+ tailwindcss({
1768
+ ...resolveSubOptions(options, "tailwindcss"),
1769
+ overrides: getOverrides(options, "tailwindcss")
1770
+ })
1771
+ );
1772
+ }
1733
1773
  if (options.jsonc ?? true) {
1734
1774
  configs.push(
1735
1775
  jsonc({
@@ -1747,7 +1787,7 @@ async function defineConfig(options = {}, ...userConfigs) {
1747
1787
  }
1748
1788
  if (usePrettierrc) {
1749
1789
  const prettierConfig = await loadPrettierConfig(
1750
- options.cwd ?? process3.cwd()
1790
+ options.cwd ?? process4.cwd()
1751
1791
  );
1752
1792
  Object.assign(prettierRules2, prettierConfig);
1753
1793
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@coderwyd/eslint-config",
3
3
  "type": "module",
4
- "version": "2.1.7",
5
- "packageManager": "pnpm@8.15.1",
4
+ "version": "2.2.0",
5
+ "packageManager": "pnpm@8.15.3",
6
6
  "description": "Donny's ESLint config",
7
7
  "author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
8
8
  "license": "MIT",
@@ -68,33 +68,34 @@
68
68
  "dependencies": {
69
69
  "@antfu/eslint-define-config": "1.23.0-2",
70
70
  "@antfu/install-pkg": "^0.3.1",
71
- "@eslint-types/jsdoc": "48.0.4",
72
- "@eslint-types/typescript-eslint": "^6.19.1",
73
- "@eslint-types/unicorn": "^50.0.1",
71
+ "@eslint-types/jsdoc": "48.0.6",
72
+ "@eslint-types/typescript-eslint": "^6.21.0",
73
+ "@eslint-types/unicorn": "^51.0.1",
74
74
  "@toml-tools/parser": "^1.0.0",
75
- "@typescript-eslint/eslint-plugin": "^6.18.1",
76
- "@typescript-eslint/parser": "^6.18.1",
77
- "eslint-config-flat-gitignore": "^0.1.2",
75
+ "@typescript-eslint/eslint-plugin": "^7.0.1",
76
+ "@typescript-eslint/parser": "^7.0.1",
77
+ "eslint-config-flat-gitignore": "^0.1.3",
78
78
  "eslint-config-prettier": "^9.1.0",
79
79
  "eslint-plugin-antfu": "^2.1.2",
80
80
  "eslint-plugin-eslint-comments": "^3.2.0",
81
81
  "eslint-plugin-i": "^2.29.1",
82
- "eslint-plugin-jsdoc": "^48.0.4",
82
+ "eslint-plugin-jsdoc": "^48.1.0",
83
83
  "eslint-plugin-jsonc": "^2.13.0",
84
84
  "eslint-plugin-n": "^16.6.2",
85
85
  "eslint-plugin-no-only-tests": "^3.1.0",
86
86
  "eslint-plugin-perfectionist": "^2.5.0",
87
87
  "eslint-plugin-prettier": "^5.1.3",
88
- "eslint-plugin-unicorn": "^50.0.1",
88
+ "eslint-plugin-tailwindcss": "^3.14.2",
89
+ "eslint-plugin-unicorn": "^51.0.1",
89
90
  "eslint-plugin-unused-imports": "^3.0.0",
90
- "eslint-plugin-vitest": "^0.3.21",
91
+ "eslint-plugin-vitest": "^0.3.22",
91
92
  "eslint-plugin-vue": "^9.21.1",
92
- "globals": "^13.24.0",
93
+ "globals": "^14.0.0",
93
94
  "jsonc-eslint-parser": "^2.4.0",
94
95
  "local-pkg": "^0.5.0",
95
96
  "parse-gitignore": "^2.0.0",
96
97
  "picocolors": "^1.0.0",
97
- "prettier": "^3.2.4",
98
+ "prettier": "^3.2.5",
98
99
  "prettier-plugin-toml": "^2.0.1",
99
100
  "prompts": "^2.4.2",
100
101
  "vue-eslint-parser": "^9.4.2",
@@ -104,10 +105,10 @@
104
105
  "@antfu/ni": "^0.21.12",
105
106
  "@types/eslint": "^8.56.2",
106
107
  "@types/fs-extra": "^11.0.4",
107
- "@types/node": "^20.10.8",
108
+ "@types/node": "^20.11.19",
108
109
  "@types/prompts": "^2.4.9",
109
110
  "@types/yargs": "^17.0.32",
110
- "@unocss/eslint-plugin": "^0.58.4",
111
+ "@unocss/eslint-plugin": "^0.58.5",
111
112
  "bumpp": "^9.3.0",
112
113
  "eslint": "^8.56.0",
113
114
  "eslint-flat-config-viewer": "^0.1.11",
@@ -119,11 +120,11 @@
119
120
  "execa": "^8.0.1",
120
121
  "fast-glob": "^3.3.2",
121
122
  "fs-extra": "^11.2.0",
122
- "lint-staged": "^15.2.1",
123
+ "lint-staged": "^15.2.2",
123
124
  "rimraf": "^5.0.5",
124
125
  "simple-git-hooks": "^2.9.0",
125
126
  "svelte-eslint-parser": "^0.33.1",
126
- "tsup": "^8.0.1",
127
+ "tsup": "^8.0.2",
127
128
  "typescript": "^5.3.3"
128
129
  },
129
130
  "simple-git-hooks": {