eslint的自用配置

vscode下eslint的自用配置,保存一下
vue的配置:

{
    "workbench.editor.enablePreview": false, //打开文件不覆盖
    "search.followSymlinks": false, //关闭快速预览
    "liveServer.settings.donotShowInfoMsg": true, //关闭liveserver提示
    "files.autoSave": "off", //打开自动保存
    "editor.fontSize": 16, //设置文字大小
    "editor.lineHeight": 24, //设置文字行高
    "editor.lineNumbers": "on", //开启行数提示
    "editor.quickSuggestions": { //开启自动显示建议
        "other": true,
        "comments": true,
        "strings": true
    },
    "window.zoomLevel": 0, // 调整窗口的缩放级别
    "editor.tabSize": 2, //制表符符号eslint
    "editor.formatOnSave": true, //每次保存自动格式化
    "eslint.autoFixOnSave": true, // 每次保存的时候将代码按eslint格式进行修复
    "prettier.eslintIntegration": true, //让prettier使用eslint的代码格式进行校验
    "prettier.semi": false, //去掉代码结尾的分号
    "prettier.singleQuote": true, //使用带引号替代双引号
    "javascript.format.insertSpaceBeforeFunctionParenthesis": true, //让函数(名)和后面的括号之间加个空格
    "vetur.format.defaultFormatter.html": "js-beautify-html", //格式化.vue中html
    "vetur.format.defaultFormatter.js": "vscode-typescript", //让vue中的js按编辑器自带的ts格式进行格式化
    "vetur.format.defaultFormatterOptions": {
        "js-beautify-html": {
            "wrap_attributes": "force-aligned" //属性强制折行对齐
        }
    },
    "eslint.validate": [ //开启对.vue文件中错误的检查
        "javascript",
        "javascriptreact",
        {
            "language": "html",
            "autoFix": true
        },
        {
            "language": "vue",
            "autoFix": true
        }
    ],
    "explorer.confirmDelete": false,
    // "editor.fontFamily": "Consolas, 'Courier New', monospace,'微软雅黑'",
    "editor.fontFamily": "Verdana, 'Verdana',Verdana,'微软雅黑'",
    "workbench.iconTheme": "vscode-icons",
    "workbench.colorTheme": "Dracula",
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    },
    "eslint.codeAction.disableRuleComment": {},
    "editor.renameOnType": true
}

react开发的配置

{
  "workbench.colorTheme": "Monokai",
  "editor.fontSize": 16,
  "editor.formatOnType": true,
  "explorer.confirmDragAndDrop": false,
  "[javascript]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },
  "prettier.singleQuote": true,
  "prettier.semi": false,
  "prettier.jsxSingleQuote": true,
  "vetur.format.defaultFormatter.js": "vscode-typescript",
  "editor.formatOnSave": true,
  "emmet.includeLanguages": {
    "javascript": "javascriptreact"
  }
}

.eslintrc.js vue配置

// http://eslint.org/docs/user-guide/configuring

module.exports = {
  root: true,
  parser: 'babel-eslint',
  parserOptions: {
    sourceType: 'module'
  },
  env: {
    browser: false,
    node: true,
    es6: true
  },
  // https://github.com/standard/standard/blob/master/docs/RULES-en.md
  extends: 'standard',
  // required to lint *.vue files
  plugins: [
    'html'
  ],
  // add your custom rules here
  'rules': {
    // allow paren-less arrow functions
    'arrow-parens': 0,
    // allow async-await
    'generator-star-spacing': 0,
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
  },
  globals: {
    App: true,
    Page: true,
    wx: true,
    swan: true,
    tt: true,
    my: true,
    getApp: true,
    getPage: true,
    requirePlugin: true,
    mpvue: true,
    mpvuePlatform: true
  }
}

.eslintrc.js react配置

module.exports = {
    'parser': 'babel-eslint',
    'extends': 'airbnb',
    'plugins': [
        'react',
        'import',
    ],
    'rules': {
        'semi': [0],
        'react/prop-types': [0],
        'no-underscore-dangle': [0],
        'no-script-url': [0],
        'max-len': [2, 150],
        'comma-dangle': [2, {
            'arrays': 'always-multiline',
            'objects': 'always-multiline',
            'imports': 'always-multiline',
            'exports': 'always-multiline',
            'functions': 'ignore',
        }],
        'camelcase': [0],
        'arrow-body-style': [0],
        'indent': [2, 4, {
            'SwitchCase': 1,
        }],
        'quote-props': [2, 'consistent'],
        'no-plusplus': [2, {
            'allowForLoopAfterthoughts': true
        }],
        'no-unused-expressions': [2, {
            'allowShortCircuit': true
        }],
        'import/no-extraneous-dependencies': [0],
        'import/no-unresolved': [0],
        'import/extensions': [0],
        'import/prefer-default-export': [0],
        'react/self-closing-comp': [0],
        'react/prefer-stateless-function': [0],
        'react/jsx-filename-extension': [1, { 'extensions': ['.js', '.jsx'] }],
        'react/jsx-indent': [2, 4],
        'react/jsx-indent-props': [2, 4],
        'react/jsx-boolean-value': [2, 'always'],
        'global-require': [0],
        'jsx-a11y/href-no-hash': [0],
    },
    'globals': {
        'document': false,
        'window': false,
        'fetch': false,
        /**
         *  jest global variable
         */
        'jest': false,
        'describe': false,
        'it': false,
        'expect': false,
        'beforeEach': false,
        'afterEach': false,
    },
};

你可能感兴趣的:(js学习)