@wongxy/eslint-config 0.0.9 → 0.0.10

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/bin/index.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ import '../dist/cli.js'
package/dist/cli.cjs ADDED
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+
26
+ // src/cli.ts
27
+ var cli_exports = {};
28
+ module.exports = __toCommonJS(cli_exports);
29
+
30
+ // src/cli/index.ts
31
+ var import_node_process2 = __toESM(require("process"), 1);
32
+ var import_picocolors3 = __toESM(require("picocolors"), 1);
33
+ var import_helpers = require("yargs/helpers");
34
+ var import_yargs = __toESM(require("yargs"), 1);
35
+
36
+ // src/cli/run.ts
37
+ var import_node_fs = __toESM(require("fs"), 1);
38
+ var import_promises = __toESM(require("fs/promises"), 1);
39
+ var import_node_path = __toESM(require("path"), 1);
40
+ var import_node_process = __toESM(require("process"), 1);
41
+ var import_prompts = __toESM(require("prompts"), 1);
42
+ var import_picocolors2 = __toESM(require("picocolors"), 1);
43
+ var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
44
+
45
+ // src/cli/constants.ts
46
+ var import_picocolors = __toESM(require("picocolors"), 1);
47
+
48
+ // package.json
49
+ var version = "0.0.10";
50
+ var devDependencies = {
51
+ "@types/eslint": "^8.44.7",
52
+ "@types/prompts": "^2.4.9",
53
+ "@types/yargs": "^17.0.32",
54
+ bumpp: "9.2.0",
55
+ eslint: "8.54.0",
56
+ tsup: "8.0.1",
57
+ typescript: "5.2.2"
58
+ };
59
+
60
+ // src/cli/constants.ts
61
+ var ARROW = import_picocolors.default.cyan("\u2192");
62
+ var CHECK = import_picocolors.default.green("\u2714");
63
+ var CROSS = import_picocolors.default.red("\u2718");
64
+ var WARN = import_picocolors.default.yellow("\u2139");
65
+ var eslintVersion = devDependencies.eslint;
66
+ var vscodeSettingsString = `
67
+ // Enable the ESlint flat config support
68
+ "eslint.experimental.useFlatConfig": true,
69
+
70
+ // Disable the default formatter, use eslint instead
71
+ "prettier.enable": false,
72
+ "editor.formatOnSave": false,
73
+
74
+ // Auto fix
75
+ "editor.codeActionsOnSave": {
76
+ "source.fixAll.eslint": "explicit",
77
+ "source.organizeImports": "never"
78
+ },
79
+
80
+ // Silent the stylistic rules in you IDE, but still auto fix them
81
+ "eslint.rules.customizations": [
82
+ { "rule": "style/*", "severity": "off" },
83
+ { "rule": "format/*", "severity": "off" },
84
+ { "rule": "*-indent", "severity": "off" },
85
+ { "rule": "*-spacing", "severity": "off" },
86
+ { "rule": "*-spaces", "severity": "off" },
87
+ { "rule": "*-order", "severity": "off" },
88
+ { "rule": "*-dangle", "severity": "off" },
89
+ { "rule": "*-newline", "severity": "off" },
90
+ { "rule": "*quotes", "severity": "off" },
91
+ { "rule": "*semi", "severity": "off" }
92
+ ],
93
+
94
+ // Enable eslint for all supported languages
95
+ "eslint.validate": [
96
+ "javascript",
97
+ "javascriptreact",
98
+ "typescript",
99
+ "typescriptreact",
100
+ "vue",
101
+ "html",
102
+ "markdown",
103
+ "json",
104
+ "jsonc",
105
+ "yaml",
106
+ "toml"
107
+ ]
108
+ `;
109
+
110
+ // src/cli/utils.ts
111
+ var import_node_child_process = require("child_process");
112
+ function isGitClean() {
113
+ try {
114
+ (0, import_node_child_process.execSync)("git diff-index --quiet HEAD --");
115
+ return true;
116
+ } catch (error) {
117
+ return false;
118
+ }
119
+ }
120
+
121
+ // src/cli/run.ts
122
+ async function run(options = {}) {
123
+ const SKIP_PROMPT = !!import_node_process.default.env.SKIP_PROMPT || options.yes;
124
+ const SKIP_GIT_CHECK = !!import_node_process.default.env.SKIP_GIT_CHECK;
125
+ const cwd = import_node_process.default.cwd();
126
+ const pathFlatConfig = import_node_path.default.join(cwd, "eslint.config.js");
127
+ const pathPackageJSON = import_node_path.default.join(cwd, "package.json");
128
+ const pathESLintIgnore = import_node_path.default.join(cwd, ".eslintignore");
129
+ if (import_node_fs.default.existsSync(pathFlatConfig)) {
130
+ console.log(import_picocolors2.default.yellow(`${WARN} eslint.config.js already exists, migration wizard exited.`));
131
+ return import_node_process.default.exit(1);
132
+ }
133
+ if (!SKIP_GIT_CHECK && !isGitClean()) {
134
+ const { confirmed } = await (0, import_prompts.default)({
135
+ initial: false,
136
+ message: "There are uncommitted changes in the current repository, are you sure to continue?",
137
+ name: "confirmed",
138
+ type: "confirm"
139
+ });
140
+ if (!confirmed)
141
+ return import_node_process.default.exit(1);
142
+ }
143
+ console.log(import_picocolors2.default.cyan(`${ARROW} bumping @wongxy/eslint-config to v${version}`));
144
+ const pkgContent = await import_promises.default.readFile(pathPackageJSON, "utf-8");
145
+ const pkg = JSON.parse(pkgContent);
146
+ pkg.devDependencies ?? (pkg.devDependencies = {});
147
+ pkg.devDependencies["@wongxy/eslint-config"] = `^${version}`;
148
+ if (!pkg.devDependencies.eslint)
149
+ pkg.devDependencies.eslint = eslintVersion;
150
+ await import_promises.default.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
151
+ console.log(import_picocolors2.default.green(`${CHECK} changes wrote to package.json`));
152
+ const eslintIgnores = [];
153
+ if (import_node_fs.default.existsSync(pathESLintIgnore)) {
154
+ console.log(import_picocolors2.default.cyan(`${ARROW} migrating existing .eslintignore`));
155
+ const content = await import_promises.default.readFile(pathESLintIgnore, "utf-8");
156
+ const parsed = (0, import_parse_gitignore.default)(content);
157
+ const globs = parsed.globs();
158
+ for (const glob of globs) {
159
+ if (glob.type === "ignore")
160
+ eslintIgnores.push(...glob.patterns);
161
+ else if (glob.type === "unignore")
162
+ eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
163
+ }
164
+ }
165
+ let eslintConfigContent = "";
166
+ const wongxyConfig = `${eslintIgnores.length ? `ignores: ${JSON.stringify(eslintIgnores)}` : ""}`;
167
+ if (pkg.type === "module") {
168
+ eslintConfigContent = `
169
+ import wongxy from '@wongxy/eslint-config'
170
+
171
+ export default wongxy({
172
+ ${wongxyConfig}
173
+ })
174
+ `.trimStart();
175
+ } else {
176
+ eslintConfigContent = `
177
+ const wongxy = require('@wongxy/eslint-config').default
178
+
179
+ module.exports = wongxy({
180
+ ${wongxyConfig}
181
+ })
182
+ `.trimStart();
183
+ }
184
+ await import_promises.default.writeFile(pathFlatConfig, eslintConfigContent);
185
+ console.log(import_picocolors2.default.green(`${CHECK} created eslint.config.js`));
186
+ const files = import_node_fs.default.readdirSync(cwd);
187
+ const legacyConfig = [];
188
+ files.forEach((file) => {
189
+ if (file.includes("eslint") || file.includes("prettier"))
190
+ legacyConfig.push(file);
191
+ });
192
+ if (legacyConfig.length) {
193
+ console.log(`${WARN} you can now remove those files manually:`);
194
+ console.log(` ${import_picocolors2.default.dim(legacyConfig.join(", "))}`);
195
+ }
196
+ let promptResult = {
197
+ updateVscodeSettings: true
198
+ };
199
+ if (!SKIP_PROMPT) {
200
+ try {
201
+ promptResult = await (0, import_prompts.default)({
202
+ initial: true,
203
+ message: "Update .vscode/settings.json for better VS Code experience?",
204
+ name: "updateVscodeSettings",
205
+ type: "confirm"
206
+ }, {
207
+ onCancel: () => {
208
+ throw new Error(`Cancelled`);
209
+ }
210
+ });
211
+ } catch (cancelled) {
212
+ console.log(cancelled.message);
213
+ return;
214
+ }
215
+ }
216
+ if (promptResult?.updateVscodeSettings ?? true) {
217
+ const dotVscodePath = import_node_path.default.join(cwd, ".vscode");
218
+ const settingsPath = import_node_path.default.join(dotVscodePath, "settings.json");
219
+ if (!import_node_fs.default.existsSync(dotVscodePath))
220
+ await import_promises.default.mkdir(dotVscodePath, { recursive: true });
221
+ if (!import_node_fs.default.existsSync(settingsPath)) {
222
+ await import_promises.default.writeFile(settingsPath, `{${vscodeSettingsString}}
223
+ `, "utf-8");
224
+ console.log(import_picocolors2.default.green(`${CHECK} created .vscode/settings.json`));
225
+ } else {
226
+ let settingsContent = await import_promises.default.readFile(settingsPath, "utf8");
227
+ settingsContent = settingsContent.trim().replace(/\s*}$/, "");
228
+ settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
229
+ settingsContent += `${vscodeSettingsString}}
230
+ `;
231
+ await import_promises.default.writeFile(settingsPath, settingsContent, "utf-8");
232
+ console.log(import_picocolors2.default.green(`${CHECK} updated .vscode/settings.json`));
233
+ }
234
+ }
235
+ console.log(import_picocolors2.default.green(`${CHECK} migration completed`));
236
+ console.log(`Now you can update the dependencies and run ${import_picocolors2.default.blue("eslint . --fix")}
237
+ `);
238
+ }
239
+
240
+ // src/cli/index.ts
241
+ function header() {
242
+ console.log(`
243
+ ${import_picocolors3.default.green(`@wongxy/eslint-config `)}${import_picocolors3.default.dim(`v${version}`)}`);
244
+ }
245
+ var instance = (0, import_yargs.default)((0, import_helpers.hideBin)(import_node_process2.default.argv)).scriptName("@wongxy/eslint-config").usage("").command(
246
+ "*",
247
+ "Run the initialization or migration",
248
+ (args) => args.option("yes", { alias: "y", description: "Skip prompts and use default values", type: "boolean" }).help(),
249
+ async (args) => {
250
+ header();
251
+ console.log();
252
+ try {
253
+ await run(args);
254
+ } catch (error) {
255
+ console.error(import_picocolors3.default.inverse(import_picocolors3.default.red(" Failed to migrate ")));
256
+ console.error(import_picocolors3.default.red(`${CROSS} ${String(error)}`));
257
+ import_node_process2.default.exit(1);
258
+ }
259
+ }
260
+ ).showHelpOnFail(false).alias("h", "help").version("version", version).alias("v", "version");
261
+ instance.help().argv;
package/dist/cli.d.cts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/cli.js ADDED
@@ -0,0 +1,232 @@
1
+ // src/cli/index.ts
2
+ import process2 from "process";
3
+ import c3 from "picocolors";
4
+ import { hideBin } from "yargs/helpers";
5
+ import yargs from "yargs";
6
+
7
+ // src/cli/run.ts
8
+ import fs from "fs";
9
+ import fsp from "fs/promises";
10
+ import path from "path";
11
+ import process from "process";
12
+ import prompts from "prompts";
13
+ import c2 from "picocolors";
14
+ import parse from "parse-gitignore";
15
+
16
+ // src/cli/constants.ts
17
+ import c from "picocolors";
18
+
19
+ // package.json
20
+ var version = "0.0.10";
21
+ var devDependencies = {
22
+ "@types/eslint": "^8.44.7",
23
+ "@types/prompts": "^2.4.9",
24
+ "@types/yargs": "^17.0.32",
25
+ bumpp: "9.2.0",
26
+ eslint: "8.54.0",
27
+ tsup: "8.0.1",
28
+ typescript: "5.2.2"
29
+ };
30
+
31
+ // src/cli/constants.ts
32
+ var ARROW = c.cyan("\u2192");
33
+ var CHECK = c.green("\u2714");
34
+ var CROSS = c.red("\u2718");
35
+ var WARN = c.yellow("\u2139");
36
+ var eslintVersion = devDependencies.eslint;
37
+ var vscodeSettingsString = `
38
+ // Enable the ESlint flat config support
39
+ "eslint.experimental.useFlatConfig": true,
40
+
41
+ // Disable the default formatter, use eslint instead
42
+ "prettier.enable": false,
43
+ "editor.formatOnSave": false,
44
+
45
+ // Auto fix
46
+ "editor.codeActionsOnSave": {
47
+ "source.fixAll.eslint": "explicit",
48
+ "source.organizeImports": "never"
49
+ },
50
+
51
+ // Silent the stylistic rules in you IDE, but still auto fix them
52
+ "eslint.rules.customizations": [
53
+ { "rule": "style/*", "severity": "off" },
54
+ { "rule": "format/*", "severity": "off" },
55
+ { "rule": "*-indent", "severity": "off" },
56
+ { "rule": "*-spacing", "severity": "off" },
57
+ { "rule": "*-spaces", "severity": "off" },
58
+ { "rule": "*-order", "severity": "off" },
59
+ { "rule": "*-dangle", "severity": "off" },
60
+ { "rule": "*-newline", "severity": "off" },
61
+ { "rule": "*quotes", "severity": "off" },
62
+ { "rule": "*semi", "severity": "off" }
63
+ ],
64
+
65
+ // Enable eslint for all supported languages
66
+ "eslint.validate": [
67
+ "javascript",
68
+ "javascriptreact",
69
+ "typescript",
70
+ "typescriptreact",
71
+ "vue",
72
+ "html",
73
+ "markdown",
74
+ "json",
75
+ "jsonc",
76
+ "yaml",
77
+ "toml"
78
+ ]
79
+ `;
80
+
81
+ // src/cli/utils.ts
82
+ import { execSync } from "child_process";
83
+ function isGitClean() {
84
+ try {
85
+ execSync("git diff-index --quiet HEAD --");
86
+ return true;
87
+ } catch (error) {
88
+ return false;
89
+ }
90
+ }
91
+
92
+ // src/cli/run.ts
93
+ async function run(options = {}) {
94
+ const SKIP_PROMPT = !!process.env.SKIP_PROMPT || options.yes;
95
+ const SKIP_GIT_CHECK = !!process.env.SKIP_GIT_CHECK;
96
+ const cwd = process.cwd();
97
+ const pathFlatConfig = path.join(cwd, "eslint.config.js");
98
+ const pathPackageJSON = path.join(cwd, "package.json");
99
+ const pathESLintIgnore = path.join(cwd, ".eslintignore");
100
+ if (fs.existsSync(pathFlatConfig)) {
101
+ console.log(c2.yellow(`${WARN} eslint.config.js already exists, migration wizard exited.`));
102
+ return process.exit(1);
103
+ }
104
+ if (!SKIP_GIT_CHECK && !isGitClean()) {
105
+ const { confirmed } = await prompts({
106
+ initial: false,
107
+ message: "There are uncommitted changes in the current repository, are you sure to continue?",
108
+ name: "confirmed",
109
+ type: "confirm"
110
+ });
111
+ if (!confirmed)
112
+ return process.exit(1);
113
+ }
114
+ console.log(c2.cyan(`${ARROW} bumping @wongxy/eslint-config to v${version}`));
115
+ const pkgContent = await fsp.readFile(pathPackageJSON, "utf-8");
116
+ const pkg = JSON.parse(pkgContent);
117
+ pkg.devDependencies ?? (pkg.devDependencies = {});
118
+ pkg.devDependencies["@wongxy/eslint-config"] = `^${version}`;
119
+ if (!pkg.devDependencies.eslint)
120
+ pkg.devDependencies.eslint = eslintVersion;
121
+ await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
122
+ console.log(c2.green(`${CHECK} changes wrote to package.json`));
123
+ const eslintIgnores = [];
124
+ if (fs.existsSync(pathESLintIgnore)) {
125
+ console.log(c2.cyan(`${ARROW} migrating existing .eslintignore`));
126
+ const content = await fsp.readFile(pathESLintIgnore, "utf-8");
127
+ const parsed = parse(content);
128
+ const globs = parsed.globs();
129
+ for (const glob of globs) {
130
+ if (glob.type === "ignore")
131
+ eslintIgnores.push(...glob.patterns);
132
+ else if (glob.type === "unignore")
133
+ eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
134
+ }
135
+ }
136
+ let eslintConfigContent = "";
137
+ const wongxyConfig = `${eslintIgnores.length ? `ignores: ${JSON.stringify(eslintIgnores)}` : ""}`;
138
+ if (pkg.type === "module") {
139
+ eslintConfigContent = `
140
+ import wongxy from '@wongxy/eslint-config'
141
+
142
+ export default wongxy({
143
+ ${wongxyConfig}
144
+ })
145
+ `.trimStart();
146
+ } else {
147
+ eslintConfigContent = `
148
+ const wongxy = require('@wongxy/eslint-config').default
149
+
150
+ module.exports = wongxy({
151
+ ${wongxyConfig}
152
+ })
153
+ `.trimStart();
154
+ }
155
+ await fsp.writeFile(pathFlatConfig, eslintConfigContent);
156
+ console.log(c2.green(`${CHECK} created eslint.config.js`));
157
+ const files = fs.readdirSync(cwd);
158
+ const legacyConfig = [];
159
+ files.forEach((file) => {
160
+ if (file.includes("eslint") || file.includes("prettier"))
161
+ legacyConfig.push(file);
162
+ });
163
+ if (legacyConfig.length) {
164
+ console.log(`${WARN} you can now remove those files manually:`);
165
+ console.log(` ${c2.dim(legacyConfig.join(", "))}`);
166
+ }
167
+ let promptResult = {
168
+ updateVscodeSettings: true
169
+ };
170
+ if (!SKIP_PROMPT) {
171
+ try {
172
+ promptResult = await prompts({
173
+ initial: true,
174
+ message: "Update .vscode/settings.json for better VS Code experience?",
175
+ name: "updateVscodeSettings",
176
+ type: "confirm"
177
+ }, {
178
+ onCancel: () => {
179
+ throw new Error(`Cancelled`);
180
+ }
181
+ });
182
+ } catch (cancelled) {
183
+ console.log(cancelled.message);
184
+ return;
185
+ }
186
+ }
187
+ if (promptResult?.updateVscodeSettings ?? true) {
188
+ const dotVscodePath = path.join(cwd, ".vscode");
189
+ const settingsPath = path.join(dotVscodePath, "settings.json");
190
+ if (!fs.existsSync(dotVscodePath))
191
+ await fsp.mkdir(dotVscodePath, { recursive: true });
192
+ if (!fs.existsSync(settingsPath)) {
193
+ await fsp.writeFile(settingsPath, `{${vscodeSettingsString}}
194
+ `, "utf-8");
195
+ console.log(c2.green(`${CHECK} created .vscode/settings.json`));
196
+ } else {
197
+ let settingsContent = await fsp.readFile(settingsPath, "utf8");
198
+ settingsContent = settingsContent.trim().replace(/\s*}$/, "");
199
+ settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
200
+ settingsContent += `${vscodeSettingsString}}
201
+ `;
202
+ await fsp.writeFile(settingsPath, settingsContent, "utf-8");
203
+ console.log(c2.green(`${CHECK} updated .vscode/settings.json`));
204
+ }
205
+ }
206
+ console.log(c2.green(`${CHECK} migration completed`));
207
+ console.log(`Now you can update the dependencies and run ${c2.blue("eslint . --fix")}
208
+ `);
209
+ }
210
+
211
+ // src/cli/index.ts
212
+ function header() {
213
+ console.log(`
214
+ ${c3.green(`@wongxy/eslint-config `)}${c3.dim(`v${version}`)}`);
215
+ }
216
+ var instance = yargs(hideBin(process2.argv)).scriptName("@wongxy/eslint-config").usage("").command(
217
+ "*",
218
+ "Run the initialization or migration",
219
+ (args) => args.option("yes", { alias: "y", description: "Skip prompts and use default values", type: "boolean" }).help(),
220
+ async (args) => {
221
+ header();
222
+ console.log();
223
+ try {
224
+ await run(args);
225
+ } catch (error) {
226
+ console.error(c3.inverse(c3.red(" Failed to migrate ")));
227
+ console.error(c3.red(`${CROSS} ${String(error)}`));
228
+ process2.exit(1);
229
+ }
230
+ }
231
+ ).showHelpOnFail(false).alias("h", "help").version("version", version).alias("v", "version");
232
+ instance.help().argv;
package/dist/index.cjs CHANGED
@@ -17,36 +17,48 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // index.ts
21
- var eslint_config_exports = {};
22
- __export(eslint_config_exports, {
23
- default: () => eslint_config_default,
24
- wongxy: () => wongxy
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ default: () => src_default
25
24
  });
