@wongxy/eslint-config 1.0.0 → 1.1.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.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,35 +17,75 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
18
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
30
 
20
31
  // src/index.ts
21
32
  var src_exports = {};
22
33
  __export(src_exports, {
23
- default: () => src_default
34
+ default: () => wongxy,
35
+ tailwindcss: () => tailwindcss
24
36
  });
25
37
  module.exports = __toCommonJS(src_exports);
26
38
  var import_eslint_config = require("@antfu/eslint-config");
27
39
  var import_local_pkg = require("local-pkg");
28
- var VuePackages = [
29
- "vue",
30
- "nuxt",
31
- "vitepress",
32
- "@slidev/cli"
33
- ];
34
- var ReactPackages = [
35
- "react",
36
- "react-native",
37
- "react-dom",
38
- "next"
39
- ];
40
+
41
+ // src/tailwindcss.ts
42
+ var import_eslint_plugin_tailwindcss = __toESM(require("eslint-plugin-tailwindcss"), 1);
43
+ async function tailwindcss(options) {
44
+ const { overrides = {} } = options ?? {};
45
+ return [
46
+ {
47
+ name: "wongxy/tailwindcss",
48
+ plugins: {
49
+ tw: import_eslint_plugin_tailwindcss.default
50
+ },
51
+ languageOptions: {
52
+ parserOptions: {
53
+ ecmaFeatures: {
54
+ jsx: true
55
+ }
56
+ }
57
+ },
58
+ rules: {
59
+ "tw/classnames-order": "warn",
60
+ "tw/enforces-negative-arbitrary-values": "warn",
61
+ "tw/enforces-shorthand": "warn",
62
+ "tw/migration-from-tailwind-2": "warn",
63
+ "tw/no-arbitrary-value": "off",
64
+ // 'tw/no-custom-classname': 'warn',
65
+ "tw/no-contradicting-classname": "error",
66
+ // 'tw/no-unnecessary-arbitrary-value': 'warn',
67
+ ...overrides
68
+ }
69
+ }
70
+ ];
71
+ }
72
+
73
+ // src/types.ts
74
+ var types_exports = {};
75
+ __reExport(types_exports, require("@antfu/eslint-config"));
76
+
77
+ // src/index.ts
78
+ __reExport(src_exports, types_exports, module.exports);
79
+ var VuePackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
80
+ var ReactPackages = ["react", "react-native", "react-dom", "next"];
40
81
  function wongxy(options = {}, ...userConfigs) {
41
82
  const finalOptions = {
42
83
  ...options,
43
84
  vue: options.vue ?? VuePackages.some((i) => (0, import_local_pkg.isPackageExists)(i)),
44
85
  typescript: options.typescript ?? (0, import_local_pkg.isPackageExists)("typescript"),
45
86
  react: (options.react || options.reactnative) ?? ReactPackages.some((i) => (0, import_local_pkg.isPackageExists)(i)),
46
- reactnative: options.reactnative ?? (0, import_local_pkg.isPackageExists)("react-native")
87
+ reactnative: options.reactnative ?? (0, import_local_pkg.isPackageExists)("react-native"),
88
+ tailwindcss: options.tailwindcss ?? (0, import_local_pkg.isPackageExists)("tailwindcss")
47
89
  };
48
90
  finalOptions.rules = {
49
91
  "no-console": "off",
@@ -92,7 +134,16 @@ function wongxy(options = {}, ...userConfigs) {
92
134
  }
93
135
  };
94
136
  }
137
+ if (finalOptions.tailwindcss) {
138
+ userConfigs.splice(0, 0, tailwindcss({
139
+ overrides: typeof finalOptions.tailwindcss === "object" ? finalOptions.tailwindcss.overrides : void 0
140
+ }));
141
+ }
95
142
  delete finalOptions.reactnative;
143
+ delete finalOptions.tailwindcss;
96
144
  return (0, import_eslint_config.antfu)(finalOptions, ...userConfigs);
97
145
  }
98
- var src_default = wongxy;
146
+ // Annotate the CommonJS export names for ESM import in node:
147
+ 0 && (module.exports = {
148
+ tailwindcss
149
+ });
package/dist/index.d.cts CHANGED
@@ -1,9 +1,174 @@
1
- import { OptionsConfig, TypedFlatConfigItem, Awaitable, ConfigNames } from '@antfu/eslint-config';
2
1
  import { Linter } from 'eslint';
