2

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

 2 years ago
source link: https://segmentfault.com/a/1190000040597363
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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

发布于 今天 15:49

一、 配一个eslint 官网学习

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

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

  • image.png

③ 采用airbnb-base标准npx install-peerdeps --dev eslint-config-airbnb-base

  • image.png

④ 增加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'],
      },
    },
  },
};

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK