ToB企服应用市场:ToB评测及商务社交产业平台

标题: webstorm设置eslint一键格式化代码 [打印本页]

作者: 张春    时间: 2024-6-22 12:51
标题: webstorm设置eslint一键格式化代码
  1. module.exports = {
  2.   root: true,
  3.   parserOptions: {
  4.     parser: 'babel-eslint',
  5.     sourceType: 'module'
  6.   },
  7.   env: {
  8.     browser: true,
  9.     node: true,
  10.     es6: true
  11.   },
  12.   extends: ['plugin:vue/recommended', 'eslint:recommended'],
  13.   // add your custom rules here
  14.   // it is base on https://github.com/vuejs/eslint-config-vue
  15.   rules: {
  16.     'vue/attribute-hyphenation': 'off',
  17.     'vue/no-mutating-props': 'off',
  18.     'vue/require-prop-types': 'off',
  19.     'vue/html-self-closing': [
  20.       'error',
  21.       {
  22.         html: {
  23.           void: 'any',
  24.           normal: 'any',
  25.           component: 'always'
  26.         },
  27.         svg: 'always',
  28.         math: 'always'
  29.       }
  30.     ],
  31.     'vue/max-attributes-per-line': [
  32.       2,
  33.       {
  34.         singleline: 2,
  35.         multiline: {
  36.           max: 2,
  37.           allowFirstLine: false
  38.         }
  39.       }
  40.     ],
  41.     'vue/singleline-html-element-content-newline': 'off',
  42.     'vue/multiline-html-element-content-newline': 'error',
  43.     'vue/name-property-casing': ['error', 'PascalCase'],
  44.     'vue/no-v-html': 'off',
  45.     'accessor-pairs': 2,
  46.     'arrow-spacing': [
  47.       2,
  48.       {
  49.         before: true,
  50.         after: true
  51.       }
  52.     ],
  53.     'block-spacing': [2, 'always'],
  54.     'brace-style': [
  55.       2,
  56.       '1tbs',
  57.       {
  58.         allowSingleLine: true
  59.       }
  60.     ],
  61.     camelcase: [
  62.       0,
  63.       {
  64.         properties: 'always'
  65.       }
  66.     ],
  67.     'comma-dangle': [2, 'never'],
  68.     'comma-spacing': [
  69.       2,
  70.       {
  71.         before: false,
  72.         after: true
  73.       }
  74.     ],
  75.     'comma-style': [2, 'last'],
  76.     'constructor-super': 2,
  77.     curly: [2, 'multi-line'],
  78.     'dot-location': [2, 'property'],
  79.     'eol-last': 2,
  80.     eqeqeq: 'off',
  81.     'generator-star-spacing': [
  82.       2,
  83.       {
  84.         before: true,
  85.         after: true
  86.       }
  87.     ],
  88.     'handle-callback-err': [2, '^(err|error)$'],
  89.     indent: [
  90.       2,
  91.       2,
  92.       {
  93.         SwitchCase: 1
  94.       }
  95.     ],
  96.     'jsx-quotes': [2, 'prefer-single'],
  97.     'key-spacing': [
  98.       2,
  99.       {
  100.         beforeColon: false,
  101.         afterColon: true
  102.       }
  103.     ],
  104.     'keyword-spacing': [
  105.       2,
  106.       {
  107.         before: true,
  108.         after: true
  109.       }
  110.     ],
  111.     'new-cap': [
  112.       2,
  113.       {
  114.         newIsCap: true,
  115.         capIsNew: false
  116.       }
  117.     ],
  118.     'new-parens': 2,
  119.     'no-array-constructor': 2,
  120.     'no-caller': 2,
  121.     'no-case-declarations': 'off',
  122.     'no-console': 'off',
  123.     'no-class-assign': 2,
  124.     'no-cond-assign': 2,
  125.     'no-const-assign': 2,
  126.     'no-control-regex': 0,
  127.     'no-delete-var': 2,
  128.     'no-dupe-args': 2,
  129.     'no-dupe-class-members': 2,
  130.     'no-dupe-keys': 2,
  131.     'no-duplicate-case': 2,
  132.     'no-empty-character-class': 2,
  133.     'no-empty-pattern': 2,
  134.     'no-eval': 2,
  135.     'no-ex-assign': 2,
  136.     'no-extend-native': 2,
  137.     'no-extra-bind': 2,
  138.     'no-extra-boolean-cast': 2,
  139.     'no-extra-parens': [2, 'functions'],
  140.     'no-fallthrough': 2,
  141.     'no-floating-decimal': 2,
  142.     'no-func-assign': 2,
  143.     'no-implied-eval': 2,
  144.     'no-inner-declarations': [2, 'functions'],
  145.     'no-invalid-regexp': 2,
  146.     'no-irregular-whitespace': 2,
  147.     'no-iterator': 2,
  148.     'no-label-var': 2,
  149.     'no-labels': [
  150.       2,
  151.       {
  152.         allowLoop: false,
  153.         allowSwitch: false
  154.       }
  155.     ],
  156.     'no-lone-blocks': 2,
  157.     'no-mixed-spaces-and-tabs': 2,
  158.     'no-multi-spaces': 2,
  159.     'no-multi-str': 2,
  160.     'no-multiple-empty-lines': [
  161.       2,
  162.       {
  163.         max: 1
  164.       }
  165.     ],
  166.     'no-native-reassign': 2,
  167.     'no-negated-in-lhs': 2,
  168.     'no-new-object': 2,
  169.     'no-new-require': 2,
  170.     'no-new-symbol': 2,
  171.     'no-new-wrappers': 2,
  172.     'no-obj-calls': 2,
  173.     'no-octal': 2,
  174.     'no-octal-escape': 2,
  175.     'no-path-concat': 2,
  176.     'no-proto': 2,
  177.     'no-redeclare': 2,
  178.     'no-regex-spaces': 2,
  179.     'no-return-assign': [2, 'except-parens'],
  180.     'no-self-assign': 2,
  181.     'no-self-compare': 2,
  182.     'no-sequences': 2,
  183.     'no-shadow-restricted-names': 2,
  184.     'no-spaced-func': 2,
  185.     'no-sparse-arrays': 2,
  186.     'no-this-before-super': 2,
  187.     'no-throw-literal': 2,
  188.     'no-trailing-spaces': 2,
  189.     'no-undef': 2,
  190.     'no-undef-init': 2,
  191.     'no-unexpected-multiline': 2,
  192.     'no-unmodified-loop-condition': 2,
  193.     'no-unneeded-ternary': [
  194.       2,
  195.       {
  196.         defaultAssignment: false
  197.       }
  198.     ],
  199.     'no-unreachable': 2,
  200.     'no-unsafe-finally': 2,
  201.     'no-unused-vars': [
  202.       1,
  203.       {
  204.         vars: 'all',
  205.         args: 'none'
  206.       }
  207.     ],
  208.     'no-useless-call': 2,
  209.     'no-useless-computed-key': 2,
  210.     'no-useless-constructor': 2,
  211.     'no-useless-escape': 0,
  212.     'no-whitespace-before-property': 2,
  213.     'no-with': 2,
  214.     'one-var': [
  215.       2,
  216.       {
  217.         initialized: 'never'
  218.       }
  219.     ],
  220.     'operator-linebreak': [
  221.       2,
  222.       'after',
  223.       {
  224.         overrides: {
  225.           '?': 'before',
  226.           ':': 'before'
  227.         }
  228.       }
  229.     ],
  230.     'padded-blocks': [2, 'never'],
  231.     quotes: [
  232.       2,
  233.       'single',
  234.       {
  235.         avoidEscape: true,
  236.         allowTemplateLiterals: true
  237.       }
  238.     ],
  239.     semi: [2, 'never'],
  240.     'semi-spacing': [
  241.       2,
  242.       {
  243.         before: false,
  244.         after: true
  245.       }
  246.     ],
  247.     'space-before-blocks': [2, 'always'],
  248.     'space-before-function-paren': [0, 'never'],
  249.     'space-in-parens': [2, 'never'],
  250.     'space-infix-ops': 2,
  251.     'space-unary-ops': [
  252.       2,
  253.       {
  254.         words: true,
  255.         nonwords: false
  256.       }
  257.     ],
  258.     'spaced-comment': [
  259.       2,
  260.       'always',
  261.       {
  262.         markers: ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
  263.       }
  264.     ],
  265.     'template-curly-spacing': [2, 'never'],
  266.     'use-isnan': 2,
  267.     'valid-typeof': 2,
  268.     'wrap-iife': [2, 'any'],
  269.     'yield-star-spacing': [2, 'both'],
  270.     yoda: [2, 'never'],
  271.     'prefer-const': 2,
  272.     'no-debugger': 0,
  273.     'object-curly-spacing': [
  274.       2,
  275.       'always',
  276.       {
  277.         objectsInObjects: false
  278.       }
  279.     ],
  280.     'array-bracket-spacing': [2, 'never']
  281.   }
  282. }
复制代码

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4