配置:

1,安装依赖

  1. sudo tnpm install eslint -g
  2. sudo tnpm install eslint-plugin-import -g
  3. sudo tnpm install eslint-config-airbnb -g
  4. sudo tnpm install eslint-plugin-jsx-a11y -g
  5. sudo tnpm install eslint-plugin-react -g
  6. sudo tnpm install babel-eslint -g

2,将配置的eslintrc.js 文件放在工程目录下(扫描所在目录下所有js文件),注意:修改文件名为.eslintrc.js

3,配置idea路径

规则详情参考:

  1. http://www.jianshu.com/p/1682b91756b1

eslintrc.js 文件

  1. module.exports = {
  2. "env": {
  3. "browser": true,
  4. "node": true
  5. },
  6. "globals": {
  7. "appTool": true,
  8. "require": true,
  9. "$": true,
  10. "ant": true
  11. },
  12. "extends": "eslint-config-airbnb",
  13. "parser": "babel-eslint",
  14. "rules": {
  15. "accessor-pairs": "error",
  16. "array-bracket-spacing": [
  17. "error",
  18. "never"
  19. ],
  20. "array-callback-return": "error",
  21. "arrow-body-style": ["error", "always"],
  22. "arrow-parens": "error",
  23. "arrow-spacing": "error",
  24. "block-scoped-var": "off",
  25. "block-spacing": [
  26. "error",
  27. "never"
  28. ],
  29. "brace-style": "off",
  30. "callback-return": "off",
  31. "camelcase": "off",
  32. "comma-dangle": [
  33. "error",
  34. "never"
  35. ],
  36. "comma-spacing": "off",
  37. "comma-style": [
  38. "error",
  39. "last"
  40. ],
  41. "complexity": "off",
  42. "computed-property-spacing": [
  43. "error",
  44. "never"
  45. ],
  46. "consistent-return": "off",
  47. "consistent-this": "off",
  48. "curly": "off",
  49. "default-case": "off",
  50. "dot-location": [
  51. "error",
  52. "property"
  53. ],
  54. "dot-notation": "error",
  55. "eol-last": "off",
  56. "eqeqeq": "off",
  57. "func-names": "off",
  58. "func-style": "off",
  59. "generator-star-spacing": "error",
  60. "global-require": "error",
  61. "guard-for-in": "off",
  62. "handle-callback-err": "error",
  63. "id-blacklist": "error",
  64. "id-length": "off",
  65. "id-match": "error",
  66. "indent": ["error", , {"SwitchCase": }],
  67. "init-declarations": "off",
  68. "jsx-quotes": ["error", "prefer-double"],
  69. "key-spacing": "off",
  70. "keyword-spacing": "off",
  71. "linebreak-style": [
  72. "error",
  73. "unix"
  74. ],
  75. "lines-around-comment": "off",
  76. "max-depth": "off",
  77. "max-len": "off",
  78. "max-lines": "off",
  79. "max-nested-callbacks": "error",
  80. "max-params": "off",
  81. "max-statements": "off",
  82. "max-statements-per-line": "off",
  83. "new-parens": "off",
  84. "new-cap": "off",
  85. "newline-after-var": "off",
  86. "newline-before-return": "off",
  87. "newline-per-chained-call": "off",
  88. "no-alert": "off",
  89. "no-array-constructor": "error",
  90. "no-bitwise": "off",
  91. "no-caller": "error",
  92. "no-catch-shadow": "off",
  93. "no-confusing-arrow": "error",
  94. "no-console": "off",
  95. "no-continue": "off",
  96. "no-div-regex": "error",
  97. "no-duplicate-imports": "error",
  98. "no-else-return": "off",
  99. "no-empty-function": "off",
  100. "no-eq-null": "off",
  101. "no-eval": [
  102. "error", {
  103. "allowIndirect": true
  104. }
  105. ],
  106. "no-extend-native": "error",
  107. "no-extra-bind": "error",
  108. "no-extra-label": "error",
  109. "no-extra-parens": "off",
  110. "no-floating-decimal": "off",
  111. "no-implicit-coercion": [
  112. "error", {
  113. "boolean": false,
  114. "number": false,
  115. "string": false
  116. }
  117. ],
  118. "no-implicit-globals": "off",
  119. "no-implied-eval": "error",
  120. "no-inline-comments": "off",
  121. "no-inner-declarations": [
  122. "error",
  123. "functions"
  124. ],
  125. "no-invalid-this": "off",
  126. "no-iterator": "error",
  127. "no-label-var": "error",
  128. "no-labels": "error",
  129. "no-lone-blocks": "error",
  130. "no-lonely-if": "off",
  131. "no-loop-func": "off",
  132. "no-magic-numbers": "off",
  133. "no-mixed-operators": "off",
  134. "no-mixed-requires": "error",
  135. "no-multi-spaces": "error",
  136. "no-multi-str": "off",
  137. "no-multiple-empty-lines": ["error", {"max": , "maxEOF": }],
  138. "no-native-reassign": "error",
  139. "no-negated-condition": "off",
  140. "no-nested-ternary": "off",
  141. "no-new": "error",
  142. "no-new-func": "off",
  143. "no-new-object": "error",
  144. "no-new-require": "error",
  145. "no-new-wrappers": "error",
  146. "no-octal-escape": "error",
  147. "no-param-reassign": "off",
  148. "no-path-concat": "error",
  149. "no-plusplus": "off",
  150. "no-process-env": "error",
  151. "no-process-exit": "error",
  152. "no-proto": "off",
  153. "no-prototype-builtins": "off",
  154. "no-restricted-globals": "error",
  155. "no-restricted-imports": "error",
  156. "no-restricted-modules": "error",
  157. "no-restricted-syntax": ["error", "WithStatement"],
  158. "no-return-assign": "off",
  159. "no-script-url": "off",
  160. "no-self-compare": "off",
  161. "no-sequences": "off",
  162. "no-shadow": "off",
  163. "no-shadow-restricted-names": "off",
  164. "no-spaced-func": "error",
  165. "no-sync": "off",
  166. "no-ternary": "off",
  167. "no-throw-literal": "error",
  168. "no-trailing-spaces": "off",
  169. "no-undef-init": "error",
  170. "no-undef": "off",
  171. "no-undefined": "off",
  172. "no-underscore-dangle": "off",
  173. "no-unmodified-loop-condition": "error",
  174. "no-unneeded-ternary": [
  175. "error", {
  176. "defaultAssignment": true
  177. }
  178. ],
  179. "no-unsafe-finally": "error",
  180. "no-unused-expressions": "off",
  181. "no-unused-vars": "off",
  182. "no-use-before-define": "off",
  183. "no-useless-call": "off",
  184. "no-useless-computed-key": "error",
  185. "no-useless-concat": "off",
  186. "no-useless-constructor": "error",
  187. "no-useless-escape": "off",
  188. "no-useless-rename": "error",
  189. "no-var": "off",
  190. "no-void": "off",
  191. "no-warning-comments": "off",
  192. "no-whitespace-before-property": "error",
  193. "no-with": "error",
  194. "object-curly-newline": "off",
  195. "object-curly-spacing": ["error", "always"],
  196. "object-property-newline": [
  197. "error", {
  198. "allowMultiplePropertiesPerLine": true
  199. }
  200. ],
  201. "object-shorthand": "off",
  202. "one-var": "off",
  203. "one-var-declaration-per-line": "off",
  204. "operator-assignment": "off",
  205. "operator-linebreak": [
  206. "error",
  207. "after"
  208. ],
  209. "padded-blocks": "off",
  210. "prefer-arrow-callback": "off",
  211. "prefer-const": "error",
  212. "prefer-reflect": "off",
  213. "prefer-rest-params": "off",
  214. "prefer-spread": "off",
  215. "prefer-template": "off",
  216. "quote-props": "off",
  217. "quotes": ["error", "single"],
  218. "radix": "off",
  219. "require-jsdoc": "off",
  220. "require-yield": "error",
  221. "rest-spread-spacing": "error",
  222. "semi": ["error", "always"],
  223. "semi-spacing": "off",
  224. "sort-imports": "off",
  225. "sort-vars": "off",
  226. "space-before-blocks": "off",
  227. "space-before-function-paren": ["error", {"anonymous": "always", "named": "never"}],
  228. "space-in-parens": "off",
  229. "space-infix-ops": "off",
  230. "space-unary-ops": [
  231. "error", {
  232. "nonwords": false,
  233. "words": false
  234. }
  235. ],
  236. "strict": "off",
  237. "template-curly-spacing": "error",
  238. "unicode-bom": [
  239. "error",
  240. "never"
  241. ],
  242. "valid-jsdoc": "off",
  243. "vars-on-top": "off",
  244. "wrap-iife": "off",
  245. "wrap-regex": "off",
  246. "yield-star-spacing": "error",
  247. "yoda": "off",
  248. "react/sort-comp": "off",
  249. "react/prefer-stateless-function": "off",
  250. "react/jsx-space-before-closing": ["error", "always"],
  251. "spaced-comment": ["error", "always"],
  252. "react/jsx-no-bind": "off",
  253. "no-extra-boolean-cast": "off"
  254. }
  255. };

