├── .gitignore ├── rules ├── strict.js ├── node.js ├── variables.js ├── errors.js ├── es6.js ├── imports.js ├── react-a11y.js ├── best-practices.js ├── style.js └── react.js ├── .travis.yml ├── test └── test.js ├── index.js ├── README.md └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .vscode/ -------------------------------------------------------------------------------- /rules/strict.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | // babel inserts `'use strict';` for us 4 | strict: ['error', 'never'] 5 | } 6 | }; 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '7' 4 | - '6' 5 | - '5' 6 | - '4' 7 | cache: 8 | directories: 9 | - node_modules 10 | script: 11 | - yarn test 12 | after_success: 13 | - yarn semantic-release -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const eslint = require('eslint'); 3 | const conf = require('../'); 4 | 5 | // The source files to lint. 6 | const repoFiles = ['index.js', 'test/test.js']; 7 | 8 | // Use the rules defined in this repo to test against. 9 | const eslintOpts = { 10 | envs: ['node', 'es6'], 11 | useEslintrc: false, 12 | rules: conf.rules, 13 | }; 14 | 15 | // Runs the linter on the repo files and asserts no errors were found. 16 | const report = new eslint.CLIEngine(eslintOpts).executeOnFiles(repoFiles); 17 | assert.equal(report.errorCount, 0); 18 | assert.equal(report.warningCount, 0); 19 | repoFiles.forEach((file, index) => { 20 | assert(report.results[index].filePath.endsWith(file)); 21 | }); 22 | -------------------------------------------------------------------------------- /rules/node.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | node: true, 4 | browser: true 5 | }, 6 | 7 | rules: { 8 | // enforce return after a callback 9 | 'callback-return': 'off', 10 | 11 | // require all requires be top-level 12 | // http://eslint.org/docs/rules/global-require 13 | 'global-require': 0, 14 | 15 | // enforces error handling in callbacks (node environment) 16 | 'handle-callback-err': 'off', 17 | 18 | // disallow mixing regular variable and require declarations 19 | 'no-mixed-requires': ['off', false], 20 | 21 | // disallow use of new operator with the require function 22 | 'no-new-require': 'error', 23 | 24 | // disallow string concatenation with __dirname and __filename 25 | // http://eslint.org/docs/rules/no-path-concat 26 | 'no-path-concat': 'error', 27 | 28 | // disallow use of process.env 29 | 'no-process-env': 'off', 30 | 31 | // disallow process.exit() 32 | 'no-process-exit': 'off', 33 | 34 | // restrict usage of specified node modules 35 | 'no-restricted-modules': 'off', 36 | 37 | // disallow use of synchronous methods (off by default) 38 | 'no-sync': 'off', 39 | } 40 | }; 41 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 3 | './rules/best-practices', 4 | './rules/errors', 5 | './rules/es6', 6 | './rules/imports', 7 | './rules/node', 8 | './rules/react-a11y', 9 | './rules/react', 10 | './rules/strict', 11 | './rules/style', 12 | './rules/variables' 13 | ].map(require.resolve), 14 | parserOptions: { 15 | ecmaVersion: 7, 16 | sourceType: 'module' 17 | }, 18 | plugins: [ 19 | 'class-property', 20 | 'import' 21 | ], 22 | parser: 'babel-eslint', 23 | rules: { 24 | 'strict': 0, 25 | 'react/jsx-indent': 0, 26 | 'react/jsx-filename-extension': 0, 27 | 'react/prop-types': 0, 28 | 'react/no-did-mount-set-state': 0, 29 | 'react/prefer-stateless-function': 0, 30 | 'no-trailing-spaces': 0, 31 | 'import/prefer-default-export': 0, 32 | 'import/no-extraneous-dependencies': 0, 33 | 'new-cap': 0, 34 | 'func-names': 0, 35 | 'consistent-return': 0, 36 | 'no-use-before-define': 0, 37 | 'global-require': 0, 38 | 'linebreak-style': 0 39 | }, 40 | globals: { 41 | "describe": false, 42 | "it": false, 43 | "test": false, 44 | "expect": false, 45 | "beforeEach": false, 46 | "afterEach": false, 47 | "before": false 48 | } 49 | }; 50 | -------------------------------------------------------------------------------- /rules/variables.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | // enforce or disallow variable initializations at definition 4 | 'init-declarations': 'off', 5 | 6 | // disallow the catch clause parameter name being the same as a variable in the outer scope 7 | 'no-catch-shadow': 'off', 8 | 9 | // disallow deletion of variables 10 | 'no-delete-var': 'error', 11 | 12 | // disallow labels that share a name with a variable 13 | // http://eslint.org/docs/rules/no-label-var 14 | 'no-label-var': 'error', 15 | 16 | // disallow specific globals 17 | 'no-restricted-globals': 'off', 18 | 19 | // disallow declaration of variables already declared in the outer scope 20 | 'no-shadow': 'error', 21 | 22 | // disallow shadowing of names such as arguments 23 | 'no-shadow-restricted-names': 'error', 24 | 25 | // disallow use of undeclared variables unless mentioned in a /*global */ block 26 | 'no-undef': 'error', 27 | 28 | // disallow use of undefined when initializing variables 29 | 'no-undef-init': 'error', 30 | 31 | // disallow use of undefined variable 32 | // TODO: enable? 33 | 'no-undefined': 'off', 34 | 35 | // disallow declaration of variables that are not used in the code 36 | 'no-unused-vars': ['error', { 'vars': 'local', 'args': 'after-used' }], 37 | 38 | // disallow use of variables before they are defined 39 | 'no-use-before-define': 'error' 40 | } 41 | }; 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![npm](https://img.shields.io/npm/dm/localeval.svg)](https://www.npmjs.com/package/eslint-config-equimper) 2 | [![npm](https://img.shields.io/npm/dt/eslint-config-equimper.svg?style=flat-square)](https://www.npmjs.com/package/eslint-config-equimper) 3 | [![Build Status](https://travis-ci.org/EQuimper/eslint-config-equimper.svg?branch=master)](https://travis-ci.org/EQuimper/eslint-config-equimper) 4 | [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release) 5 | [![Greenkeeper badge](https://badges.greenkeeper.io/EQuimper/eslint-config-equimper.svg)](https://greenkeeper.io/) 6 | [![Dependency Status](https://dependencyci.com/github/EQuimper/eslint-config-equimper/badge)](https://dependencyci.com/github/EQuimper/eslint-config-equimper) 7 | [![code style equimper](https://img.shields.io/badge/code%20style-equimper-blue.svg?style=flat-square)](https://github.com/EQuimper/eslint-config-equimper) 8 | 9 | ## Usage 10 | 11 | 1. `npm i -D eslint-config-equimper eslint` || `yarn add -D eslint-config-equimper eslint` 12 | 13 | 2. Create .eslintrc file in the root directory 14 | 15 | 3. And paste this code 16 | 17 | ``` 18 | { 19 | "extends": "equimper" 20 | } 21 | ``` 22 | 23 | If you want to put the badge in your project. 24 | 25 | `[![code style equimper](https://img.shields.io/badge/code%20style-equimper-blue.svg?style=flat-square)](https://github.com/EQuimper/eslint-config-equimper)` 26 | [![code style equimper](https://img.shields.io/badge/code%20style-equimper-blue.svg?style=flat-square)](https://github.com/EQuimper/eslint-config-equimper) -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-config-equimper", 3 | "version": "2.2.2", 4 | "description": "Eslint config with less rule for react & react-native working with es7. Base of Airbnb", 5 | "main": "index.js", 6 | "repository": { 7 | "url": "https://github.com/EQuimper/eslint-config-equimper" 8 | }, 9 | "bugs": { 10 | "url": "https://github.com/EQuimper/eslint-config-equimper/issues" 11 | }, 12 | "scripts": { 13 | "commit": "git-cz", 14 | "test": "node test/test.js", 15 | "semantic-release": "semantic-release pre && npm publish && semantic-release post" 16 | }, 17 | "engines": { 18 | "node": ">= 0.10.0" 19 | }, 20 | "files": [ 21 | "index.js", 22 | "rules/*" 23 | ], 24 | "author": "Emanuel Quimper ", 25 | "license": "MIT", 26 | "keywords": [ 27 | "eslint", 28 | "eslint-config", 29 | "eslint-es6", 30 | "eslint-es7", 31 | "eslint-react", 32 | "eslint-airbnb", 33 | "eslint-decorator", 34 | "react-native eslint", 35 | "react eslint" 36 | ], 37 | "dependencies": { 38 | "babel-eslint": "^8.0.0", 39 | "eslint": "^4.2.0", 40 | "eslint-plugin-class-property": "^1.0.6", 41 | "eslint-plugin-import": "^2.7.0", 42 | "eslint-plugin-jsx-a11y": "^6.0.2", 43 | "eslint-plugin-react": "^7.1.0" 44 | }, 45 | "peerDependencies": { 46 | "eslint": ">=4.0.0" 47 | }, 48 | "devDependencies": { 49 | "commitizen": "^3.0.0", 50 | "cz-conventional-changelog": "^2.0.0", 51 | "semantic-release": "^15.0.0" 52 | }, 53 | "config": { 54 | "commitizen": { 55 | "path": "./node_modules/cz-conventional-changelog" 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /rules/errors.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | // require trailing commas in multiline object literals 4 | 'comma-dangle': ['error', 'always-multiline'], 5 | 6 | // disallow assignment in conditional expressions 7 | 'no-cond-assign': ['error', 'always'], 8 | 9 | // disallow use of console 10 | 'no-console': 'warn', 11 | 12 | // disallow use of constant expressions in conditions 13 | 'no-constant-condition': 'warn', 14 | 15 | // disallow control characters in regular expressions 16 | 'no-control-regex': 'error', 17 | 18 | // disallow use of debugger 19 | 'no-debugger': 'error', 20 | 21 | // disallow duplicate arguments in functions 22 | 'no-dupe-args': 'error', 23 | 24 | // disallow duplicate keys when creating object literals 25 | 'no-dupe-keys': 'error', 26 | 27 | // disallow a duplicate case label. 28 | 'no-duplicate-case': 'error', 29 | 30 | // disallow empty statements 31 | 'no-empty': 'error', 32 | 33 | // disallow the use of empty character classes in regular expressions 34 | 'no-empty-character-class': 'error', 35 | 36 | // disallow assigning to the exception in a catch block 37 | 'no-ex-assign': 'error', 38 | 39 | // disallow double-negation boolean casts in a boolean context 40 | // http://eslint.org/docs/rules/no-extra-boolean-cast 41 | 'no-extra-boolean-cast': 'error', 42 | 43 | // disallow unnecessary parentheses 44 | // http://eslint.org/docs/rules/no-extra-parens 45 | 'no-extra-parens': ['off', 'all', { 46 | conditionalAssign: true, 47 | nestedBinaryExpressions: false, 48 | returnAssign: false, 49 | }], 50 | 51 | // disallow unnecessary semicolons 52 | 'no-extra-semi': 'error', 53 | 54 | // disallow overwriting functions written as function declarations 55 | 'no-func-assign': 'error', 56 | 57 | // disallow function or variable declarations in nested blocks 58 | 'no-inner-declarations': 'error', 59 | 60 | // disallow invalid regular expression strings in the RegExp constructor 61 | 'no-invalid-regexp': 'error', 62 | 63 | // disallow irregular whitespace outside of strings and comments 64 | 'no-irregular-whitespace': 'error', 65 | 66 | // disallow negation of the left operand of an in expression 67 | // TODO: deprecated in favor of no-unsafe-negation 68 | 'no-negated-in-lhs': 'off', 69 | 70 | // disallow the use of object properties of the global object (Math and JSON) as functions 71 | 'no-obj-calls': 'error', 72 | 73 | // disallow use of Object.prototypes builtins directly 74 | // http://eslint.org/docs/rules/no-prototype-builtins 75 | 'no-prototype-builtins': 'error', 76 | 77 | // disallow multiple spaces in a regular expression literal 78 | 'no-regex-spaces': 'error', 79 | 80 | // disallow sparse arrays 81 | 'no-sparse-arrays': 'error', 82 | 83 | // Disallow template literal placeholder syntax in regular strings 84 | // http://eslint.org/docs/rules/no-template-curly-in-string 85 | // TODO: enable, semver-major 86 | 'no-template-curly-in-string': 'off', 87 | 88 | // Avoid code that looks like two expressions but is actually one 89 | // http://eslint.org/docs/rules/no-unexpected-multiline 90 | 'no-unexpected-multiline': 'error', 91 | 92 | // disallow unreachable statements after a return, throw, continue, or break statement 93 | 'no-unreachable': 'error', 94 | 95 | // disallow return/throw/break/continue inside finally blocks 96 | // http://eslint.org/docs/rules/no-unsafe-finally 97 | 'no-unsafe-finally': 'error', 98 | 99 | // disallow negating the left operand of relational operators 100 | // http://eslint.org/docs/rules/no-unsafe-negation 101 | 'no-unsafe-negation': 'error', 102 | 103 | // disallow comparisons with the value NaN 104 | 'use-isnan': 'error', 105 | 106 | // ensure JSDoc comments are valid 107 | // http://eslint.org/docs/rules/valid-jsdoc 108 | 'valid-jsdoc': 'off', 109 | 110 | // ensure that the results of typeof are compared against a valid string 111 | 'valid-typeof': 'error' 112 | } 113 | }; 114 | -------------------------------------------------------------------------------- /rules/es6.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | es6: true 4 | }, 5 | parserOptions: { 6 | ecmaVersion: 6, 7 | sourceType: 'module', 8 | }, 9 | 10 | rules: { 11 | // enforces no braces where they can be omitted 12 | // http://eslint.org/docs/rules/arrow-body-style 13 | 'arrow-body-style': ['error', 'as-needed'], 14 | 15 | // require parens in arrow function arguments 16 | 'arrow-parens': 'off', 17 | 18 | // require space before/after arrow function's arrow 19 | // http://eslint.org/docs/rules/arrow-spacing 20 | 'arrow-spacing': ['error', { before: true, after: true }], 21 | 22 | // verify super() callings in constructors 23 | 'constructor-super': 'error', 24 | 25 | // enforce the spacing around the * in generator functions 26 | // http://eslint.org/docs/rules/generator-star-spacing 27 | 'generator-star-spacing': ['error', { before: false, after: true }], 28 | 29 | // disallow modifying variables of class declarations 30 | // http://eslint.org/docs/rules/no-class-assign 31 | 'no-class-assign': 'error', 32 | 33 | // disallow arrow functions where they could be confused with comparisons 34 | // http://eslint.org/docs/rules/no-confusing-arrow 35 | 'no-confusing-arrow': ['error', { 36 | allowParens: true, 37 | }], 38 | 39 | // disallow modifying variables that are declared using const 40 | 'no-const-assign': 'error', 41 | 42 | // disallow duplicate class members 43 | // http://eslint.org/docs/rules/no-dupe-class-members 44 | 'no-dupe-class-members': 'error', 45 | 46 | // disallow importing from the same path more than once 47 | // http://eslint.org/docs/rules/no-duplicate-imports 48 | 'no-duplicate-imports': 'error', 49 | 50 | // disallow symbol constructor 51 | // http://eslint.org/docs/rules/no-new-symbol 52 | 'no-new-symbol': 'error', 53 | 54 | // disallow specific imports 55 | // http://eslint.org/docs/rules/no-restricted-imports 56 | 'no-restricted-imports': 'off', 57 | 58 | // disallow to use this/super before super() calling in constructors. 59 | // http://eslint.org/docs/rules/no-this-before-super 60 | 'no-this-before-super': 'error', 61 | 62 | // disallow useless computed property keys 63 | // http://eslint.org/docs/rules/no-useless-computed-key 64 | 'no-useless-computed-key': 'error', 65 | 66 | // disallow unnecessary constructor 67 | // http://eslint.org/docs/rules/no-useless-constructor 68 | 'no-useless-constructor': 'error', 69 | 70 | // disallow renaming import, export, and destructured assignments to the same name 71 | // http://eslint.org/docs/rules/no-useless-rename 72 | 'no-useless-rename': ['error', { 73 | ignoreDestructuring: false, 74 | ignoreImport: false, 75 | ignoreExport: false, 76 | }], 77 | 78 | // require let or const instead of var 79 | 'no-var': 'error', 80 | 81 | // require method and property shorthand syntax for object literals 82 | // http://eslint.org/docs/rules/object-shorthand 83 | 'object-shorthand': ['error', 'always', { 84 | ignoreConstructors: false, 85 | avoidQuotes: true, 86 | }], 87 | 88 | // suggest using arrow functions as callbacks 89 | 'prefer-arrow-callback': ['error', { 90 | allowNamedFunctions: false, 91 | allowUnboundThis: true, 92 | }], 93 | 94 | // suggest using of const declaration for variables that are never modified after declared 95 | 'prefer-const': ['error', { 96 | destructuring: 'any', 97 | ignoreReadBeforeAssign: true, 98 | }], 99 | 100 | // suggest using Reflect methods where applicable 101 | // http://eslint.org/docs/rules/prefer-reflect 102 | // TODO: enable 103 | 'prefer-reflect': 'off', 104 | 105 | // use rest parameters instead of arguments 106 | // http://eslint.org/docs/rules/prefer-rest-params 107 | 'prefer-rest-params': 'error', 108 | 109 | // suggest using the spread operator instead of .apply() 110 | // http://eslint.org/docs/rules/prefer-spread 111 | 'prefer-spread': 'error', 112 | 113 | // suggest using template literals instead of string concatenation 114 | // http://eslint.org/docs/rules/prefer-template 115 | 'prefer-template': 'error', 116 | 117 | // disallow generator functions that do not have yield 118 | // http://eslint.org/docs/rules/require-yield 119 | 'require-yield': 'error', 120 | 121 | // enforce spacing between object rest-spread 122 | // http://eslint.org/docs/rules/rest-spread-spacing 123 | 'rest-spread-spacing': ['error', 'never'], 124 | 125 | // import sorting 126 | // http://eslint.org/docs/rules/sort-imports 127 | 'sort-imports': ['off', { 128 | ignoreCase: false, 129 | ignoreMemberSort: false, 130 | memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], 131 | }], 132 | 133 | // enforce usage of spacing in template strings 134 | // http://eslint.org/docs/rules/template-curly-spacing 135 | 'template-curly-spacing': 'error', 136 | 137 | // enforce spacing around the * in yield* expressions 138 | // http://eslint.org/docs/rules/yield-star-spacing 139 | 'yield-star-spacing': ['error', 'after'] 140 | } 141 | }; 142 | -------------------------------------------------------------------------------- /rules/imports.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | es6: true 4 | }, 5 | parserOptions: { 6 | ecmaVersion: 6, 7 | sourceType: 'module' 8 | }, 9 | plugins: [ 10 | 'import' 11 | ], 12 | 13 | settings: { 14 | 'import/resolver': { 15 | node: { 16 | extensions: ['.js', '.json'] 17 | } 18 | }, 19 | 'import/extensions': [ 20 | '.js', 21 | '.jsx', 22 | ], 23 | 'import/core-modules': [ 24 | ], 25 | 'import/ignore': [ 26 | 'node_modules', 27 | '\\.(coffee|scss|css|less|hbs|svg|json)$', 28 | ], 29 | }, 30 | 31 | rules: { 32 | // Static analysis: 33 | 34 | // ensure imports point to files/modules that can be resolved 35 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md 36 | 'import/no-unresolved': ['error', { commonjs: true }], 37 | 38 | // ensure named imports coupled with named exports 39 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it 40 | 'import/named': 'off', 41 | 42 | // ensure default import coupled with default export 43 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it 44 | 'import/default': 'off', 45 | 46 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md 47 | 'import/namespace': 'off', 48 | 49 | // Helpful warnings: 50 | 51 | // disallow invalid exports, e.g. multiple defaults 52 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md 53 | 'import/export': 'error', 54 | 55 | // do not allow a default import name to match a named export 56 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md 57 | 'import/no-named-as-default': 'error', 58 | 59 | // warn on accessing default export property names that are also named exports 60 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md 61 | 'import/no-named-as-default-member': 'error', 62 | 63 | // disallow use of jsdoc-marked-deprecated imports 64 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md 65 | 'import/no-deprecated': 'off', 66 | 67 | // Forbid the use of extraneous packages 68 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md 69 | 'import/no-extraneous-dependencies': ['error', { 70 | devDependencies: false, 71 | optionalDependencies: false, 72 | }], 73 | 74 | // Forbid mutable exports 75 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md 76 | 'import/no-mutable-exports': 'error', 77 | 78 | // Module systems: 79 | 80 | // disallow require() 81 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md 82 | 'import/no-commonjs': 'off', 83 | 84 | // disallow AMD require/define 85 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md 86 | 'import/no-amd': 'error', 87 | 88 | // No Node.js builtin modules 89 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md 90 | // TODO: enable? 91 | 'import/no-nodejs-modules': 'off', 92 | 93 | // Style guide: 94 | 95 | // disallow non-import statements appearing before import statements 96 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md 97 | 'import/imports-first': ['error', 'absolute-first'], 98 | 99 | // disallow duplicate imports 100 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md 101 | 'import/no-duplicates': 'error', 102 | 103 | // disallow namespace imports 104 | // TODO: enable? 105 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md 106 | 'import/no-namespace': 'off', 107 | 108 | // Ensure consistent use of file extension within the import path 109 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md 110 | // TODO: enable when https://github.com/benmosher/eslint-plugin-import/issues/390 is resolved 111 | 'import/extensions': ['off', 'never'], 112 | 113 | // Enforce a convention in module import order 114 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md 115 | // TODO: enable? 116 | 'import/order': ['off', { 117 | groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], 118 | 'newlines-between': 'never', 119 | }], 120 | 121 | // Require a newline after the last import/require in a group 122 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md 123 | 'import/newline-after-import': 'error', 124 | 125 | // Require modules with a single export to use a default export 126 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md 127 | 'import/prefer-default-export': 'error', 128 | 129 | // Restrict which files can be imported in a given folder 130 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md 131 | 'import/no-restricted-paths': 'off', 132 | }, 133 | }; 134 | -------------------------------------------------------------------------------- /rules/react-a11y.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: ['jsx-a11y', 'react'], 3 | rules: { 4 | // Enforce that anchors have content 5 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md 6 | // TODO: enable, semver-major 7 | 'jsx-a11y/anchor-has-content': ['error', { components: [''] }], 8 | 9 | // Require ARIA roles to be valid and non-abstract 10 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md 11 | 'jsx-a11y/aria-role': ['error', { ignoreNonDom: false }], 12 | 13 | // Enforce all aria-* props are valid. 14 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md 15 | 'jsx-a11y/aria-props': 'error', 16 | 17 | // Enforce ARIA state and property values are valid. 18 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md 19 | 'jsx-a11y/aria-proptypes': 'error', 20 | 21 | // Enforce that elements that do not support ARIA roles, states, and 22 | // properties do not have those attributes. 23 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md 24 | 'jsx-a11y/aria-unsupported-elements': 'error', 25 | 26 | // Require to have a non-empty `alt` prop, or role="presentation" 27 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md 28 | // 'jsx-a11y/alt-text': ['error', { 29 | // elements: ['img', 'object', 'area', 'input[type="image"]'], 30 | // img: [], 31 | // object: [], 32 | // area: [], 33 | // 'input[type="image"]': [], 34 | // }], 35 | 36 | // Prevent img alt text from containing redundant words like "image", "picture", or "photo" 37 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md 38 | 'jsx-a11y/img-redundant-alt': 'error', 39 | 40 | // require that JSX labels use "htmlFor" 41 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md 42 | 'jsx-a11y/label-has-for': ['error', { components: ['label'] }], 43 | 44 | // require that mouseover/out come with focus/blur, for keyboard-only users 45 | // TODO: evaluate 46 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md 47 | 'jsx-a11y/mouse-events-have-key-events': 'off', 48 | 49 | // Prevent use of `accessKey` 50 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md 51 | 'jsx-a11y/no-access-key': 'error', 52 | 53 | // require onBlur instead of onChange 54 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md 55 | 'jsx-a11y/no-onchange': 'off', 56 | 57 | // Enforce that elements with onClick handlers must be focusable. 58 | // TODO: evaluate 59 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/onclick-has-focus.md 60 | 'jsx-a11y/onclick-has-focus': 0, 61 | 62 | // Enforce that DOM elements without semantic behavior not have interaction handlers 63 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md 64 | 'jsx-a11y/no-static-element-interactions': [ 65 | 'error', 66 | { 67 | handlers: [ 68 | 'onClick', 69 | 'onMouseDown', 70 | 'onMouseUp', 71 | 'onKeyPress', 72 | 'onKeyDown', 73 | 'onKeyUp', 74 | ], 75 | }, 76 | ], 77 | 78 | // A non-interactive element does not support event handlers (mouse and key handlers) 79 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-interactions.md 80 | // 'jsx-a11y/no-noninteractive-element-interactions': ['error', { 81 | // handlers: [ 82 | // 'onClick', 83 | // 'onMouseDown', 84 | // 'onMouseUp', 85 | // 'onKeyPress', 86 | // 'onKeyDown', 87 | // 'onKeyUp', 88 | // ] 89 | // }], 90 | 91 | // ensure HTML elements do not specify redundant ARIA roles 92 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md 93 | 'jsx-a11y/no-redundant-roles': 'error', 94 | 95 | // Enforce that elements with ARIA roles must have all required attributes 96 | // for that role. 97 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md 98 | 'jsx-a11y/role-has-required-aria-props': 'error', 99 | 100 | // Enforce that elements with explicit or implicit roles defined contain 101 | // only aria-* properties supported by that role. 102 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md 103 | 'jsx-a11y/role-supports-aria-props': 'error', 104 | 105 | // Enforce tabIndex value is not greater than zero. 106 | // TODO: evaluate 107 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md 108 | 'jsx-a11y/tabindex-no-positive': 0, 109 | 110 | // ensure tags have content and are not aria-hidden 111 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md 112 | 'jsx-a11y/heading-has-content': 'error', 113 | 114 | // require HTML elements to have a "lang" prop 115 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md 116 | 'jsx-a11y/html-has-lang': 'error', 117 | 118 | // require HTML element's lang prop to be valid 119 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md 120 | 'jsx-a11y/lang': 'error', 121 | 122 | // prevent marquee elements 123 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-marquee.md 124 | // 'jsx-a11y/no-marquee': 2, 125 | 126 | // only allow to have the "scope" attr 127 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md 128 | 'jsx-a11y/scope': 'error', 129 | }, 130 | }; 131 | -------------------------------------------------------------------------------- /rules/best-practices.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | // enforces getter/setter pairs in objects 4 | 'accessor-pairs': 'off', 5 | 6 | // enforces return statements in callbacks of array's methods 7 | // http://eslint.org/docs/rules/array-callback-return 8 | 'array-callback-return': 'error', 9 | 10 | // treat var statements as if they were block scoped 11 | 'block-scoped-var': 'error', 12 | 13 | // specify the maximum cyclomatic complexity allowed in a program 14 | complexity: ['off', 11], 15 | 16 | // require return statements to either always or never specify values 17 | // http://eslint.org/docs/rules/consistent-return 18 | 'consistent-return': 'error', 19 | 20 | // specify curly brace conventions for all control statements 21 | curly: ['error', 'multi-line'], 22 | 23 | // require default case in switch statements 24 | 'default-case': ['error', { commentPattern: '^no default$' }], 25 | 26 | // encourages use of dot notation whenever possible 27 | 'dot-notation': ['error', { allowKeywords: true }], 28 | 29 | // enforces consistent newlines before or after dots 30 | // http://eslint.org/docs/rules/dot-location 31 | 'dot-location': ['error', 'property'], 32 | 33 | // require the use of === and !== 34 | // http://eslint.org/docs/rules/eqeqeq 35 | eqeqeq: ['error', 'allow-null'], 36 | 37 | // make sure for-in loops have an if statement 38 | 'guard-for-in': 'error', 39 | 40 | // disallow the use of alert, confirm, and prompt 41 | 'no-alert': 'warn', 42 | 43 | // disallow use of arguments.caller or arguments.callee 44 | 'no-caller': 'error', 45 | 46 | // disallow lexical declarations in case/default clauses 47 | // http://eslint.org/docs/rules/no-case-declarations.html 48 | 'no-case-declarations': 'error', 49 | 50 | // disallow division operators explicitly at beginning of regular expression 51 | // http://eslint.org/docs/rules/no-div-regex 52 | 'no-div-regex': 'off', 53 | 54 | // disallow else after a return in an if 55 | 'no-else-return': 'error', 56 | 57 | // disallow empty functions, except for standalone funcs/arrows 58 | // http://eslint.org/docs/rules/no-empty-function 59 | 'no-empty-function': ['error', { 60 | allow: [ 61 | 'arrowFunctions', 62 | 'functions', 63 | 'methods', 64 | ] 65 | }], 66 | 67 | // disallow empty destructuring patterns 68 | // http://eslint.org/docs/rules/no-empty-pattern 69 | 'no-empty-pattern': 'error', 70 | 71 | // disallow comparisons to null without a type-checking operator 72 | 'no-eq-null': 'off', 73 | 74 | // disallow use of eval() 75 | 'no-eval': 'error', 76 | 77 | // disallow adding to native types 78 | 'no-extend-native': 'error', 79 | 80 | // disallow unnecessary function binding 81 | 'no-extra-bind': 'error', 82 | 83 | // disallow Unnecessary Labels 84 | // http://eslint.org/docs/rules/no-extra-label 85 | 'no-extra-label': 'error', 86 | 87 | // disallow fallthrough of case statements 88 | 'no-fallthrough': 'error', 89 | 90 | // disallow the use of leading or trailing decimal points in numeric literals 91 | 'no-floating-decimal': 'error', 92 | 93 | // disallow reassignments of native objects or read-only globals 94 | // http://eslint.org/docs/rules/no-global-assign 95 | 'no-global-assign': ['error', { exceptions: [] }], 96 | 97 | // disallow implicit type conversions 98 | // http://eslint.org/docs/rules/no-implicit-coercion 99 | 'no-implicit-coercion': ['off', { 100 | boolean: false, 101 | number: true, 102 | string: true, 103 | allow: [], 104 | }], 105 | 106 | // disallow var and named functions in global scope 107 | // http://eslint.org/docs/rules/no-implicit-globals 108 | 'no-implicit-globals': 'off', 109 | 110 | // disallow use of eval()-like methods 111 | 'no-implied-eval': 'error', 112 | 113 | // disallow this keywords outside of classes or class-like objects 114 | 'no-invalid-this': 'off', 115 | 116 | // disallow usage of __iterator__ property 117 | 'no-iterator': 'error', 118 | 119 | // disallow use of labels for anything other then loops and switches 120 | 'no-labels': ['error', { allowLoop: false, allowSwitch: false }], 121 | 122 | // disallow unnecessary nested blocks 123 | 'no-lone-blocks': 'error', 124 | 125 | // disallow creation of functions within loops 126 | 'no-loop-func': 'error', 127 | 128 | // disallow magic numbers 129 | // http://eslint.org/docs/rules/no-magic-numbers 130 | 'no-magic-numbers': ['off', { 131 | ignore: [], 132 | ignoreArrayIndexes: true, 133 | enforceConst: true, 134 | detectObjects: false, 135 | }], 136 | 137 | // disallow use of multiple spaces 138 | 'no-multi-spaces': 'error', 139 | 140 | // disallow use of multiline strings 141 | 'no-multi-str': 'error', 142 | 143 | // disallow reassignments of native objects 144 | // TODO: deprecated in favor of no-global-assign 145 | 'no-native-reassign': 'off', 146 | 147 | // disallow use of new operator when not part of the assignment or comparison 148 | 'no-new': 'error', 149 | 150 | // disallow use of new operator for Function object 151 | 'no-new-func': 'error', 152 | 153 | // disallows creating new instances of String, Number, and Boolean 154 | 'no-new-wrappers': 'error', 155 | 156 | // disallow use of (old style) octal literals 157 | 'no-octal': 'error', 158 | 159 | // disallow use of octal escape sequences in string literals, such as 160 | // var foo = 'Copyright \251'; 161 | 'no-octal-escape': 'error', 162 | 163 | // disallow reassignment of function parameters 164 | // disallow parameter object manipulation 165 | // rule: http://eslint.org/docs/rules/no-param-reassign.html 166 | 'no-param-reassign': ['error', { props: true }], 167 | 168 | // disallow usage of __proto__ property 169 | 'no-proto': 'error', 170 | 171 | // disallow declaring the same variable more then once 172 | 'no-redeclare': 'error', 173 | 174 | // disallow use of assignment in return statement 175 | 'no-return-assign': 'error', 176 | 177 | // disallow use of `javascript:` urls. 178 | 'no-script-url': 'error', 179 | 180 | // disallow self assignment 181 | // http://eslint.org/docs/rules/no-self-assign 182 | 'no-self-assign': 'error', 183 | 184 | // disallow comparisons where both sides are exactly the same 185 | 'no-self-compare': 'error', 186 | 187 | // disallow use of comma operator 188 | 'no-sequences': 'error', 189 | 190 | // restrict what can be thrown as an exception 191 | 'no-throw-literal': 'error', 192 | 193 | // disallow unmodified conditions of loops 194 | // http://eslint.org/docs/rules/no-unmodified-loop-condition 195 | 'no-unmodified-loop-condition': 'off', 196 | 197 | // disallow usage of expressions in statement position 198 | 'no-unused-expressions': ['error', { 199 | allowShortCircuit: false, 200 | allowTernary: false, 201 | }], 202 | 203 | // disallow unused labels 204 | // http://eslint.org/docs/rules/no-unused-labels 205 | 'no-unused-labels': 'error', 206 | 207 | // disallow unnecessary .call() and .apply() 208 | 'no-useless-call': 'off', 209 | 210 | // disallow useless string concatenation 211 | // http://eslint.org/docs/rules/no-useless-concat 212 | 'no-useless-concat': 'error', 213 | 214 | // disallow unnecessary string escaping 215 | // http://eslint.org/docs/rules/no-useless-escape 216 | 'no-useless-escape': 'error', 217 | 218 | // disallow use of void operator 219 | // http://eslint.org/docs/rules/no-void 220 | 'no-void': 'error', 221 | 222 | // disallow usage of configurable warning terms in comments: e.g. todo 223 | 'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }], 224 | 225 | // disallow use of the with statement 226 | 'no-with': 'error', 227 | 228 | // require use of the second argument for parseInt() 229 | radix: 'error', 230 | 231 | // requires to declare all vars on top of their containing scope 232 | 'vars-on-top': 'error', 233 | 234 | // require immediate function invocation to be wrapped in parentheses 235 | // http://eslint.org/docs/rules/wrap-iife.html 236 | 'wrap-iife': ['error', 'outside'], 237 | 238 | // require or disallow Yoda conditions 239 | yoda: 'error' 240 | } 241 | }; 242 | -------------------------------------------------------------------------------- /rules/style.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | // enforce spacing inside array brackets 4 | 'array-bracket-spacing': ['error', 'never'], 5 | 6 | // enforce spacing inside single-line blocks 7 | // http://eslint.org/docs/rules/block-spacing 8 | 'block-spacing': ['error', 'always'], 9 | 10 | // enforce one true brace style 11 | 'brace-style': ['error', '1tbs', { allowSingleLine: true }], 12 | 13 | // require camel case names 14 | camelcase: ['error', { properties: 'never' }], 15 | 16 | // enforce spacing before and after comma 17 | 'comma-spacing': ['error', { before: false, after: true }], 18 | 19 | // enforce one true comma style 20 | 'comma-style': ['error', 'last'], 21 | 22 | // disallow padding inside computed properties 23 | 'computed-property-spacing': ['error', 'never'], 24 | 25 | // enforces consistent naming when capturing the current execution context 26 | 'consistent-this': 'off', 27 | 28 | // enforce newline at the end of file, with no multiple empty lines 29 | 'eol-last': 'error', 30 | 31 | // enforce spacing between functions and their invocations 32 | // http://eslint.org/docs/rules/func-call-spacing 33 | // TODO: enable, semver-minor 34 | 'func-call-spacing': ['off', 'never'], 35 | 36 | // require function expressions to have a name 37 | 'func-names': 'warn', 38 | 39 | // enforces use of function declarations or expressions 40 | 'func-style': 'off', 41 | 42 | // Blacklist certain identifiers to prevent them being used 43 | // http://eslint.org/docs/rules/id-blacklist 44 | 'id-blacklist': 'off', 45 | 46 | // this option enforces minimum and maximum identifier lengths 47 | // (variable names, property names etc.) 48 | 'id-length': 'off', 49 | 50 | // require identifiers to match the provided regular expression 51 | 'id-match': 'off', 52 | 53 | // this option sets a specific tab width for your code 54 | // http://eslint.org/docs/rules/indent 55 | indent: ['error', 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }], 56 | 57 | // specify whether double or single quotes should be used in JSX attributes 58 | // http://eslint.org/docs/rules/jsx-quotes 59 | 'jsx-quotes': ['off', 'prefer-double'], 60 | 61 | // enforces spacing between keys and values in object literal properties 62 | 'key-spacing': ['error', { beforeColon: false, afterColon: true }], 63 | 64 | // require a space before & after certain keywords 65 | 'keyword-spacing': ['error', { 66 | before: true, 67 | after: true, 68 | overrides: { 69 | return: { after: true }, 70 | throw: { after: true }, 71 | case: { after: true } 72 | } 73 | }], 74 | 75 | // disallow mixed 'LF' and 'CRLF' as linebreaks 76 | // http://eslint.org/docs/rules/linebreak-style 77 | 'linebreak-style': ['error', 'unix'], 78 | 79 | // enforces empty lines around comments 80 | 'lines-around-comment': 'off', 81 | 82 | // specify the maximum depth that blocks can be nested 83 | 'max-depth': ['off', 4], 84 | 85 | // specify the maximum length of a line in your program 86 | // http://eslint.org/docs/rules/max-len 87 | 'max-len': ['error', 150, 2, { 88 | ignoreUrls: true, 89 | ignoreComments: false 90 | }], 91 | 92 | // specify the max number of lines in a file 93 | // http://eslint.org/docs/rules/max-lines 94 | 'max-lines': ['off', { 95 | max: 300, 96 | skipBlankLines: true, 97 | skipComments: true 98 | }], 99 | 100 | // specify the maximum depth callbacks can be nested 101 | 'max-nested-callbacks': 'off', 102 | 103 | // limits the number of parameters that can be used in the function declaration. 104 | 'max-params': ['off', 3], 105 | 106 | // specify the maximum number of statement allowed in a function 107 | 'max-statements': ['off', 10], 108 | 109 | // restrict the number of statements per line 110 | // http://eslint.org/docs/rules/max-statements-per-line 111 | 'max-statements-per-line': ['off', { max: 1 }], 112 | 113 | // require multiline ternary 114 | // http://eslint.org/docs/rules/multiline-ternary 115 | 'multiline-ternary': 'off', 116 | 117 | // require a capital letter for constructors 118 | 'new-cap': ['error', { newIsCap: true }], 119 | 120 | // disallow the omission of parentheses when invoking a constructor with no arguments 121 | // http://eslint.org/docs/rules/new-parens 122 | 'new-parens': 'error', 123 | 124 | // allow/disallow an empty newline after var statement 125 | 'newline-after-var': 'off', 126 | 127 | // http://eslint.org/docs/rules/newline-before-return 128 | 'newline-before-return': 'off', 129 | 130 | // enforces new line after each method call in the chain to make it 131 | // more readable and easy to maintain 132 | // http://eslint.org/docs/rules/newline-per-chained-call 133 | 'newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }], 134 | 135 | // disallow use of the Array constructor 136 | 'no-array-constructor': 'error', 137 | 138 | // disallow use of bitwise operators 139 | // http://eslint.org/docs/rules/no-bitwise 140 | // TODO: enable 141 | 'no-bitwise': 'off', 142 | 143 | // disallow use of the continue statement 144 | // http://eslint.org/docs/rules/no-continue 145 | 'no-continue': 'error', 146 | 147 | // disallow comments inline after code 148 | 'no-inline-comments': 'off', 149 | 150 | // disallow if as the only statement in an else block 151 | // http://eslint.org/docs/rules/no-lonely-if 152 | 'no-lonely-if': 'error', 153 | 154 | // disallow un-paren'd mixes of different operators 155 | // http://eslint.org/docs/rules/no-mixed-operators 156 | 'no-mixed-operators': ['error', { 157 | groups: [ 158 | ['+', '-', '*', '/', '%', '**'], 159 | ['&', '|', '^', '~', '<<', '>>', '>>>'], 160 | ['==', '!=', '===', '!==', '>', '>=', '<', '<='], 161 | ['&&', '||'], 162 | ['in', 'instanceof'] 163 | ], 164 | allowSamePrecedence: false 165 | }], 166 | 167 | // disallow mixed spaces and tabs for indentation 168 | 'no-mixed-spaces-and-tabs': 'error', 169 | 170 | // disallow multiple empty lines and only one newline at the end 171 | // http://eslint.org/docs/rules/no-multiple-empty-lines 172 | 'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 1 }], 173 | 174 | // disallow negated conditions 175 | // http://eslint.org/docs/rules/no-negated-condition 176 | 'no-negated-condition': 'off', 177 | 178 | // disallow nested ternary expressions 179 | 'no-nested-ternary': 'error', 180 | 181 | // disallow use of the Object constructor 182 | 'no-new-object': 'error', 183 | 184 | // disallow use of unary operators, ++ and -- 185 | 'no-plusplus': 'off', 186 | 187 | // disallow certain syntax forms 188 | // http://eslint.org/docs/rules/no-restricted-syntax 189 | 'no-restricted-syntax': [ 190 | 'error', 191 | 'DebuggerStatement', 192 | 'ForInStatement', 193 | 'LabeledStatement', 194 | 'WithStatement', 195 | ], 196 | 197 | // disallow space between function identifier and application 198 | 'no-spaced-func': 'error', 199 | 200 | // disallow tab characters entirely 201 | // TODO: enable 202 | 'no-tabs': 'off', 203 | 204 | // disallow the use of ternary operators 205 | 'no-ternary': 'off', 206 | 207 | // disallow trailing whitespace at the end of lines 208 | 'no-trailing-spaces': 'error', 209 | 210 | // disallow dangling underscores in identifiers 211 | 'no-underscore-dangle': 0, 212 | 213 | // disallow the use of Boolean literals in conditional expressions 214 | // also, prefer `a || b` over `a ? a : b` 215 | // http://eslint.org/docs/rules/no-unneeded-ternary 216 | 'no-unneeded-ternary': ['error', { defaultAssignment: false }], 217 | 218 | // disallow whitespace before properties 219 | // http://eslint.org/docs/rules/no-whitespace-before-property 220 | 'no-whitespace-before-property': 'error', 221 | 222 | // require padding inside curly braces 223 | 'object-curly-spacing': ['error', 'always'], 224 | 225 | // enforce line breaks between braces 226 | // http://eslint.org/docs/rules/object-curly-newline 227 | // TODO: enable once https://github.com/eslint/eslint/issues/6488 is resolved 228 | 'object-curly-newline': ['off', { 229 | ObjectExpression: { minProperties: 0, multiline: true }, 230 | ObjectPattern: { minProperties: 0, multiline: true } 231 | }], 232 | 233 | // enforce "same line" or "multiple line" on object properties. 234 | // http://eslint.org/docs/rules/object-property-newline 235 | 'object-property-newline': ['error', { 236 | allowMultiplePropertiesPerLine: true, 237 | }], 238 | 239 | // allow just one var statement per function 240 | 'one-var': ['error', 'never'], 241 | 242 | // require a newline around variable declaration 243 | // http://eslint.org/docs/rules/one-var-declaration-per-line 244 | 'one-var-declaration-per-line': ['error', 'always'], 245 | 246 | // require assignment operator shorthand where possible or prohibit it entirely 247 | // http://eslint.org/docs/rules/operator-assignment 248 | 'operator-assignment': ['error', 'always'], 249 | 250 | // enforce operators to be placed before or after line breaks 251 | 'operator-linebreak': 'off', 252 | 253 | // enforce padding within blocks 254 | 'padded-blocks': ['error', 'never'], 255 | 256 | // require quotes around object literal property names 257 | // http://eslint.org/docs/rules/quote-props.html 258 | 'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }], 259 | 260 | // specify whether double or single quotes should be used 261 | quotes: ['error', 'single', { avoidEscape: true }], 262 | 263 | // do not require jsdoc 264 | // http://eslint.org/docs/rules/require-jsdoc 265 | 'require-jsdoc': 'off', 266 | 267 | // require or disallow use of semicolons instead of ASI 268 | semi: ['error', 'always'], 269 | 270 | // enforce spacing before and after semicolons 271 | 'semi-spacing': ['error', { before: false, after: true }], 272 | 273 | // requires object keys to be sorted 274 | 'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }], 275 | 276 | // sort variables within the same declaration block 277 | 'sort-vars': 'off', 278 | 279 | // require or disallow space before blocks 280 | 'space-before-blocks': 'error', 281 | 282 | // require or disallow space before function opening parenthesis 283 | // http://eslint.org/docs/rules/space-before-function-paren 284 | 'space-before-function-paren': ['error', { anonymous: 'always', named: 'never' }], 285 | 286 | // require or disallow spaces inside parentheses 287 | 'space-in-parens': ['error', 'never'], 288 | 289 | // require spaces around operators 290 | 'space-infix-ops': 'error', 291 | 292 | // Require or disallow spaces before/after unary operators 293 | // http://eslint.org/docs/rules/space-unary-ops 294 | 'space-unary-ops': ['error', { 295 | words: true, 296 | nonwords: false, 297 | overrides: { 298 | }, 299 | }], 300 | 301 | // require or disallow a space immediately following the // or /* in a comment 302 | 'spaced-comment': ['error', 'always', { 303 | exceptions: ['-', '+'], 304 | markers: ['=', '!'] // space here to support sprockets directives 305 | }], 306 | 307 | // require or disallow the Unicode Byte Order Mark 308 | // http://eslint.org/docs/rules/unicode-bom 309 | 'unicode-bom': ['error', 'never'], 310 | 311 | // require regex literals to be wrapped in parentheses 312 | 'wrap-regex': 'off' 313 | } 314 | }; 315 | -------------------------------------------------------------------------------- /rules/react.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | 'react' 4 | ], 5 | // View link below for react rules documentation 6 | // https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules 7 | rules: { 8 | // Specify whether double or single quotes should be used in JSX attributes 9 | // http://eslint.org/docs/rules/jsx-quotes 10 | 'jsx-quotes': ['error', 'prefer-double'], 11 | 12 | // 'class-methods-use-this': ['error', { 13 | // exceptMethods: [ 14 | // 'render', 15 | // 'getInitialState', 16 | // 'getDefaultProps', 17 | // 'getChildContext', 18 | // 'componentWillMount', 19 | // 'componentDidMount', 20 | // 'componentWillReceiveProps', 21 | // 'shouldComponentUpdate', 22 | // 'componentWillUpdate', 23 | // 'componentDidUpdate', 24 | // 'componentWillUnmount', 25 | // ], 26 | // }], 27 | 28 | // Prevent missing displayName in a React component definition 29 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md 30 | 'react/display-name': ['off', { 'ignoreTranspilerName': false }], 31 | 32 | // Forbid certain propTypes (any, array, object) 33 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md 34 | 'react/forbid-prop-types': ['error', { 'forbid': ['any', 'array', 'object'] }], 35 | 36 | // Enforce boolean attributes notation in JSX 37 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md 38 | 'react/jsx-boolean-value': ['error', 'never'], 39 | 40 | // Validate closing bracket location in JSX 41 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md 42 | 'react/jsx-closing-bracket-location': ['error', 'line-aligned'], 43 | 44 | // Enforce or disallow spaces inside of curly braces in JSX attributes 45 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md 46 | 'react/jsx-curly-spacing': ['error', 'never', { 'allowMultiline': true }], 47 | 48 | // Enforce event handler naming conventions in JSX 49 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md 50 | 'react/jsx-handler-names': ['off', { 51 | eventHandlerPrefix: 'handle', 52 | eventHandlerPropPrefix: 'on', 53 | }], 54 | 55 | // Validate props indentation in JSX 56 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md 57 | 'react/jsx-indent-props': ['error', 2], 58 | 59 | // Validate JSX has key prop when in array or iterator 60 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md 61 | 'react/jsx-key': 'off', 62 | 63 | // Limit maximum of props on a single line in JSX 64 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md 65 | 'react/jsx-max-props-per-line': ['off', { maximum: 1, when: 'multiline' }], 66 | 67 | // Prevent usage of .bind() in JSX props 68 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md 69 | 'react/jsx-no-bind': ['error', { 70 | ignoreRefs: false, 71 | allowArrowFunctions: true, 72 | allowBind: false, 73 | }], 74 | 75 | // Prevent duplicate props in JSX 76 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md 77 | 'react/jsx-no-duplicate-props': ['error', { 'ignoreCase': false }], 78 | 79 | // Prevent usage of unwrapped JSX strings 80 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md 81 | 'react/jsx-no-literals': 'off', 82 | 83 | // Disallow undeclared variables in JSX 84 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md 85 | 'react/jsx-no-undef': 'error', 86 | 87 | // Enforce PascalCase for user-defined JSX components 88 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md 89 | 'react/jsx-pascal-case': ['error', { 90 | allowAllCaps: true, 91 | ignore: [], 92 | }], 93 | 94 | // Enforce propTypes declarations alphabetical sorting 95 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md 96 | 'react/sort-prop-types': [0, { 97 | ignoreCase: false, 98 | callbacksLast: false, 99 | requiredFirst: false, 100 | }], 101 | 102 | // Deprecated in favor of react/jsx-sort-props 103 | 'react/jsx-sort-prop-types': 'off', 104 | 105 | // Enforce props alphabetical sorting 106 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md 107 | 'react/jsx-sort-props': ['off', { 108 | ignoreCase: true, 109 | callbacksLast: false, 110 | shorthandFirst: false, 111 | shorthandLast: false, 112 | noSortAlphabetically: false, 113 | reservedFirst: true, 114 | }], 115 | // Prevent React to be incorrectly marked as unused 116 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md 117 | 'react/jsx-uses-react': ['error'], 118 | 119 | // Prevent variables used in JSX to be incorrectly marked as unused 120 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md 121 | 'react/jsx-uses-vars': 'error', 122 | 123 | // Prevent usage of dangerous JSX properties 124 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger.md 125 | 'react/no-danger': 'warn', 126 | 127 | // Prevent usage of deprecated methods 128 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md 129 | 'react/no-deprecated': ['error'], 130 | 131 | // Prevent usage of setState in componentDidMount 132 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md 133 | 'react/no-did-mount-set-state': 'error', 134 | 135 | // Prevent usage of setState in componentDidUpdate 136 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md 137 | 'react/no-did-update-set-state': 'error', 138 | 139 | // Prevent direct mutation of this.state 140 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md 141 | 'react/no-direct-mutation-state': 'off', 142 | 143 | // Prevent usage of setState in componentWillUpdate 144 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md 145 | // 'react/no-will-update-set-state': 'error', 146 | 147 | // Prevent usage of isMounted 148 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md 149 | 'react/no-is-mounted': 'error', 150 | 151 | // Prevent multiple component definition per file 152 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md 153 | 'react/no-multi-comp': ['error', { 'ignoreStateless': true }], 154 | 155 | // Prevent usage of setState 156 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md 157 | 'react/no-set-state': 'off', 158 | 159 | // Prevent using string references 160 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md 161 | 'react/no-string-refs': 'error', 162 | 163 | // Prevent usage of unknown DOM property 164 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md 165 | 'react/no-unknown-property': 'error', 166 | 167 | // Require ES6 class declarations over React.createClass 168 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md 169 | 'react/prefer-es6-class': ['error', 'always'], 170 | 171 | // Require stateless functions when not using lifecycle methods, setState or ref 172 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md 173 | 'react/prefer-stateless-function': ['error', { ignorePureComponents: true }], 174 | 175 | // Prevent missing props validation in a React component definition 176 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md 177 | 'react/prop-types': ['error', { 'ignore': [], 'customValidators': [], skipUndeclared: false }], 178 | 179 | // Prevent missing React when using JSX 180 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md 181 | 'react/react-in-jsx-scope': 'error', 182 | 183 | // Restrict file extensions that may be required 184 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-extension.md 185 | // 'react/require-extension': [2, { 'extensions': ['.jsx', '.js'] }], 186 | 187 | // Require render() methods to return something 188 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md 189 | 'react/require-render-return': 'error', 190 | 191 | // Prevent extra closing tags for components without children 192 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md 193 | 'react/self-closing-comp': 'error', 194 | 195 | // Enforce spaces before the closing bracket of self-closing JSX elements 196 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md 197 | 'react/jsx-space-before-closing': ['error', 'always'], 198 | 199 | // Enforce component methods order 200 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md 201 | 'react/sort-comp': ['error', { 202 | order: [ 203 | 'static-methods', 204 | 'lifecycle', 205 | '/^on.+$/', 206 | '/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/', 207 | 'everything-else', 208 | '/^render.+$/', 209 | 'render' 210 | ], 211 | }], 212 | 213 | // Prevent missing parentheses around multilines JSX 214 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md 215 | 'react/jsx-wrap-multilines': ['error', { 216 | declaration: true, 217 | assignment: true, 218 | return: true, 219 | }], 220 | 221 | // Validate whitespace in and around the JSX opening and closing brackets 222 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md 223 | 'react/jsx-tag-spacing': ['error', { 224 | closingSlash: 'never', 225 | beforeSelfClosing: 'always', 226 | afterOpening: 'never' 227 | }], 228 | 229 | 'react/jsx-space-before-closing': ['off', 'always'], // deprecated 230 | 231 | // Require that the first prop in a JSX element be on a new line when the element is multiline 232 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md 233 | 'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'], 234 | 235 | // Enforce spacing around jsx equals signs 236 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md 237 | 'react/jsx-equals-spacing': ['error', 'never'], 238 | 239 | // Enforce JSX indentation 240 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md 241 | 'react/jsx-indent': ['error', 2], 242 | 243 | // Disallow target="_blank" on links 244 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md 245 | 'react/jsx-no-target-blank': 'error', 246 | 247 | // only .jsx files may have JSX 248 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md 249 | 'react/jsx-filename-extension': ['error', { 'extensions': ['.jsx'] }], 250 | 251 | // prevent accidental JS comments from being injected into JSX as text 252 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md 253 | 'react/jsx-no-comment-textnodes': 'error', 254 | 'react/no-comment-textnodes': 'off', // deprecated version 255 | 256 | // disallow using React.render/ReactDOM.render's return value 257 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md 258 | 'react/no-render-return-value': 'error', 259 | 260 | // require a shouldComponentUpdate method, or PureRenderMixin 261 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md 262 | 'react/require-optimization': ['off', { 'allowDecorators': [] }], 263 | 264 | // warn against using findDOMNode() 265 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md 266 | 'react/no-find-dom-node': 'error', 267 | 268 | // Prevent void DOM elements from receiving children 269 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md 270 | 'react/void-dom-elements-no-children': 'error', 271 | 272 | // Prevent usage of Array index in keys 273 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md 274 | 'react/no-array-index-key': 'error', 275 | }, 276 | 277 | settings: { 278 | 'import/resolver': { 279 | node: { 280 | extensions: ['.js', '.jsx', '.json'] 281 | } 282 | }, 283 | react: { 284 | pragma: 'React', 285 | version: '15.0' 286 | }, 287 | } 288 | }; 289 | --------------------------------------------------------------------------------