26
- module.exports = __toCommonJS(eslint_config_exports);
25
+ module.exports = __toCommonJS(src_exports);
27
26
  var import_eslint_config = require("@antfu/eslint-config");
28
27
  function wongxy(options, ...userConfigs) {
29
- return (0, import_eslint_config.antfu)(options, {
30
- rules: {
31
- "no-console": "off",
32
- "no-alert": "off",
33
- "no-multiple-empty-lines": "warn",
34
- "antfu/top-level-function": "off"
28
+ const reactnative = options?.reactnative;
29
+ const react = options?.react || reactnative;
30
+ const configs = [];
31
+ configs.push(
32
+ {
33
+ rules: {
34
+ "no-console": "off",
35
+ "no-alert": "off",
36
+ "no-multiple-empty-lines": "warn",
37
+ "antfu/top-level-function": "off"
38
+ }
35
39
  }
36
- }, {
37
- files: ["**/*.vue"],
38
- rules: {
39
- "vue/singleline-html-element-content-newline": "off",
40
- "vue/valid-template-root": "off",
41
- "vue/block-order": ["warn", {
42
- order: [["script", "template"], "style"]
43
- }],
44
- "vue/custom-event-name-casing": "off"
45
- }
46
- }, ...userConfigs);
40
+ );
41
+ if (options?.vue) {
42
+ configs.push({
43
+ files: ["**/*.vue"],
44
+ rules: {
45
+ "vue/singleline-html-element-content-newline": "off",
46
+ "vue/valid-template-root": "off",
47
+ "vue/block-order": ["warn", {
48
+ order: [["script", "template"], "style"]
49
+ }],
50
+ "vue/custom-event-name-casing": "off"
51
+ }
52
+ });
53
+ }
54
+ if (reactnative) {
55
+ configs.push({
56
+ rules: {
57
+ "ts/no-require-imports": "off",
58
+ "ts/no-use-before-define": "off"
59
+ }
60
+ });
61
+ }
62
+ return (0, import_eslint_config.antfu)({ ...options, react }, ...configs, ...userConfigs);
47
63
  }
48
- var eslint_config_default = wongxy;
49
- // Annotate the CommonJS export names for ESM import in node:
50
- 0 && (module.exports = {
51
- wongxy
52
- });
64
+ var src_default = wongxy;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { OptionsConfig, FlatConfigItem, Awaitable, UserConfigItem } from '@antfu/eslint-config';
2
2
 
3
- declare function wongxy(options?: OptionsConfig & FlatConfigItem, ...userConfigs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
3
+ declare function wongxy(options?: OptionsConfig & FlatConfigItem & {
4
+ reactnative?: boolean;
5
+ }, ...userConfigs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
4
6
 
5
- export { wongxy as default, wongxy };
7
+ export { wongxy as default };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { OptionsConfig, FlatConfigItem, Awaitable, UserConfigItem } from '@antfu/eslint-config';
2
2
 
3
- declare function wongxy(options?: OptionsConfig & FlatConfigItem, ...userConfigs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
3
+ declare function wongxy(options?: OptionsConfig & FlatConfigItem & {
4
+ reactnative?: boolean;
5
+ }, ...userConfigs: Awaitable<UserConfigItem | UserConfigItem[]>[]): Promise<UserConfigItem[]>;
4
6
 
5
- export { wongxy as default, wongxy };
7
+ export { wongxy as default };
package/dist/index.js CHANGED
@@ -1,27 +1,43 @@
1
- // index.ts
1
+ // src/index.ts
2
2
  import { antfu } from "@antfu/eslint-config";
3
3
  function wongxy(options, ...userConfigs) {
4
- return antfu(options, {
5
- rules: {
6
- "no-console": "off",
7
- "no-alert": "off",
8
- "no-multiple-empty-lines": "warn",
9
- "antfu/top-level-function": "off"
4
+ const reactnative = options?.reactnative;
5
+ const react = options?.react || reactnative;
6
+ const configs = [];
7
+ configs.push(
8
+ {
9
+ rules: {
10
+ "no-console": "off",
11
+ "no-alert": "off",
12
+ "no-multiple-empty-lines": "warn",
13
+ "antfu/top-level-function": "off"
14
+ }
10
15
  }
11
- }, {
12
- files: ["**/*.vue"],
13
- rules: {
14
- "vue/singleline-html-element-content-newline": "off",
15
- "vue/valid-template-root": "off",
16
- "vue/block-order": ["warn", {
17
- order: [["script", "template"], "style"]
18
- }],
19
- "vue/custom-event-name-casing": "off"
20
- }
21
- }, ...userConfigs);
16
+ );
17
+ if (options?.vue) {
18
+ configs.push({
19
+ files: ["**/*.vue"],
20
+ rules: {
21
+ "vue/singleline-html-element-content-newline": "off",
22
+ "vue/valid-template-root": "off",
23
+ "vue/block-order": ["warn", {
24
+ order: [["script", "template"], "style"]
25
+ }],
26
+ "vue/custom-event-name-casing": "off"
27
+ }
28
+ });
29
+ }
30
+ if (reactnative) {
31
+ configs.push({
32
+ rules: {
33
+ "ts/no-require-imports": "off",
34
+ "ts/no-use-before-define": "off"
35
+ }
36
+ });
37
+ }
38
+ return antfu({ ...options, react }, ...configs, ...userConfigs);
22
39
  }
23
- var eslint_config_default = wongxy;
40
+ var src_default = wongxy;
24
41
  export {
25
- eslint_config_default as default,
26
- wongxy
42
+ src_default as default
27
43
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wongxy/eslint-config",
3
3
  "type": "module",
4
- "version": "0.0.9",
4
+ "version": "0.0.10",
5
5
  "description": "xiyaowong's eslint config",
6
6
  "author": "xiyaowong (https://github.com/xiyaowong)",
7
7
  "license": "MIT",
@@ -12,14 +12,22 @@
12
12
  }
13
13
  },
14
14
  "main": "dist/index.js",
15
+ "bin": "bin/index.js",
15
16
  "files": [
17
+ "bin",
16
18
  "dist"
17
19
  ],
18
20
  "dependencies": {
19
- "@antfu/eslint-config": "latest"
21
+ "@antfu/eslint-config": "latest",
22
+ "parse-gitignore": "^2.0.0",
23
+ "picocolors": "^1.0.0",
24
+ "prompts": "^2.4.2",
25
+ "yargs": "^17.7.2"
20
26
  },
21
27
  "devDependencies": {
22
28
  "@types/eslint": "^8.44.7",
29
+ "@types/prompts": "^2.4.9",
30
+ "@types/yargs": "^17.0.32",
23
31
  "bumpp": "9.2.0",
24
32
  "eslint": "8.54.0",
25
33
  "tsup": "8.0.1",