@vue/create-eslint-config
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -99,4 +99,14 @@ #!/usr/bin/env node | ||
console.info(dim(`Detected Vue.js version: ${vueVersion}`)) | ||
} catch (e) { | ||
// FIXME: warning that this only support Vue 3 | ||
} catch {} | ||
if (!vueVersion || !/^3/.test(vueVersion)) { | ||
const { continueAnyway } = await prompt({ | ||
type: 'toggle', | ||
disabled: 'No', | ||
enabled: 'Yes', | ||
name: 'continueAnyway', | ||
message: 'Vue 3.x is required but not detected. Continue anyway?', | ||
initial: false | ||
}) | ||
if (!continueAnyway) { abort() } | ||
} | ||
@@ -107,19 +117,18 @@ | ||
// 4.2 Allow JS in Vue? Allow JSX (TSX, if answered no in 4.1) in Vue? | ||
let hasTypeScript = false | ||
let detectedTypeScript = false | ||
try { | ||
const tsVersion = requireInCwd('typescript/package.json').version | ||
console.info(dim(`Detected TypeScript version: ${tsVersion}`)) | ||
hasTypeScript = true | ||
} catch (e) { | ||
const anwsers = await prompt({ | ||
type: 'toggle', | ||
disabled: 'No', | ||
enabled: 'Yes', | ||
name: 'hasTypeScript', | ||
message: 'Does your project use TypeScript?', | ||
initial: false | ||
}) | ||
hasTypeScript = anwsers.hasTypeScript | ||
} | ||
detectedTypeScript = true | ||
} catch {} | ||
const { hasTypeScript } = await prompt({ | ||
type: 'toggle', | ||
disabled: 'No', | ||
enabled: 'Yes', | ||
name: 'hasTypeScript', | ||
message: 'Does your project use TypeScript?', | ||
initial: detectedTypeScript | ||
}) | ||
const supportedScriptLangs = {} | ||
@@ -181,2 +190,10 @@ // FIXME: Use a multi-select prompt | ||
const { needsOxlint } = await prompt({ | ||
type: 'toggle', | ||
disabled: 'No', | ||
enabled: 'Yes', | ||
name: 'needsOxlint', | ||
message: 'Would you like to supplement ESLint with Oxlint for faster linting (experimental)?' | ||
}) | ||
const { pkg: pkgToExtend, files } = createConfig({ | ||
@@ -186,8 +203,5 @@ hasTypeScript, | ||
needsPrettier, | ||
needsOxlint, | ||
}) | ||
// TODO: | ||
// Add `lint` command to package.json | ||
// Add a `format` command to package.json when prettier is used | ||
deepMerge(pkg, pkgToExtend) | ||
@@ -194,0 +208,0 @@ |
28
index.js
@@ -13,2 +13,3 @@ // @ts-check | ||
needsPrettier = false, | ||
needsOxlint = false, | ||
@@ -23,2 +24,3 @@ additionalConfigs = [], | ||
devDependencies: pickDependencies(['eslint', 'eslint-plugin-vue']), | ||
scripts: {} | ||
} | ||
@@ -56,2 +58,19 @@ | ||
if (needsOxlint) { | ||
additionalConfigs.push({ | ||
devDependencies: pickDependencies(['oxlint', 'eslint-plugin-oxlint', 'npm-run-all2']), | ||
afterVuePlugin: [ | ||
{ | ||
importer: "import oxlint from 'eslint-plugin-oxlint'", | ||
content: "oxlint.configs['flat/recommended'],", | ||
}, | ||
], | ||
}) | ||
pkg.scripts['lint:oxlint'] = 'oxlint . --fix -D correctness' | ||
pkg.scripts['lint:eslint'] = 'eslint . --fix' | ||
pkg.scripts.lint = 'run-s lint:*' | ||
} else { | ||
pkg.scripts.lint = 'eslint . --fix' | ||
} | ||
if (needsPrettier) { | ||
@@ -71,2 +90,3 @@ additionalConfigs.push({ | ||
}) | ||
pkg.scripts.format = 'prettier --write src/' | ||
} | ||
@@ -109,2 +129,6 @@ | ||
// TODO: | ||
// Add `lint` command to package.json | ||
// Add a `format` command to package.json when prettier is used | ||
return { | ||
@@ -137,4 +161,4 @@ pkg, | ||
* Recursively merge the content of the new object to the existing one | ||
* @param {Object} target the existing object | ||
* @param {Object} obj the new object | ||
* @param {object} target the existing object | ||
* @param {object} obj the new object | ||
*/ | ||
@@ -141,0 +165,0 @@ export function deepMerge(target, obj) { |
{ | ||
"name": "@vue/create-eslint-config", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Utility to setup ESLint in Vue.js projects.", | ||
@@ -37,8 +37,11 @@ "type": "module", | ||
"devDependencies": { | ||
"@eslint/js": "^9.13.0", | ||
"@types/node": "^22.7.9", | ||
"@vue/eslint-config-prettier": "^10.0.0", | ||
"@eslint/js": "^9.14.0", | ||
"@types/node": "^22.8.7", | ||
"@vue/eslint-config-prettier": "^10.1.0", | ||
"@vue/eslint-config-typescript": "^14.1.3", | ||
"eslint": "^9.13.0", | ||
"eslint-plugin-vue": "^9.29.1", | ||
"eslint": "^9.14.0", | ||
"eslint-plugin-oxlint": "^0.11.0", | ||
"eslint-plugin-vue": "^9.30.0", | ||
"npm-run-all2": "^7.0.1", | ||
"oxlint": "^0.11.0", | ||
"prettier": "^3.3.3", | ||
@@ -45,0 +48,0 @@ "typescript": "~5.6.0" |
18740
14
436
11