feat: auto JS fallback

This commit is contained in:
Anthony Fu 2022-11-12 15:03:35 +08:00
parent f8014b745e
commit b820b0fd92
3 changed files with 20 additions and 3 deletions

View File

@ -1,3 +1,10 @@
const { isPackageExists } = require('local-pkg')
const TS = isPackageExists('typescript')
if (!TS)
console.warn('[@antfu/eslint-config] TypeScript is not installed, fallback to JS only.')
module.exports = { module.exports = {
overrides: [ overrides: [
{ {
@ -9,13 +16,17 @@ module.exports = {
rules: { rules: {
'no-unused-vars': 'off', 'no-unused-vars': 'off',
'no-undef': 'off', 'no-undef': 'off',
'@typescript-eslint/no-unused-vars': 'off', ...(TS
? { '@typescript-eslint/no-unused-vars': 'off' }
: null),
}, },
}, },
], ],
extends: [ extends: [
'plugin:vue/vue3-recommended', 'plugin:vue/vue3-recommended',
'@antfu/eslint-config-ts', TS
? '@antfu/eslint-config-ts'
: '@antfu/eslint-config-basic',
], ],
rules: { rules: {
'vue/max-attributes-per-line': 'off', 'vue/max-attributes-per-line': 'off',

View File

@ -16,9 +16,11 @@
}, },
"dependencies": { "dependencies": {
"@antfu/eslint-config-ts": "workspace:*", "@antfu/eslint-config-ts": "workspace:*",
"@antfu/eslint-config-basic": "workspace:*",
"eslint-plugin-vue": "^9.4.0" "eslint-plugin-vue": "^9.4.0"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^8.23.0" "eslint": "^8.23.0",
"local-pkg": "^0.4.2"
} }
} }

View File

@ -131,14 +131,18 @@ importers:
packages/vue: packages/vue:
specifiers: specifiers:
'@antfu/eslint-config-basic': workspace:*
'@antfu/eslint-config-ts': workspace:* '@antfu/eslint-config-ts': workspace:*
eslint: ^8.23.0 eslint: ^8.23.0
eslint-plugin-vue: ^9.4.0 eslint-plugin-vue: ^9.4.0
local-pkg: ^0.4.2
dependencies: dependencies:
'@antfu/eslint-config-basic': link:../basic
'@antfu/eslint-config-ts': link:../typescript '@antfu/eslint-config-ts': link:../typescript
eslint-plugin-vue: 9.4.0_eslint@8.23.0 eslint-plugin-vue: 9.4.0_eslint@8.23.0
devDependencies: devDependencies:
eslint: 8.23.0 eslint: 8.23.0
local-pkg: 0.4.2
packages: packages: