Skip to content

Commit

Permalink
feat: improve Nuxt3 compatibility (nuxt#236)
Browse files Browse the repository at this point in the history
close nuxt#231
close nuxt#216
  • Loading branch information
antfu authored Nov 16, 2022
1 parent 8fce580 commit 8f520af
Show file tree
Hide file tree
Showing 6 changed files with 613 additions and 260 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"test": "yarn lint && vitest run"
},
"devDependencies": {
"eslint": "^8.23.0",
"eslint": "^8.27.0",
"lerna": "^5.4.3",
"vitest": "^0.22.1"
"vitest": "^0.25.1",
"vue": "^3.2.45"
},
"packageManager": "yarn@3.2.3"
}
26 changes: 23 additions & 3 deletions packages/eslint-config-typescript/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
module.exports = {
extends: [
'@nuxtjs'
'@nuxtjs',
'plugin:@typescript-eslint/recommended'
],
plugins: [
'@typescript-eslint'
],
plugins: ['@typescript-eslint'],
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser'
Expand All @@ -14,7 +17,24 @@ module.exports = {
'no-unused-vars': 'off',

// https://github.com/typescript-eslint/typescript-eslint/blob/1cf9243/docs/getting-started/linting/FAQ.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
'no-undef': 'off'
'no-undef': 'off',

// For easier migration
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/parameter-properties': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/triple-slash-reference': 'off'
},
settings: {
'import/parsers': {
Expand Down
12 changes: 8 additions & 4 deletions packages/eslint-config-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
],
"dependencies": {
"@nuxtjs/eslint-config": "^11.0.0",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"eslint-import-resolver-typescript": "^3.5.0",
"eslint-plugin-import": "^2.26.0"
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-vue": "^9.7.0"
},
"peerDependencies": {
"eslint": "^8.23.0"
},
"devDependencies": {
"typescript": "^4.8.4"
}
}
35 changes: 31 additions & 4 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
const { getPackageInfoSync } = require('local-pkg')

const nuxt = getPackageInfoSync('nuxt')
const isNuxt2 = nuxt && nuxt.version && nuxt.version.startsWith('2.')

module.exports = {
env: {
browser: true,
node: true
node: true,
...(isNuxt2 ? {} : { es6: true })
},
extends: [
'standard',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:vue/recommended'
isNuxt2
? 'plugin:vue/recommended'
: 'plugin:vue/vue3-recommended'
],
plugins: [
'unicorn',
Expand Down Expand Up @@ -125,7 +133,10 @@ module.exports = {
// Maximum 5 attributes per line instead of one
'vue/max-attributes-per-line': ['error', {
singleline: 5
}]
}],

// v-model argument is supported in Vue3
'vue/no-v-model-argument': isNuxt2 ? 'error' : 'off'
},
overrides: [
{
Expand All @@ -136,8 +147,24 @@ module.exports = {
'**/error.{js,ts,vue}'
],
rules: {
'vue/multi-word-component-names': 'off'
'vue/multi-word-component-names': 'off',
// Pages and layouts are required to have a single root element
'vue/no-multiple-template-root': 'error'
}
}
],
reportUnusedDisableDirectives: true,
ignorePatterns: [
'*.min.*',
'*.d.ts',
'dist',
'LICENSE*',
'output',
'coverage',
'public',
'package-lock.json',
'pnpm-lock.yaml',
'yarn.lock',
'__snapshots__'
]
}
9 changes: 5 additions & 4 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
"dependencies": {
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.2.5",
"eslint-plugin-n": "^15.5.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.1",
"eslint-plugin-unicorn": "^43.0.2",
"eslint-plugin-vue": "^9.4.0"
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-unicorn": "^44.0.2",
"eslint-plugin-vue": "^9.7.0",
"local-pkg": "^0.4.2"
},
"peerDependencies": {
"eslint": "^8.23.0"
Expand Down
Loading

0 comments on commit 8f520af

Please sign in to comment.