@wongxy/eslint-config 0.0.28 → 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,59 +17,133 @@ 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
- function wongxy(options = {}, ...userConfigs) {
28
- const finalOptions = { ...options, react: options.react || options.reactnative };
29
- const configs = [];
30
- configs.push({
31
- name: "wongxy/general",
32
- rules: {
33
- "no-console": "off",
34
- "no-alert": "off",
35
- "no-multiple-empty-lines": "warn",
36
- "antfu/top-level-function": "off",
37
- "antfu/if-newline": "off",
38
- "import/order": ["error", { "newlines-between": "always" }],
39
- "style/brace-style": ["error", "1tbs", { allowSingleLine: true }]
40
- }
41
- });
42
- if (options.vue) {
43
- configs.push({
44
- name: "wongxy/vue",
45
- files: ["**/*.vue"],
39
+ var import_local_pkg = require("local-pkg");
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
+ },
46
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"];
81
+ function wongxy(options = {}, ...userConfigs) {
82
+ const finalOptions = {
83
+ ...options,
84
+ vue: options.vue ?? VuePackages.some((i) => (0, import_local_pkg.isPackageExists)(i)),
85
+ typescript: options.typescript ?? (0, import_local_pkg.isPackageExists)("typescript"),
86
+ react: (options.react || options.reactnative) ?? ReactPackages.some((i) => (0, import_local_pkg.isPackageExists)(i)),
87
+ reactnative: options.reactnative ?? (0, import_local_pkg.isPackageExists)("react-native"),
88
+ tailwindcss: options.tailwindcss ?? (0, import_local_pkg.isPackageExists)("tailwindcss")
89
+ };
90
+ finalOptions.rules = {
91
+ "no-console": "off",
92
+ "no-alert": "off",
93
+ "no-multiple-empty-lines": "warn",
94
+ "antfu/top-level-function": "off",
95
+ "antfu/if-newline": "off",
96
+ "import/order": ["error", { "newlines-between": "always" }],
97
+ "style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
98
+ ...finalOptions.rules
99
+ };
100
+ if (finalOptions.vue) {
101
+ const vue = typeof finalOptions.vue === "object" ? finalOptions.vue : {};
102
+ finalOptions.vue = {
103
+ ...vue,
104
+ overrides: {
47
105
  "vue/singleline-html-element-content-newline": "off",
48
106
  "vue/valid-template-root": "off",
49
107
  "vue/block-order": ["warn", { order: [["script", "template"], "style"] }],
50
- "vue/custom-event-name-casing": "off"
108
+ "vue/custom-event-name-casing": "off",
109
+ ...vue.overrides
51
110
  }
52
- });
111
+ };
53
112
  }
54
- if (options.react) {
55
- configs.push({
56
- name: "wongxy/react",
57
- rules: {
58
- "react/prefer-destructuring-assignment": "off"
113
+ if (finalOptions.react) {
114
+ const react = typeof finalOptions.react === "object" ? finalOptions.react : {};
115
+ finalOptions.react = {
116
+ ...react,
117
+ overrides: {
118
+ "react/prefer-destructuring-assignment": "off",
119
+ ...react.overrides
59
120
  }
60
- });
121
+ };
61
122
  }
62
- if (options.reactnative) {
63
- configs.push({
64
- name: "wongxy/reactnative",
65
- rules: {
66
- "ts/no-require-imports": "off",
67
- "ts/no-use-before-define": "off"
123
+ if (finalOptions.typescript) {
124
+ const typescript = typeof finalOptions.typescript === "object" ? finalOptions.typescript : {};
125
+ finalOptions.typescript = {
126
+ ...typescript,
127
+ overrides: {
128
+ "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, fixStyle: "inline-type-imports", prefer: "type-imports" }],
129
+ ...finalOptions.reactnative ? {
130
+ "ts/no-require-imports": "off",
131
+ "ts/no-use-before-define": "off"
132
+ } : void 0,
133
+ ...typescript.overrides
68
134
  }
69
- });
135
+ };
136
+ }
137
+ if (finalOptions.tailwindcss) {
138
+ userConfigs.splice(0, 0, tailwindcss({
139
+ overrides: typeof finalOptions.tailwindcss === "object" ? finalOptions.tailwindcss.overrides : void 0
140
+ }));
70
141
  }
71
- return (0, import_eslint_config.antfu)(finalOptions, ...configs, ...userConfigs);
142
+ delete finalOptions.reactnative;
143
+ delete finalOptions.tailwindcss;
144
+ return (0, import_eslint_config.antfu)(finalOptions, ...userConfigs);
72
145
  }
73
- 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,52 +1,137 @@
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
- function wongxy(options = {}, ...userConfigs) {
4
- const finalOptions = { ...options, react: options.react || options.reactnative };
5
- const configs = [];
6
- configs.push({
7
- name: "wongxy/general",
8
- rules: {
9
- "no-console": "off",
10
- "no-alert": "off",
11
- "no-multiple-empty-lines": "warn",
12
- "antfu/top-level-function": "off",
13
- "antfu/if-newline": "off",
14
- "import/order": ["error", { "newlines-between": "always" }],
15
- "style/brace-style": ["error", "1tbs", { allowSingleLine: true }]
16
- }
17
- });
18
- if (options.vue) {
19
- configs.push({
20
- name: "wongxy/vue",
21
- files: ["**/*.vue"],
26
+ import { isPackageExists } from "local-pkg";
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
+ },
22
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"];
69
+ function wongxy(options = {}, ...userConfigs) {
70
+ const finalOptions = {
71
+ ...options,
72
+ vue: options.vue ?? VuePackages.some((i) => isPackageExists(i)),
73
+ typescript: options.typescript ?? isPackageExists("typescript"),
74
+ react: (options.react || options.reactnative) ?? ReactPackages.some((i) => isPackageExists(i)),
75
+ reactnative: options.reactnative ?? isPackageExists("react-native"),
76
+ tailwindcss: options.tailwindcss ?? isPackageExists("tailwindcss")
77
+ };
78
+ finalOptions.rules = {
79
+ "no-console": "off",
80
+ "no-alert": "off",
81
+ "no-multiple-empty-lines": "warn",
82
+ "antfu/top-level-function": "off",
83
+ "antfu/if-newline": "off",
84
+ "import/order": ["error", { "newlines-between": "always" }],
85
+ "style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
86
+ ...finalOptions.rules
87
+ };
88
+ if (finalOptions.vue) {
89
+ const vue = typeof finalOptions.vue === "object" ? finalOptions.vue : {};
90
+ finalOptions.vue = {
91
+ ...vue,
92
+ overrides: {
23
93
  "vue/singleline-html-element-content-newline": "off",
24
94
  "vue/valid-template-root": "off",
25
95
  "vue/block-order": ["warn", { order: [["script", "template"], "style"] }],
26
- "vue/custom-event-name-casing": "off"
96
+ "vue/custom-event-name-casing": "off",
97
+ ...vue.overrides
27
98
  }
28
- });
99
+ };
29
100
  }
30
- if (options.react) {
31
- configs.push({
32
- name: "wongxy/react",
33
- rules: {
34
- "react/prefer-destructuring-assignment": "off"
101
+ if (finalOptions.react) {
102
+ const react = typeof finalOptions.react === "object" ? finalOptions.react : {};
103
+ finalOptions.react = {
104
+ ...react,
105
+ overrides: {
106
+ "react/prefer-destructuring-assignment": "off",
107
+ ...react.overrides
35
108
  }
36
- });
109
+ };
37
110
  }
38
- if (options.reactnative) {
39
- configs.push({
40
- name: "wongxy/reactnative",
41
- rules: {
42
- "ts/no-require-imports": "off",
43
- "ts/no-use-before-define": "off"
111
+ if (finalOptions.typescript) {
112
+ const typescript = typeof finalOptions.typescript === "object" ? finalOptions.typescript : {};
113
+ finalOptions.typescript = {
114
+ ...typescript,
115
+ overrides: {
116
+ "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, fixStyle: "inline-type-imports", prefer: "type-imports" }],
117
+ ...finalOptions.reactnative ? {
118
+ "ts/no-require-imports": "off",
119
+ "ts/no-use-before-define": "off"
120
+ } : void 0,
121
+ ...typescript.overrides
44
122
  }
45
- });
123
+ };
124
+ }
125
+ if (finalOptions.tailwindcss) {
126
+ userConfigs.splice(0, 0, tailwindcss({
127
+ overrides: typeof finalOptions.tailwindcss === "object" ? finalOptions.tailwindcss.overrides : void 0
128
+ }));
46
129
  }
47
- return antfu(finalOptions, ...configs, ...userConfigs);
130
+ delete finalOptions.reactnative;
131
+ delete finalOptions.tailwindcss;
132
+ return antfu(finalOptions, ...userConfigs);
48
133
  }
49
- var src_default = wongxy;
50
134
  export {
51
- src_default as default
135
+ wongxy as default,
136
+ tailwindcss
52
137
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wongxy/eslint-config",
3
3
  "type": "module",
4
- "version": "0.0.28",
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,27 +20,33 @@
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
- "@antfu/eslint-config": "^2.24.1"
27
+ "@antfu/eslint-config": "^2.24.1",
28
+ "local-pkg": "^0.5.0"
27
29
  },
28
30
  "devDependencies": {
29
31
  "@types/eslint": "^9.6.0",
32
+ "@types/node": "^22.2.0",
30
33
  "bumpp": "^9.4.2",
31
34
  "eslint": "^9.8.0",
32
35
  "eslint-flat-config-viewer": "^0.1.20",
36
+ "eslint-typegen": "^0.3.0",
37
+ "esno": "^4.7.0",
33
38
  "tsup": "^8.2.4",
34
39
  "typescript": "5.4.5"
35
40
  },
36
41
  "scripts": {
37
- "build": "tsup --format esm,cjs --clean --dts",
42
+ "build": "nr typegen && tsup --format esm,cjs --clean --dts",
38
43
  "stub": "tsup --format esm",
39
44
  "dev": "tsup --format esm,cjs --watch & eslint-flat-config-viewer",
40
45
  "lint": "pnpm run stub && eslint .",
41
46
  "lint:fix": "pnpm run stub && eslint . --fix",
42
47
  "release": "bumpp && pnpm publish",
43
48
  "preview": "eslint-flat-config-viewer",
49
+ "typegen": "esno scripts/typegen.ts",
44
50
  "typecheck": "tsc --noEmit"
45
51
  }
46
52
  }