@wongxy/eslint-config 2.0.0 → 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,140 +1,109 @@
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
-
19
- // src/index.ts
20
- var index_exports = {};
21
- __export(index_exports, {
22
- default: () => wongxy,
23
- tailwindcss: () => tailwindcss
24
- });
25
- import { antfu } from "@antfu/eslint-config";
1
+ import { GLOB_SRC, GLOB_TS, GLOB_TSX, GLOB_VUE, antfu, getOverrides } from "@antfu/eslint-config";
26
2
  import { isPackageExists } from "local-pkg";
3
+ import pluginTailwind from "eslint-plugin-better-tailwindcss";
27
4
 
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
- ];
5
+ //#region src/tailwindcss.ts
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
+ };
16
+ return [{
17
+ name: "wongxy/tailwindcss/setup",
18
+ plugins: { tw: pluginTailwind },
19
+ languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
20
+ ...!!settings && { settings: { "better-tailwindcss": settings } }
21
+ }, {
22
+ name: "wongxy/tailwindcss/rules",
23
+ rules: {
24
+ ...rules,
25
+ ...overrides
26
+ }
27
+ }];
58
28
  }
59
29
 
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(index_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
- options = options ?? {};
71
- const finalOptions = {
72
- ...options,
73
- vue: options.vue ?? VuePackages.some((i) => isPackageExists(i)),
74
- typescript: options.typescript ?? isPackageExists("typescript"),
75
- react: (options.react || options.reactnative) ?? ReactPackages.some((i) => isPackageExists(i)),
76
- reactnative: options.reactnative ?? isPackageExists("react-native"),
77
- tailwindcss: options.tailwindcss ?? isPackageExists("tailwindcss")
78
- };
79
- const rules = {
80
- "no-console": "off",
81
- "no-alert": "off",
82
- "no-multiple-empty-lines": "warn",
83
- "antfu/top-level-function": "off",
84
- "antfu/if-newline": "off",
85
- // 'import/order': ['error', { 'newlines-between': 'always' }],
86
- "style/brace-style": ["error", "1tbs", { allowSingleLine: true }]
87
- };
88
- for (const key in finalOptions.rules)
89
- delete rules[key];
90
- userConfigs.splice(0, 0, { name: "wongxy/rules", rules });
91
- if (finalOptions.vue) {
92
- const vue = typeof finalOptions.vue === "object" ? finalOptions.vue : {};
93
- finalOptions.vue = {
94
- ...vue,
95
- overrides: {
96
- "vue/singleline-html-element-content-newline": "off",
97
- "vue/valid-template-root": "off",
98
- "vue/block-order": ["warn", { order: [["script", "template"], "style"] }],
99
- "vue/custom-event-name-casing": "off",
100
- ...vue.overrides
101
- }
102
- };
103
- }
104
- if (finalOptions.react) {
105
- const react = typeof finalOptions.react === "object" ? finalOptions.react : {};
106
- finalOptions.react = {
107
- ...react,
108
- overrides: {
109
- "react/prefer-destructuring-assignment": "off",
110
- ...react.overrides
111
- }
112
- };
113
- }
114
- if (finalOptions.typescript) {
115
- const typescript = typeof finalOptions.typescript === "object" ? finalOptions.typescript : {};
116
- finalOptions.typescript = {
117
- ...typescript,
118
- overrides: {
119
- "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, fixStyle: "inline-type-imports", prefer: "type-imports" }],
120
- ...finalOptions.reactnative ? {
121
- "ts/no-require-imports": "off",
122
- "ts/no-use-before-define": "off"
123
- } : void 0,
124
- ...typescript.overrides
125
- }
126
- };
127
- }
128
- if (finalOptions.tailwindcss) {
129
- userConfigs.splice(0, 0, tailwindcss({
130
- overrides: typeof finalOptions.tailwindcss === "object" ? finalOptions.tailwindcss.overrides : void 0
131
- }));
132
- }
133
- delete finalOptions.reactnative;
134
- delete finalOptions.tailwindcss;
135
- return antfu(finalOptions, ...userConfigs);
30
+ //#endregion
31
+ //#region src/index.ts
32
+ const VuePackages = [
33
+ "vue",
34
+ "nuxt",
35
+ "vitepress",
36
+ "@slidev/cli"
37
+ ];
38
+ const ReactPackages = [
39
+ "react",
40
+ "react-native",
41
+ "react-dom",
42
+ "next"
43
+ ];
44
+ function resolveRules(overrides, rules) {
45
+ return Object.fromEntries(Object.entries(rules).filter(([k]) => !overrides[k]));
136
46
  }
137
- export {
138
- wongxy as default,
139
- tailwindcss
140
- };
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
+ })
68
+ });
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));
104
+ }
105
+ return antfu(options, ...configs, ...userConfigs);
106
+ }
107
+
108
+ //#endregion
109
+ export { wongxy as default };
package/package.json CHANGED
@@ -1,51 +1,52 @@
1
1
  {
2
2
  "name": "@wongxy/eslint-config",
3
3
  "type": "module",
4
- "version": "2.0.0",
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
  ],