idea中配置eslint 静态代码检查的更多相关文章

  1. PC-lint 简明教程(C/C++静态代码检查工具)

    前言 PC-lint是一款小而强大的C/C++静态代码检查工具,它可以检查未初始化变量,数组越界,空指针等编译器很难发现的潜在错误.在很多专业的软件公司如Microsoft,PC-Lint检查无错误无 ...

  2. 在Jenkins中使用sonar进行静态代码检查

    要解决的问题 jenkins自动构建完成后,希望能通过sonar静态代码检查生成一份报告,给与开发人员对当前代码的做一个质量评估和修改意见 1.安装并配置sonar服务器 懒得说,跟着官方文档走就行, ...

  3. 静态代码检查工具 cppcheck 的使用

      CppCheck是一个C/C++代码缺陷静态检查工具.不同于C/C++编译器及其它分析工具,CppCheck只检查编译器检查不出来的bug,不检查语法错误.所谓静态代码检查就是使用一个工具检查我们 ...

  4. 如何在webstrom中配置eslint和less

    webstrom 帮助文档(英文版) 1.在webstrom中使用ESLint规范代码格式: JSHint 可以帮助检测你的 JavaScript 代码中的错误和潜在的问题,而 eslint是一个 J ...

  5. 静态代码检查工具 cppcheck 的使用(可分别集成到VS和QT Creator里)

    CppCheck是一个C/C++代码缺陷静态检查工具.不同于C/C++编译器及其它分析工具,CppCheck只检查编译器检查不出来的bug,不检查语法错误.所谓静态代码检查就是使用一个工具检查我们写的 ...

  6. Webpack 2 视频教程 010 - 配置 ESLint 实现代码规范自动测试 (下)

    原文发表于我的技术博客 这是我免费发布的高质量超清「Webpack 2 视频教程」. Webpack 作为目前前端开发必备的框架,Webpack 发布了 2.0 版本,此视频就是基于 2.0 的版本讲 ...

  7. Webpack 2 视频教程 009 - 配置 ESLint 实现代码规范自动测试 (上)

    原文发表于我的技术博客 这是我免费发布的高质量超清「Webpack 2 视频教程」. Webpack 作为目前前端开发必备的框架,Webpack 发布了 2.0 版本,此视频就是基于 2.0 的版本讲 ...

  8. C#静态代码检查工具StyleCode

    C#静态代码检查工具StyleCode -- 初探 最近我们Advent Data Service (ADS) 在项目上需要按照代码规范进行代码的编写工作,以方便将来代码的阅读与维护. 但是人工检查起 ...

  9. jenkins+findbugs+checkstyle+PMD静态代码检查(二)

    可以根据自己的需求选中对应的插件进行配置(不一定非要同时配置三个插件) jenkins:持续集成的工具 fundbugs:检测代码静态错误的插件  例如:定义了没有用到的对象,string类型的比较使 ...

