@wongxy/eslint-config 0.0.27 → 1.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.cjs CHANGED
@@ -24,49 +24,75 @@ __export(src_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(src_exports);
26
26
  var import_eslint_config = require("@antfu/eslint-config");
27
- function wongxy(options, ...userConfigs) {
28
- const reactnative = options?.reactnative;
29
- const react = options?.react || reactnative;
30
- const configs = [];
31
- configs.push(
32
- {
33
- name: "wongxy:general",
34
- rules: {
35
- "no-console": "off",
36
- "no-alert": "off",
37
- "no-multiple-empty-lines": "warn",
38
- "antfu/top-level-function": "off",
39
- "antfu/if-newline": "off",
40
- "import/order": ["error", {
41
- "newlines-between": "always"
42
- }],
43
- "style/brace-style": ["error", "1tbs", { allowSingleLine: true }]
44
- }
45
- }
46
- );
47
- if (options?.vue) {
48
- configs.push({
49
- name: "wongxy:vue",
50
- files: ["**/*.vue"],
51
- rules: {
27
+ 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
+ function wongxy(options = {}, ...userConfigs) {
41
+ const finalOptions = {
42
+ ...options,
43
+ vue: options.vue ?? VuePackages.some((i) => (0, import_local_pkg.isPackageExists)(i)),
44
+ typescript: options.typescript ?? (0, import_local_pkg.isPackageExists)("typescript"),
45
+ 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")
47
+ };
48
+ finalOptions.rules = {
49
+ "no-console": "off",
50
+ "no-alert": "off",
51
+ "no-multiple-empty-lines": "warn",
52
+ "antfu/top-level-function": "off",
53
+ "antfu/if-newline": "off",
54
+ "import/order": ["error", { "newlines-between": "always" }],
55
+ "style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
56
+ ...finalOptions.rules
57
+ };
58
+ if (finalOptions.vue) {
59
+ const vue = typeof finalOptions.vue === "object" ? finalOptions.vue : {};
60
+ finalOptions.vue = {
61
+ ...vue,
62
+ overrides: {
52
63
  "vue/singleline-html-element-content-newline": "off",
53
64
  "vue/valid-template-root": "off",
54
- "vue/block-order": ["warn", {
55
- order: [["script", "template"], "style"]
56
- }],
57
- "vue/custom-event-name-casing": "off"
65
+ "vue/block-order": ["warn", { order: [["script", "template"], "style"] }],
66
+ "vue/custom-event-name-casing": "off",
67
+ ...vue.overrides
68
+ }
69
+ };
70
+ }
71
+ if (finalOptions.react) {
72
+ const react = typeof finalOptions.react === "object" ? finalOptions.react : {};
73
+ finalOptions.react = {
74
+ ...react,
75
+ overrides: {
76
+ "react/prefer-destructuring-assignment": "off",
77
+ ...react.overrides
58
78
  }
59
- });
79
+ };
60
80
  }
61
- if (reactnative) {
62
- configs.push({
63
- name: "wongxy:reactnative",
64
- rules: {
65
- "ts/no-require-imports": "off",
66
- "ts/no-use-before-define": "off"
81
+ if (finalOptions.typescript) {
82
+ const typescript = typeof finalOptions.typescript === "object" ? finalOptions.typescript : {};
83
+ finalOptions.typescript = {
84
+ ...typescript,
85
+ overrides: {
86
+ "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, fixStyle: "inline-type-imports", prefer: "type-imports" }],
87
+ ...finalOptions.reactnative ? {
88
+ "ts/no-require-imports": "off",
89
+ "ts/no-use-before-define": "off"
90
+ } : void 0,
91
+ ...typescript.overrides
67
92
  }
68
- });
93
+ };
69
94
  }
70
- return (0, import_eslint_config.antfu)({ ...options, react }, ...configs, ...userConfigs);
95
+ delete finalOptions.reactnative;
96
+ return (0, import_eslint_config.antfu)(finalOptions, ...userConfigs);
71
97
  }
72
98
  var src_default = wongxy;
package/dist/index.d.cts CHANGED
@@ -4,6 +4,6 @@ import { FlatConfigComposer } from 'eslint-flat-config-utils';
4
4
 
5
5
  declare function wongxy(options?: OptionsConfig & TypedFlatConfigItem & {
6
6
  reactnative?: boolean;
7
- }, ...userConfigs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.FlatConfig[]>[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
7
+ }, ...userConfigs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.Config[]>[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
8
8
 
9
9
  export { wongxy as default };
package/dist/index.d.ts CHANGED
@@ -4,6 +4,6 @@ import { FlatConfigComposer } from 'eslint-flat-config-utils';
4
4
 
5
5
  declare function wongxy(options?: OptionsConfig & TypedFlatConfigItem & {
6
6
  reactnative?: boolean;
7
- }, ...userConfigs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.FlatConfig[]>[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
7
+ }, ...userConfigs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any, any> | Linter.Config[]>[]): FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
8
8
 
9
9
  export { wongxy as default };
package/dist/index.js CHANGED
@@ -1,49 +1,75 @@
1
1
  // src/index.ts
2
2
  import { antfu } from "@antfu/eslint-config";
3
- function wongxy(options, ...userConfigs) {
4
- const reactnative = options?.reactnative;
5
- const react = options?.react || reactnative;
6
- const configs = [];
7
- configs.push(
8
- {
9
- name: "wongxy:general",
10
- rules: {
11
- "no-console": "off",
12
- "no-alert": "off",
13
- "no-multiple-empty-lines": "warn",
14
- "antfu/top-level-function": "off",
15
- "antfu/if-newline": "off",
16
- "import/order": ["error", {
17
- "newlines-between": "always"
18
- }],
19
- "style/brace-style": ["error", "1tbs", { allowSingleLine: true }]
20
- }
21
- }
22
- );
23
- if (options?.vue) {
24
- configs.push({
25
- name: "wongxy:vue",
26
- files: ["**/*.vue"],
27
- rules: {
3
+ 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
+ ];
16
+ function wongxy(options = {}, ...userConfigs) {
17
+ const finalOptions = {
18
+ ...options,
19
+ vue: options.vue ?? VuePackages.some((i) => isPackageExists(i)),
20
+ typescript: options.typescript ?? isPackageExists("typescript"),
21
+ react: (options.react || options.reactnative) ?? ReactPackages.some((i) => isPackageExists(i)),
22
+ reactnative: options.reactnative ?? isPackageExists("react-native")
23
+ };
24
+ finalOptions.rules = {
25
+ "no-console": "off",
26
+ "no-alert": "off",
27
+ "no-multiple-empty-lines": "warn",
28
+ "antfu/top-level-function": "off",
29
+ "antfu/if-newline": "off",
30
+ "import/order": ["error", { "newlines-between": "always" }],
31
+ "style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
32
+ ...finalOptions.rules
33
+ };
34
+ if (finalOptions.vue) {
35
+ const vue = typeof finalOptions.vue === "object" ? finalOptions.vue : {};
36
+ finalOptions.vue = {
37
+ ...vue,
38
+ overrides: {
28
39
  "vue/singleline-html-element-content-newline": "off",
29
40
  "vue/valid-template-root": "off",
30
- "vue/block-order": ["warn", {
31
- order: [["script", "template"], "style"]
32
- }],
33
- "vue/custom-event-name-casing": "off"
41
+ "vue/block-order": ["warn", { order: [["script", "template"], "style"] }],
42
+ "vue/custom-event-name-casing": "off",
43
+ ...vue.overrides
44
+ }
45
+ };
46
+ }
47
+ if (finalOptions.react) {
48
+ const react = typeof finalOptions.react === "object" ? finalOptions.react : {};
49
+ finalOptions.react = {
50
+ ...react,
51
+ overrides: {
52
+ "react/prefer-destructuring-assignment": "off",
53
+ ...react.overrides
34
54
  }
35
- });
55
+ };
36
56
  }
37
- if (reactnative) {
38
- configs.push({
39
- name: "wongxy:reactnative",
40
- rules: {
41
- "ts/no-require-imports": "off",
42
- "ts/no-use-before-define": "off"
57
+ if (finalOptions.typescript) {
58
+ const typescript = typeof finalOptions.typescript === "object" ? finalOptions.typescript : {};
59
+ finalOptions.typescript = {
60
+ ...typescript,
61
+ overrides: {
62
+ "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, fixStyle: "inline-type-imports", prefer: "type-imports" }],
63
+ ...finalOptions.reactnative ? {
64
+ "ts/no-require-imports": "off",
65
+ "ts/no-use-before-define": "off"
66
+ } : void 0,
67
+ ...typescript.overrides
43
68
  }
44
- });
69
+ };
45
70
  }
46
- return antfu({ ...options, react }, ...configs, ...userConfigs);
71
+ delete finalOptions.reactnative;
72
+ return antfu(finalOptions, ...userConfigs);
47
73
  }
48
74
  var src_default = wongxy;
49
75
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wongxy/eslint-config",
3
3
  "type": "module",
4
- "version": "0.0.27",
4
+ "version": "1.0.0",
5
5
  "description": "xiyaowong's eslint config",
6
6
  "author": "xiyaowong (https://github.com/xiyaowong)",
7
7
  "license": "MIT",
@@ -23,14 +23,15 @@
23
23
  "eslint-plugin-react-refresh": "^0.4.4"
24
24
  },
25
25
  "dependencies": {
26
- "@antfu/eslint-config": "^2.23.2"
26
+ "@antfu/eslint-config": "^2.24.1",
27
+ "local-pkg": "^0.5.0"
27
28
  },
28
29
  "devDependencies": {
29
- "@types/eslint": "^8.56.11",
30
- "bumpp": "^9.4.1",
31
- "eslint": "^9.7.0",
30
+ "@types/eslint": "^9.6.0",
31
+ "bumpp": "^9.4.2",
32
+ "eslint": "^9.8.0",
32
33
  "eslint-flat-config-viewer": "^0.1.20",
33
- "tsup": "^8.2.3",
34
+ "tsup": "^8.2.4",
34
35
  "typescript": "5.4.5"
35
36
  },
36
37
  "scripts": {