Last active
March 3, 2018 07:34
-
-
Save SherryQueen/1768c69864c7ceb8d8c964b18f0e9f68 to your computer and use it in GitHub Desktop.
eslint 规则
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| env: { | |
| node: true, | |
| commonjs: true, | |
| es6: true, | |
| mocha: true, | |
| }, | |
| extends: 'eslint:recommended', | |
| parserOptions: { | |
| sourceType: 'module', | |
| }, | |
| rules: { | |
| 'no-console': 'warn', // console 警告 | |
| 'no-var': 'error', // 禁止使用var | |
| 'no-unused-vars': 'warn', // 未使用的变量 | |
| 'no-extra-semi': 'error', // 禁止不必要的分号 | |
| 'comma-dangle': [2, 'always-multiline'], // 数组和对象键值对最后一个逗号 | |
| 'comma-spacing': [2, { before: false, after: true }], // 控制逗号前后的空格 | |
| 'computed-property-spacing': [2, 'never'], // 以方括号取对象属性时,[ 后面和 ] 前面是否需要空格, 可选参数 never, always | |
| indent: ['error', 2, { SwitchCase: 1 }], // 空格两个 | |
| 'linebreak-style': ['error', 'unix'], // 换行分割 | |
| quotes: ['error', 'single'], // 单引号 | |
| semi: ['warn', 'never'], // 无分号结尾 | |
| }, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| env: { | |
| browser: true, | |
| es6: true, | |
| }, | |
| extends: 'eslint:recommended', | |
| parserOptions: { | |
| ecmaFeatures: { | |
| experimentalObjectRestSpread: true, | |
| jsx: true, | |
| }, | |
| sourceType: 'module', | |
| }, | |
| plugins: ['react'], | |
| rules: { | |
| 'no-multi-spaces': 1, | |
| 'react/jsx-tag-spacing': 1, // 总是在自动关闭的标签前加一个空格,正常情况下也不需要换行 | |
| 'jsx-quotes': 1, | |
| 'react/jsx-closing-bracket-location': 1, // 遵循JSX语法缩进/格式 | |
| 'react/jsx-boolean-value': 1, // 如果属性值为 true, 可以直接省略 | |
| 'react/no-string-refs': 1, // 总是在Refs里使用回调函数 | |
| 'react/self-closing-comp': 1, // 对于没有子元素的标签来说总是自己关闭标签 | |
| 'react/jsx-no-bind': 1, // 当在 render() 里使用事件处理方法时,提前在构造函数里把 this 绑定上去 | |
| 'react/sort-comp': 1, // 按照具体规范的React.createClass 的生命周期函数书写代码 | |
| 'react/jsx-pascal-case': 1, // React模块名使用帕斯卡命名,实例使用骆驼式命名 | |
| 'no-console': 'warn', // console 警告 | |
| 'no-var': 'error', // 禁止使用var | |
| 'no-unused-vars': 'warn', // 未使用的变量 | |
| 'no-extra-semi': 'error', // 禁止不必要的分号 | |
| 'comma-dangle': [2, 'always-multiline'], // 数组和对象键值对最后一个逗号 | |
| 'comma-spacing': [2, { before: false, after: true }], // 控制逗号前后的空格 | |
| 'computed-property-spacing': [2, 'never'], // 以方括号取对象属性时,[ 后面和 ] 前面是否需要空格, 可选参数 never, always | |
| indent: ['error', 2, { SwitchCase: 1 }], // 空格两个 | |
| 'linebreak-style': ['error', 'unix'], // 换行分割 | |
| quotes: ['error', 'single'], // 单引号 | |
| semi: ['warn', 'never'], // 无分号结尾 | |
| }, | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment