Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ nuxt3 ] 使用 eslint #2

Open
veraaaaaLiu opened this issue Feb 22, 2024 · 0 comments
Open

[ nuxt3 ] 使用 eslint #2

veraaaaaLiu opened this issue Feb 22, 2024 · 0 comments

Comments

@veraaaaaLiu
Copy link
Owner

veraaaaaLiu commented Feb 22, 2024

網頁


Install Dependencies

npm install --save-dev eslint @nuxt/eslint-config

Configuration

Add .eslintrc.cjs to the root folder of your Nuxt app.

// .eslintrc.cjs
module.exports = {
  root: true,
  extends: ['@nuxt/eslint-config'],
}

package.json

// settings.json
"scripts": {
  ...
  "lint": "eslint .",
  "lint:fix": "eslint . --fix",
  ...
},

Install the VS Code ESLint extension.

{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit"
  }
}

遵守 airbnb 的 esLint 規範

// .eslintrc.cjs
module.exports = {
  root: true,
  env: {
    node: true,
  },
  extends: [
    '@nuxt/eslint-config',
    '@vue/airbnb',
  ],
  parserOptions: {
    parser: '@babel/eslint-parser',
  },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'vuejs-accessibility/label-has-for': 'off',
    'vuejs-accessibility/form-control-has-label': 'off',
  },
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant