2021年前端知识点提炼(九月份)

一、 配一个eslint 官网学习 目前快速配一个的指令示范

【2021年前端知识点提炼(九月份)】npm install eslint -D
./node_modules/.bin/eslint --init
  • 2021年前端知识点提炼(九月份)
    文章图片
③ 采用airbnb-base标准npx install-peerdeps --dev eslint-config-airbnb-base
  • 2021年前端知识点提炼(九月份)
    文章图片
④ 增加package.json中script指令"lint": "eslint --fix --ext .js,.vue src"
⑤ 修改.eslint.js中的部分规则和airbnb-base依赖,及解决一些airbnb中不合理的报错规则如:airbnb-base报import/no-unresolved
module.exports = { env: { es2021: true, node: true, }, extends: ['eslint:recommended', 'plugin:vue/essential', 'airbnb-base'], parserOptions: { ecmaVersion: 12, sourceType: 'module', }, plugins: ['vue'], rules: { 'max-len': ['error', { code: 150 }], 'import/no-unresolved': 'off', // 取消自动解析路径,以此开启alias的别名路径设置 'arrow-parens': ['error', 'as-needed'], // 箭头函数的参数可以不使用圆括号 'comma-dangle': ['error', 'never'], // 不允许末尾逗号 'no-underscore-dangle': 'off', //允许标识符中有下划线,从而支持vue中插件的使用 'linebreak-style': 'off', // 取消换行符\n或\r\n的验证 'no-param-reassign': 'off', // 允许对函数参数进行再赋值 'consistent-return': 'off', // 关闭函数中return的检测 }, settings: { 'import/resolver': { node: { extensions: ['.js', '.jsx', '.vue'], }, }, }, };

    推荐阅读