关于javascript:2021年前端知识点提炼九月份

26次阅读

共计 919 个字符,预计需要花费 3 分钟才能阅读完成。

一、配一个 eslint 官网学习

目前疾速配一个的指令示范

npm install eslint -D
./node_modules/.bin/eslint --init

③ 采纳 airbnb-base 规范 npx install-peerdeps --dev eslint-config-airbnb-base

④ 减少 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'],
      },
    },
  },
};

正文完
 0