随机推荐

  1. Linux下的SVN服务器搭建

    鉴于在搭建时,参考网上很多资料,网上资料在有用的同时,也坑了很多人 本文的目的,也就是想让后继之人在搭建svn服务器时不再犯错,不再被网上漫天的坑爹作品所坑害,故此总结 /******开始****** ...

  2. DataGrid获取当前行某列值

    前言: 本文将给大家介绍一下, 在ASP.NET MVC环境下,如何利用Jquery MiniUI(一个专业WebUI控件库)来获取Datagrid中的值,官网没有涉及到的内容:如何获取当前行某一列的 ...

  3. heartbeat

    http://www.bubuko.com/infodetail-1174857.html http://www.cnblogs.com/zhanjindong/p/3618055.html http ...

  4. Cellebrite UFED 5.1 发布,全面支持三星 S6 S6 Edge Note5 HUAWEI series

    世界级取证公司Cellebrite 昨天发布了最新的 UFED 5.1 系统更新,4PC全面支持三星S6,S6EDGE NOTE5 以及HUAWEI,LG系列恢复,锁屏密码XX!下面是部分截图 有需要 ...

  5. 阿里yum源

    转:http://mirrors.aliyun.com/help/centos?spm=5176.bbsr150321.0.0.d6ykiD 1.备份 mv /etc/yum.repos.d/Cent ...

  6. <hr> 的18种样式

    18 Simple Styles for Horizontal Rules (hr CSS Design) Simple Styles for <hr>'s Code: <!DOCT ...

  7. Java读取文件最后两行

    File f=new File("C:\\123.txt"); BufferedReader br = new BufferedReader(new FileReader(f)); ...

  8. GreenDao关系建表

    关系 在greenDAO,实体涉及使用一对一或一对多的关系.例如,如果要模拟一个1:greenDAOñ关系,你将有一个一对一和一对多的关系.但是,请注意,一对一和一对多的关系不是相互连接,所以你必须同 ...

  9. Struts框架2ActionError类 内部资料 请勿转载 谢谢合作

    ActionError类从不独立进行错误处理,它们总是被存储在ActionErrors对象中.ActionErrors对象保存ActionError类的集合以及它们特定的属性值,我们可以使用自己定义的 ...

  10. Appium 关于如何获取 apk 包名即 appPackage 和 appActivity

    方法2: a.启动待测apk b.开启日志输出:adb logcat>D:/log.txt c.关闭日志输出:ctrl+c d.查看日志 进入通过adb 连接上设备以后,通过如下命令查看包名 C ...