3
2
  import { FlatConfigComposer } from 'eslint-flat-config-utils';
3
+ import { ConfigNames as ConfigNames$2, TypedFlatConfigItem as TypedFlatConfigItem$1, OptionsConfig as OptionsConfig$1, Awaitable } from '@antfu/eslint-config';
4
+ export * from '@antfu/eslint-config';
4
5
 
5
- declare function wongxy(options?: OptionsConfig & TypedFlatConfigItem & {
6
+ /* eslint-disable */
7
+ /* prettier-ignore */
8
+
9
+
10
+ interface RuleOptions {
11
+ /**
12
+ * Enforce a consistent and logical order of the Tailwind CSS classnames
13
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/classnames-order.md
14
+ */
15
+ 'tw/classnames-order'?: Linter.RuleEntry<TwClassnamesOrder>
16
+ /**
17
+ * Warns about dash prefixed classnames using arbitrary values
18
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-negative-arbitrary-values.md
19
+ */
20
+ 'tw/enforces-negative-arbitrary-values'?: Linter.RuleEntry<TwEnforcesNegativeArbitraryValues>
21
+ /**
22
+ * Enforces the usage of shorthand Tailwind CSS classnames
23
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-shorthand.md
24
+ */
25
+ 'tw/enforces-shorthand'?: Linter.RuleEntry<TwEnforcesShorthand>
26
+ /**
27
+ * Detect obsolete classnames when upgrading to Tailwind CSS v3
28
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/migration-from-tailwind-2.md
29
+ */
30
+ 'tw/migration-from-tailwind-2'?: Linter.RuleEntry<TwMigrationFromTailwind2>
31
+ /**
32
+ * Forbid using arbitrary values in classnames
33
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-arbitrary-value.md
34
+ */
35
+ 'tw/no-arbitrary-value'?: Linter.RuleEntry<TwNoArbitraryValue>
36
+ /**
37
+ * Avoid contradicting Tailwind CSS classnames (e.g. "w-3 w-5")
38
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-contradicting-classname.md
39
+ */
40
+ 'tw/no-contradicting-classname'?: Linter.RuleEntry<TwNoContradictingClassname>
41
+ /**
42
+ * Detect classnames which do not belong to Tailwind CSS
43
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-custom-classname.md
44
+ */
45
+ 'tw/no-custom-classname'?: Linter.RuleEntry<TwNoCustomClassname>
46
+ /**
47
+ * Forbid using arbitrary values in classnames when an equivalent preset exists
48
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-unnecessary-arbitrary-value.md
49
+ */
50
+ 'tw/no-unnecessary-arbitrary-value'?: Linter.RuleEntry<TwNoUnnecessaryArbitraryValue>
51
+ }
52
+
53
+ /* ======= Declarations ======= */
54
+ // ----- tw/classnames-order -----
55
+ type TwClassnamesOrder = []|[{
56
+ callees?: string[]
57
+ ignoredKeys?: string[]
58
+ config?: (string | {
59
+ [k: string]: unknown | undefined
60
+ })
61
+ removeDuplicates?: boolean
62
+ tags?: string[]
63
+ [k: string]: unknown | undefined
64
+ }]
65
+ // ----- tw/enforces-negative-arbitrary-values -----
66
+ type TwEnforcesNegativeArbitraryValues = []|[{
67
+ callees?: string[]
68
+ ignoredKeys?: string[]
69
+ config?: (string | {
70
+ [k: string]: unknown | undefined
71
+ })
72
+ tags?: string[]
73
+ [k: string]: unknown | undefined
74
+ }]
75
+ // ----- tw/enforces-shorthand -----
76
+ type TwEnforcesShorthand = []|[{
77
+ callees?: string[]
78
+ ignoredKeys?: string[]
79
+ config?: (string | {
80
+ [k: string]: unknown | undefined
81
+ })
82
+ tags?: string[]
83
+ [k: string]: unknown | undefined
84
+ }]
85
+ // ----- tw/migration-from-tailwind-2 -----
86
+ type TwMigrationFromTailwind2 = []|[{
87
+ callees?: string[]
88
+ ignoredKeys?: string[]
89
+ config?: (string | {
90
+ [k: string]: unknown | undefined
91
+ })
92
+ tags?: string[]
93
+ [k: string]: unknown | undefined
94
+ }]
95
+ // ----- tw/no-arbitrary-value -----
96
+ type TwNoArbitraryValue = []|[{
97
+ callees?: string[]
98
+ ignoredKeys?: string[]
99
+ config?: (string | {
100
+ [k: string]: unknown | undefined
101
+ })
102
+ tags?: string[]
103
+ [k: string]: unknown | undefined
104
+ }]
105
+ // ----- tw/no-contradicting-classname -----
106
+ type TwNoContradictingClassname = []|[{
107
+ callees?: string[]
108
+ ignoredKeys?: string[]
109
+ config?: (string | {
110
+ [k: string]: unknown | undefined
111
+ })
112
+ tags?: string[]
113
+ [k: string]: unknown | undefined
114
+ }]
115
+ // ----- tw/no-custom-classname -----
116
+ type TwNoCustomClassname = []|[{
117
+ callees?: string[]
118
+ ignoredKeys?: string[]
119
+ config?: (string | {
120
+ [k: string]: unknown | undefined
121
+ })
122
+ cssFiles?: string[]
123
+ cssFilesRefreshRate?: number
124
+ tags?: string[]
125
+ whitelist?: string[]
126
+ [k: string]: unknown | undefined
127
+ }]
128
+ // ----- tw/no-unnecessary-arbitrary-value -----
129
+ type TwNoUnnecessaryArbitraryValue = []|[{
130
+ callees?: string[]
131
+ ignoredKeys?: string[]
132
+ config?: (string | {
133
+ [k: string]: unknown | undefined
134
+ })
135
+ tags?: string[]
136
+ [k: string]: unknown | undefined
137
+ }]
138
+ // Names of all the configs
139
+ type ConfigNames$1 = 'wongxy/tailwindcss'
140
+
141
+ interface OptionsOverrides {
142
+ overrides?: TypedFlatConfigItem['rules'];
143
+ }
144
+ type ConfigNames = ConfigNames$2 & ConfigNames$1;
145
+ type TypedFlatConfigItem = TypedFlatConfigItem$1 & MyTypedFlatConfigItem;
146
+ type MyTypedFlatConfigItem = Omit<Linter.Config<Linter.RulesRecord & RuleOptions>, 'plugins'>;
147
+ interface OptionsConfig extends OptionsConfig$1 {
148
+ /**
149
+ * Enable Tailwind rules.
150
+ *
151
+ * @default auto-detect based on the dependencies
152
+ */
153
+ tailwindcss?: boolean | OptionsOverrides;
154
+ /**
155
+ * Enable React Native support.
156
+ *
157
+ * Will enable `react` support automatically.
158
+ *
159
+ * @default auto-detect based on the dependencies
160
+ */
6
161
  reactnative?: boolean;
7
- }, ...userConfigs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.Config[]>[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
162
+ /**
163
+ * Enable react rules.
164
+ *
165
+ * @default auto-detect based on the dependencies
166
+ */
167
+ react?: boolean | OptionsOverrides;
168
+ }
169
+
170
+ declare function tailwindcss(options?: OptionsOverrides): Promise<TypedFlatConfigItem$1[]>;
171
+
172
+ declare function wongxy(options?: OptionsConfig & TypedFlatConfigItem, ...userConfigs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.Config[]>[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
8
173
 
9
- export { wongxy as default };
174
+ export { type ConfigNames, type MyTypedFlatConfigItem, type OptionsConfig, type OptionsOverrides, type TypedFlatConfigItem, wongxy as default, tailwindcss };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,174 @@
1
- import { OptionsConfig, TypedFlatConfigItem, Awaitable, ConfigNames } from '@antfu/eslint-config';
2
1
  import { Linter } from 'eslint';
3
2
  import { FlatConfigComposer } from 'eslint-flat-config-utils';
3
+ import { ConfigNames as ConfigNames$2, TypedFlatConfigItem as TypedFlatConfigItem$1, OptionsConfig as OptionsConfig$1, Awaitable } from '@antfu/eslint-config';
4
+ export * from '@antfu/eslint-config';
4
5
 
5
- declare function wongxy(options?: OptionsConfig & TypedFlatConfigItem & {
6
+ /* eslint-disable */
7
+ /* prettier-ignore */
8
+
9
+
10
+ interface RuleOptions {
11
+ /**
12
+ * Enforce a consistent and logical order of the Tailwind CSS classnames
13
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/classnames-order.md
14
+ */
15
+ 'tw/classnames-order'?: Linter.RuleEntry<TwClassnamesOrder>
16
+ /**
17
+ * Warns about dash prefixed classnames using arbitrary values
18
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-negative-arbitrary-values.md
19
+ */
20
+ 'tw/enforces-negative-arbitrary-values'?: Linter.RuleEntry<TwEnforcesNegativeArbitraryValues>
21
+ /**
22
+ * Enforces the usage of shorthand Tailwind CSS classnames
23
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/enforces-shorthand.md
24
+ */
25
+ 'tw/enforces-shorthand'?: Linter.RuleEntry<TwEnforcesShorthand>
26
+ /**
27
+ * Detect obsolete classnames when upgrading to Tailwind CSS v3
28
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/migration-from-tailwind-2.md
29
+ */
30
+ 'tw/migration-from-tailwind-2'?: Linter.RuleEntry<TwMigrationFromTailwind2>
31
+ /**
32
+ * Forbid using arbitrary values in classnames
33
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-arbitrary-value.md
34
+ */
35
+ 'tw/no-arbitrary-value'?: Linter.RuleEntry<TwNoArbitraryValue>
36
+ /**
37
+ * Avoid contradicting Tailwind CSS classnames (e.g. "w-3 w-5")
38
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-contradicting-classname.md
39
+ */
40
+ 'tw/no-contradicting-classname'?: Linter.RuleEntry<TwNoContradictingClassname>
41
+ /**
42
+ * Detect classnames which do not belong to Tailwind CSS
43
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-custom-classname.md
44
+ */
45
+ 'tw/no-custom-classname'?: Linter.RuleEntry<TwNoCustomClassname>
46
+ /**
47
+ * Forbid using arbitrary values in classnames when an equivalent preset exists
48
+ * @see https://github.com/francoismassart/eslint-plugin-tailwindcss/tree/master/docs/rules/no-unnecessary-arbitrary-value.md
49
+ */
50
+ 'tw/no-unnecessary-arbitrary-value'?: Linter.RuleEntry<TwNoUnnecessaryArbitraryValue>
51
+ }
52
+
53
+ /* ======= Declarations ======= */
54
+ // ----- tw/classnames-order -----
55
+ type TwClassnamesOrder = []|[{
56
+ callees?: string[]
57
+ ignoredKeys?: string[]
58
+ config?: (string | {
59
+ [k: string]: unknown | undefined
60
+ })
61
+ removeDuplicates?: boolean
62
+ tags?: string[]
63
+ [k: string]: unknown | undefined
64
+ }]
65
+ // ----- tw/enforces-negative-arbitrary-values -----
66
+ type TwEnforcesNegativeArbitraryValues = []|[{
67
+ callees?: string[]
68
+ ignoredKeys?: string[]
69
+ config?: (string | {
70
+ [k: string]: unknown | undefined
71
+ })
72
+ tags?: string[]
73
+ [k: string]: unknown | undefined
74
+ }]
75
+ // ----- tw/enforces-shorthand -----
76
+ type TwEnforcesShorthand = []|[{
77
+ callees?: string[]
78
+ ignoredKeys?: string[]
79
+ config?: (string | {
80
+ [k: string]: unknown | undefined
81
+ })
82
+ tags?: string[]
83
+ [k: string]: unknown | undefined
84
+ }]
85
+ // ----- tw/migration-from-tailwind-2 -----
86
+ type TwMigrationFromTailwind2 = []|[{
87
+ callees?: string[]
88
+ ignoredKeys?: string[]
89
+ config?: (string | {
90
+ [k: string]: unknown | undefined
91
+ })
92
+ tags?: string[]
93
+ [k: string]: unknown | undefined
94
+ }]
95
+ // ----- tw/no-arbitrary-value -----
96
+ type TwNoArbitraryValue = []|[{
97
+ callees?: string[]
98
+ ignoredKeys?: string[]
99
+ config?: (string | {
100
+ [k: string]: unknown | undefined
101
+ })
102
+ tags?: string[]
103
+ [k: string]: unknown | undefined
104
+ }]
105
+ // ----- tw/no-contradicting-classname -----
106
+ type TwNoContradictingClassname = []|[{
107
+ callees?: string[]
108
+ ignoredKeys?: string[]
109
+ config?: (string | {
110
+ [k: string]: unknown | undefined
111
+ })
112
+ tags?: string[]
113
+ [k: string]: unknown | undefined
114
+ }]
115
+ // ----- tw/no-custom-classname -----
116
+ type TwNoCustomClassname = []|[{
117
+ callees?: string[]
118
+ ignoredKeys?: string[]
119
+ config?: (string | {
120
+ [k: string]: unknown | undefined
121
+ })
122
+ cssFiles?: string[]
123
+ cssFilesRefreshRate?: number
124
+ tags?: string[]
125
+ whitelist?: string[]
126
+ [k: string]: unknown | undefined
127
+ }]
128
+ // ----- tw/no-unnecessary-arbitrary-value -----
129
+ type TwNoUnnecessaryArbitraryValue = []|[{
130
+ callees?: string[]
131
+ ignoredKeys?: string[]
132
+ config?: (string | {
133
+ [k: string]: unknown | undefined
134
+ })
135
+ tags?: string[]
136
+ [k: string]: unknown | undefined
137
+ }]
138
+ // Names of all the configs
139
+ type ConfigNames$1 = 'wongxy/tailwindcss'
140
+
141
+ interface OptionsOverrides {
142
+ overrides?: TypedFlatConfigItem['rules'];
143
+ }
144
+ type ConfigNames = ConfigNames$2 & ConfigNames$1;
145
+ type TypedFlatConfigItem = TypedFlatConfigItem$1 & MyTypedFlatConfigItem;
146
+ type MyTypedFlatConfigItem = Omit<Linter.Config<Linter.RulesRecord & RuleOptions>, 'plugins'>;
147
+ interface OptionsConfig extends OptionsConfig$1 {
148
+ /**
149
+ * Enable Tailwind rules.
150
+ *
151
+ * @default auto-detect based on the dependencies
152
+ */
153
+ tailwindcss?: boolean | OptionsOverrides;
154
+ /**
155
+ * Enable React Native support.
156
+ *
157
+ * Will enable `react` support automatically.
158
+ *
159
+ * @default auto-detect based on the dependencies
160
+ */
6
161
  reactnative?: boolean;
7
- }, ...userConfigs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.Config[]>[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
162
+ /**
163
+ * Enable react rules.
164
+ *
165
+ * @default auto-detect based on the dependencies
166
+ */
167
+ react?: boolean | OptionsOverrides;
168
+ }
169
+
170
+ declare function tailwindcss(options?: OptionsOverrides): Promise<TypedFlatConfigItem$1[]>;
171
+
172
+ declare function wongxy(options?: OptionsConfig & TypedFlatConfigItem, ...userConfigs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.Config[]>[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
8
173
 
9
- export { wongxy as default };
174
+ export { type ConfigNames, type MyTypedFlatConfigItem, type OptionsConfig, type OptionsOverrides, type TypedFlatConfigItem, wongxy as default, tailwindcss };
package/dist/index.js CHANGED
@@ -1,25 +1,79 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+
1
19
  // src/index.ts
20
+ var src_exports = {};
21
+ __export(src_exports, {
22
+ default: () => wongxy,
23
+ tailwindcss: () => tailwindcss
24
+ });
2
25
  import { antfu } from "@antfu/eslint-config";
3
26
  import { isPackageExists } from "local-pkg";
4
- var VuePackages = [
5
- "vue",
6
- "nuxt",
7
- "vitepress",
8
- "@slidev/cli"
9
- ];
10
- var ReactPackages = [
11
- "react",
12
- "react-native",
13
- "react-dom",
14
- "next"
15
- ];
27
+
28
+ // src/tailwindcss.ts
29
+ import pluginTailwind from "eslint-plugin-tailwindcss";
30
+ async function tailwindcss(options) {
31
+ const { overrides = {} } = options ?? {};
32
+ return [
33
+ {
34
+ name: "wongxy/tailwindcss",
35
+ plugins: {
36
+ tw: pluginTailwind
37
+ },
38
+ languageOptions: {
39
+ parserOptions: {
40
+ ecmaFeatures: {
41
+ jsx: true
42
+ }
43
+ }
44
+ },
45
+ rules: {
46
+ "tw/classnames-order": "warn",
47
+ "tw/enforces-negative-arbitrary-values": "warn",
48
+ "tw/enforces-shorthand": "warn",
49
+ "tw/migration-from-tailwind-2": "warn",
50
+ "tw/no-arbitrary-value": "off",
51
+ // 'tw/no-custom-classname': 'warn',
52
+ "tw/no-contradicting-classname": "error",
53
+ // 'tw/no-unnecessary-arbitrary-value': 'warn',
54
+ ...overrides
55
+ }
56
+ }
57
+ ];
58
+ }
59
+
60
+ // src/types.ts
61
+ var types_exports = {};
62
+ __reExport(types_exports, eslint_config_star);
63
+ import * as eslint_config_star from "@antfu/eslint-config";
64
+
65
+ // src/index.ts
66
+ __reExport(src_exports, types_exports);
67
+ var VuePackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
68
+ var ReactPackages = ["react", "react-native", "react-dom", "next"];
16
69
  function wongxy(options = {}, ...userConfigs) {
17
70
  const finalOptions = {
18
71
  ...options,
19
72
  vue: options.vue ?? VuePackages.some((i) => isPackageExists(i)),
20
73
  typescript: options.typescript ?? isPackageExists("typescript"),
21
74
  react: (options.react || options.reactnative) ?? ReactPackages.some((i) => isPackageExists(i)),
22
- reactnative: options.reactnative ?? isPackageExists("react-native")
75
+ reactnative: options.reactnative ?? isPackageExists("react-native"),
76
+ tailwindcss: options.tailwindcss ?? isPackageExists("tailwindcss")
23
77
  };
24
78
  finalOptions.rules = {
25
79
  "no-console": "off",
@@ -68,10 +122,16 @@ function wongxy(options = {}, ...userConfigs) {
68
122
  }
69
123
  };
70
124
  }
125
+ if (finalOptions.tailwindcss) {
126
+ userConfigs.splice(0, 0, tailwindcss({
127
+ overrides: typeof finalOptions.tailwindcss === "object" ? finalOptions.tailwindcss.overrides : void 0
128
+ }));
129
+ }
71
130
  delete finalOptions.reactnative;
131
+ delete finalOptions.tailwindcss;
72
132
  return antfu(finalOptions, ...userConfigs);
73
133
  }
74
- var src_default = wongxy;
75
134
  export {
76
- src_default as default
135
+ wongxy as default,
136
+ tailwindcss
77
137
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wongxy/eslint-config",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.1.0",
5
5
  "description": "xiyaowong's eslint config",
6
6
  "author": "xiyaowong (https://github.com/xiyaowong)",
7
7
  "license": "MIT",
@@ -20,7 +20,8 @@
20
20
  "@unocss/eslint-plugin": ">=0.50.0",
21
21
  "eslint": ">=8.40.0",
22
22
  "eslint-plugin-react-hooks": "^4.6.0",
23
- "eslint-plugin-react-refresh": "^0.4.4"
23
+ "eslint-plugin-react-refresh": "^0.4.4",
24
+ "eslint-plugin-tailwindcss": ">=3.17.4"
24
25
  },
25
26
  "dependencies": {
26
27
  "@antfu/eslint-config": "^2.24.1",
@@ -28,20 +29,24 @@
28
29
  },
29
30
  "devDependencies": {
30
31
  "@types/eslint": "^9.6.0",
32
+ "@types/node": "^22.2.0",
31
33
  "bumpp": "^9.4.2",
32
34
  "eslint": "^9.8.0",
33
35
  "eslint-flat-config-viewer": "^0.1.20",
36
+ "eslint-typegen": "^0.3.0",
37
+ "esno": "^4.7.0",
34
38
  "tsup": "^8.2.4",
35
39
  "typescript": "5.4.5"
36
40
  },
37
41
  "scripts": {
38
- "build": "tsup --format esm,cjs --clean --dts",
42
+ "build": "nr typegen && tsup --format esm,cjs --clean --dts",
39
43
  "stub": "tsup --format esm",
40
44
  "dev": "tsup --format esm,cjs --watch & eslint-flat-config-viewer",
41
45
  "lint": "pnpm run stub && eslint .",
42
46
  "lint:fix": "pnpm run stub && eslint . --fix",
43
47
  "release": "bumpp && pnpm publish",
44
48
  "preview": "eslint-flat-config-viewer",
49
+ "typegen": "esno scripts/typegen.ts",
45
50
  "typecheck": "tsc --noEmit"
46
51
  }
47
52
  }