18
16
  "peerDependencies": {
19
17
  "@eslint-react/eslint-plugin": "^1.49.0",
18
+ "@next/eslint-plugin-next": "^15.5.2",
20
19
  "@unocss/eslint-plugin": "^66.1.2",
21
20
  "eslint": "^9.27.0",
21
+ "eslint-plugin-better-tailwindcss": "^3.7.9",
22
22
  "eslint-plugin-react-hooks": "^5.2.0",
23
- "eslint-plugin-react-refresh": "^0.4.20",
24
- "eslint-plugin-tailwindcss": ">=3.18.0"
23
+ "eslint-plugin-react-refresh": "^0.4.20"
25
24
  },
26
25
  "dependencies": {
27
- "@antfu/eslint-config": "^4.13.2",
28
- "local-pkg": "^1.1.1"
26
+ "@antfu/eslint-config": "^5.2.1",
27
+ "eslint-flat-config-utils": "^2.1.1",
28
+ "local-pkg": "^1.1.2"
29
29
  },
30
30
  "devDependencies": {
31
+ "@antfu/ni": "^26.0.1",
31
32
  "@types/eslint": "^9.6.1",
32
- "@types/eslint-plugin-tailwindcss": "3.17.0",
33
- "@types/node": "^22.15.21",
34
- "bumpp": "^10.1.1",
35
- "eslint": "^9.27.0",
36
- "eslint-typegen": "^2.2.0",
33
+ "@types/node": "^24.3.0",
34
+ "bumpp": "^10.2.3",
35
+ "eslint": "^9.34.0",
36
+ "eslint-typegen": "^2.3.0",
37
37
  "esno": "^4.8.0",
38
- "tsup": "^8.5.0",
39
- "typescript": "5.4.5"
38
+ "tsdown": "^0.14.2",
39
+ "typescript": "5.9.2"
40
40
  },
41
41
  "scripts": {
42
- "build": "nr typegen && tsup --format esm,cjs --clean --dts",
43
- "stub": "tsup --format esm",
44
- "dev": "tsup --format esm,cjs --watch & eslint-flat-config-viewer",
45
- "lint": "pnpm run stub && eslint .",
46
- "lint:fix": "pnpm run stub && eslint . --fix",
42
+ "build": "nr typegen && tsdown --clean --dts",
43
+ "stub": "tsdown --format esm",
44
+ "watch": "tsdown --watch",
45
+ "dev": "tsdown --watch & eslint-flat-config-viewer",
46
+ "lint:fix": "eslint . --fix",
47
+ "lint": "eslint .",
47
48
  "release": "bumpp && pnpm publish",
48
- "inspect": "pnpm build && npx @eslint/config-inspector",
49
+ "inspect": "nlx @eslint/config-inspector",
49
50
  "typegen": "esno scripts/typegen.ts",
50
51
  "typecheck": "tsc --noEmit"
51
52
  }