@wongxy/eslint-config 2.0.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,24 +1,27 @@
1
- import { __export, __reExport } from "./chunk-CHLpw0oG.js";
2
- import { antfu } from "@antfu/eslint-config";
1
+ import { GLOB_SRC, GLOB_TS, GLOB_TSX, GLOB_VUE, antfu, getOverrides } from "@antfu/eslint-config";
3
2
  import { isPackageExists } from "local-pkg";
4
- import pluginTailwind from "eslint-plugin-tailwindcss";
5
-
6
- export * from "@antfu/eslint-config"
3
+ import pluginTailwind from "eslint-plugin-better-tailwindcss";
7
4
 
8
5
  //#region src/tailwindcss.ts
9
- async function tailwindcss(options) {
10
- const { overrides = {} } = options ?? {};
6
+ async function tailwindcss(options = {}) {
7
+ const { overrides = {}, settings } = options;
8
+ const rules = {
9
+ "tw/enforce-consistent-class-order": "warn",
10
+ "tw/enforce-consistent-line-wrapping": ["warn", { printWidth: 100 }],
11
+ "tw/no-duplicate-classes": "warn",
12
+ "tw/no-unnecessary-whitespace": "warn",
13
+ "tw/no-conflicting-classes": "warn",
14
+ "tw/no-unregistered-classes": "warn"
15
+ };
11
16
  return [{
12
- name: "wongxy/tailwindcss",
17
+ name: "wongxy/tailwindcss/setup",
13
18
  plugins: { tw: pluginTailwind },
14
19
  languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
20
+ ...!!settings && { settings: { "better-tailwindcss": settings } }
21
+ }, {
22
+ name: "wongxy/tailwindcss/rules",
15
23
  rules: {
16
- "tw/classnames-order": "warn",
17
- "tw/enforces-negative-arbitrary-values": "warn",
18
- "tw/enforces-shorthand": "warn",
19
- "tw/migration-from-tailwind-2": "warn",
20
- "tw/no-arbitrary-value": "off",
21
- "tw/no-contradicting-classname": "error",
24
+ ...rules,
22
25
  ...overrides
23
26
  }
24
27
  }];
@@ -26,11 +29,6 @@ async function tailwindcss(options) {
26
29
 
27
30
  //#endregion
28
31
  //#region src/index.ts
29
- var src_exports = {};
30
- __export(src_exports, {
31
- default: () => wongxy,
32
- tailwindcss: () => tailwindcss
33
- });
34
32
  const VuePackages = [
35
33
  "vue",
36
34
  "nuxt",
@@ -43,79 +41,69 @@ const ReactPackages = [
43
41
  "react-dom",
44
42
  "next"
45
43
  ];
46
- function wongxy(options, ...userConfigs) {
47
- options = options ?? {};
48
- const finalOptions = {
49
- ...options,
50
- vue: options.vue ?? VuePackages.some((i) => isPackageExists(i)),
51
- typescript: options.typescript ?? isPackageExists("typescript"),
52
- react: (options.react || options.reactnative) ?? ReactPackages.some((i) => isPackageExists(i)),
53
- reactnative: options.reactnative ?? isPackageExists("react-native"),
54
- tailwindcss: options.tailwindcss ?? isPackageExists("tailwindcss")
55
- };
56
- const rules = {
57
- "no-console": "off",
58
- "no-alert": "off",
59
- "no-multiple-empty-lines": "warn",
60
- "antfu/top-level-function": "off",
61
- "antfu/if-newline": "off",
62
- "style/brace-style": [
63
- "error",
64
- "1tbs",
65
- { allowSingleLine: true }
66
- ]
67
- };
68
- for (const key in finalOptions.rules) delete rules[key];
69
- userConfigs.splice(0, 0, {
70
- name: "wongxy/rules",
71
- rules
44
+ function resolveRules(overrides, rules) {
45
+ return Object.fromEntries(Object.entries(rules).filter(([k]) => !overrides[k]));
46
+ }
47
+ function wongxy(options = {}, ...userConfigs) {
48
+ const { react: enableReact = ReactPackages.some((i) => isPackageExists(i)), typescript: enableTypeScript = isPackageExists("typescript"), vue: enableVue = VuePackages.some((i) => isPackageExists(i)), tailwindcss: enableTailwind = isPackageExists("tailwindcss"), reactnative: enableReactNative = isPackageExists("react-native") } = options;
49
+ const configs = [];
50
+ configs.push({
51
+ name: "wongxy/common",
52
+ rules: resolveRules(options.rules ?? {}, {
53
+ "no-console": "off",
54
+ "no-alert": "off",
55
+ "no-multiple-empty-lines": "warn",
56
+ "antfu/top-level-function": "off",
57
+ "antfu/if-newline": "off",
58
+ "style/brace-style": [
59
+ "error",
60
+ "1tbs",
61
+ { allowSingleLine: true }
62
+ ],
63
+ "perfectionist/sort-jsx-props": ["warn", {
64
+ order: "asc",
65
+ type: "natural"
66
+ }]
67
+ })
72
68
  });
73
- if (finalOptions.vue) {
74
- const vue = typeof finalOptions.vue === "object" ? finalOptions.vue : {};
75
- finalOptions.vue = {
76
- ...vue,
77
- overrides: {
78
- "vue/singleline-html-element-content-newline": "off",
79
- "vue/valid-template-root": "off",
80
- "vue/block-order": ["warn", { order: [["script", "template"], "style"] }],
81
- "vue/custom-event-name-casing": "off",
82
- ...vue.overrides
83
- }
84
- };
85
- }
86
- if (finalOptions.react) {
87
- const react = typeof finalOptions.react === "object" ? finalOptions.react : {};
88
- finalOptions.react = {
89
- ...react,
90
- overrides: {
91
- "react/prefer-destructuring-assignment": "off",
92
- ...react.overrides
93
- }
94
- };
95
- }
96
- if (finalOptions.typescript) {
97
- const typescript = typeof finalOptions.typescript === "object" ? finalOptions.typescript : {};
98
- finalOptions.typescript = {
99
- ...typescript,
100
- overrides: {
101
- "ts/consistent-type-imports": ["error", {
102
- disallowTypeAnnotations: false,
103
- fixStyle: "inline-type-imports",
104
- prefer: "type-imports"
105
- }],
106
- ...finalOptions.reactnative ? {
107
- "ts/no-require-imports": "off",
108
- "ts/no-use-before-define": "off"
109
- } : void 0,
110
- ...typescript.overrides
111
- }
112
- };
69
+ if (enableVue) configs.push({
70
+ name: "wongxy/vue",
71
+ files: [GLOB_VUE],
72
+ rules: resolveRules(getOverrides(options, "vue"), {
73
+ "vue/singleline-html-element-content-newline": "off",
74
+ "vue/valid-template-root": "off",
75
+ "vue/block-order": ["warn", { order: [["script", "template"], "style"] }],
76
+ "vue/custom-event-name-casing": "off"
77
+ })
78
+ });
79
+ if (enableReact) configs.push({
80
+ name: "wongxy/react",
81
+ files: [GLOB_SRC],
82
+ rules: resolveRules(getOverrides(options, "react"), { "react/prefer-destructuring-assignment": "off" })
83
+ });
84
+ if (enableTypeScript) configs.push({
85
+ name: "wongxy/typescript",
86
+ files: [GLOB_TS, GLOB_TSX],
87
+ rules: resolveRules(getOverrides(options, "typescript"), { "ts/consistent-type-imports": ["error", {
88
+ disallowTypeAnnotations: false,
89
+ fixStyle: "inline-type-imports",
90
+ prefer: "type-imports"
91
+ }] })
92
+ });
93
+ if (enableReactNative) configs.push({
94
+ name: "wongxy/reactnative",
95
+ files: [GLOB_TS, GLOB_TSX],
96
+ rules: resolveRules(getOverrides(options, "typescript"), {
97
+ "ts/no-require-imports": "off",
98
+ "ts/no-use-before-define": "off"
99
+ })
100
+ });
101
+ if (enableTailwind) {
102
+ const tw = typeof options.tailwindcss === "object" ? options.tailwindcss : void 0;
103
+ configs.push(tailwindcss(tw));
113
104
  }
114
- if (finalOptions.tailwindcss) userConfigs.splice(0, 0, tailwindcss({ overrides: typeof finalOptions.tailwindcss === "object" ? finalOptions.tailwindcss.overrides : void 0 }));
115
- delete finalOptions.reactnative;
116
- delete finalOptions.tailwindcss;
117
- return antfu(finalOptions, ...userConfigs);
105
+ return antfu(options, ...configs, ...userConfigs);
118
106
  }
119
107
 
120
108
  //#endregion
121
- export { wongxy as default, tailwindcss };
109
+ export { wongxy as default };
package/package.json CHANGED
@@ -1,17 +1,15 @@
1
1
  {
2
2
  "name": "@wongxy/eslint-config",
3
3
  "type": "module",
4
- "version": "2.0.1",
4
+ "version": "3.0.0",
5
5
  "description": "xiyaowong's eslint config",
6
6
  "author": "xiyaowong (https://github.com/xiyaowong)",
7
7
  "license": "MIT",
8
8
  "exports": {
9
- ".": {
10
- "import": "./dist/index.js",
11
- "require": "./dist/index.cjs"
12
- }
9
+ ".": "./dist/index.js"
13
10
  },
14
11
  "main": "dist/index.js",
12
+ "types": "./dist/index.d.ts",
15
13
  "files": [
16
14
  "dist"
17
15
  ],
@@ -20,9 +18,9 @@
20
18
  "@next/eslint-plugin-next": "^15.5.2",
21
19
  "@unocss/eslint-plugin": "^66.1.2",
22
20
  "eslint": "^9.27.0",
21
+ "eslint-plugin-better-tailwindcss": "^3.7.9",
23
22
  "eslint-plugin-react-hooks": "^5.2.0",
24
- "eslint-plugin-react-refresh": "^0.4.20",
25
- "eslint-plugin-tailwindcss": ">=3.18.0"
23
+ "eslint-plugin-react-refresh": "^0.4.20"
26
24
  },
27
25
  "dependencies": {
28
26
  "@antfu/eslint-config": "^5.2.1",
@@ -30,8 +28,8 @@
30
28
  "local-pkg": "^1.1.2"
31
29
  },
32
30
  "devDependencies": {
31
+ "@antfu/ni": "^26.0.1",
33
32
  "@types/eslint": "^9.6.1",
34
- "@types/eslint-plugin-tailwindcss": "3.17.0",
35
33
  "@types/node": "^24.3.0",
36
34
  "bumpp": "^10.2.3",
37
35
  "eslint": "^9.34.0",
@@ -44,11 +42,11 @@
44
42
  "build": "nr typegen && tsdown --clean --dts",
45
43
  "stub": "tsdown --format esm",
46
44
  "watch": "tsdown --watch",
47
- "lint": "pnpm run stub && eslint .",
48
45
  "dev": "tsdown --watch & eslint-flat-config-viewer",
49
- "lint:fix": "pnpm run stub && eslint . --fix",
46
+ "lint:fix": "eslint . --fix",
47
+ "lint": "eslint .",
50
48
  "release": "bumpp && pnpm publish",
51
- "inspect": "pnpm build && npx @eslint/config-inspector",
49
+ "inspect": "nlx @eslint/config-inspector",
52
50
  "typegen": "esno scripts/typegen.ts",
53
51
  "typecheck": "tsc --noEmit"
54
52
  }
@@ -1,25 +0,0 @@
1
- //#region rolldown:runtime
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all) __defProp(target, name, {
8
- get: all[name],
9
- enumerable: true
10
- });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
- key = keys[i];
15
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: ((k) => from[k]).bind(null, key),
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
21
- };
22
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
23
-
24
- //#endregion
25
- export { __export, __reExport };