plugins: - compat - import - react - unicorn - flowtype - jsx-a11y - promise - no-use-extend-native - filenames - lodash - node - flowtype-errors extends: - eslint:recommended - plugin:react/recommended - plugin:unicorn/recommended - plugin:import/errors - plugin:import/warnings - plugin:lodash/recommended - plugin:node/recommended env: browser: true node: true es6: true jest: true worker: true serviceworker: true installedESLint: true parserOptions: ecmaVersion: 2017 ecmaFeatures: experimentalObjectRestSpread: true generators: true jsx: true sourceType: module rules: ####################################################################################### # Basics ####################################################################################### indent: - error - 2 - SwitchCase: 1 VariableDeclarator: 1 outerIIFEBody: 0 MemberExpression: 1 FunctionExpression: body: 1 parameters: 1 CallExpression: arguments: 1 linebreak-style: - error - unix quotes: - error - double - avoidEscape: true allowTemplateLiterals: true semi: - error - never no-console: - off no-extra-parens: - off class-methods-use-this: - warn - exceptMethods: - componentWillMount - componentDidMount - componentWillReceiveProps - shouldComponentUpdate - componentWillUpdate - componentDidUpdate - componentWillUnmount func-call-spacing: error # Tolerating both: 1tbs and allman - it's not really that relevant as long # as overall indenting is correct brace-style: - off comma-dangle: - error - never ####################################################################################### # Code Quality ####################################################################################### array-callback-return: - error block-scoped-var: - off # Keeping complexity down. The default of 20 is far to high in my opinion. complexity: - error - 10 consistent-return: error # Allo using curly braces or not (e.g. for simple if-statements) curly: - off default-case: - error dot-location: - error - property dot-notation: - error - allowKeywords: true # Smart option allows simple equal for null-comparison which is good eqeqeq: - error - smart no-alert: error # Was mainly relevant while people extended Object.prototype.xxx guard-for-in: - off # Match ES5 strict no-caller: error # Hard to read code must be forbidden no-div-regex: error # Prefer what ever the developer thinks make code more readable/understandable no-else-return: - off no-empty-function: - error no-empty-pattern: error # This is just stupid no-eq-null: - off no-eval: - error no-extend-native: - error no-fallthrough: - error no-floating-decimal: error # I like some of these, but numbers are to awkward for me. no-implicit-coercion: - error - boolean: true string: true number: false # Does not make sense with ES6 modules no-implicit-globals: - off no-implied-eval: - error no-invalid-this: - error no-iterator: - error no-lone-blocks: error # Good style no-magic-numbers: - error - ignoreArrayIndexes: true ignore: [ -1, 0, 1, 2, 10, 16, 100, 1000 ] no-mixed-operators: - error - groups: - ['&', '|', '^', '~', '<<', '>>', '>>>'] - ['==', '!=', '===', '!==', '>', '>=', '<', '<='] - ['&&', '||'] - ['in', 'instanceof'] allowSamePrecedence: false # Useless formatting with high maintenance no-multi-spaces: error no-multi-str: - error no-native-reassign: - error no-new-func: - error no-new-wrappers: - error no-octal: - error no-octal-escape: error valid-typeof: error # Disable direct init: new require("app-header") no-new-require: error # Use path.join/resolve instead no-path-concat: error # disallow certain object properties # http://eslint.org/docs/rules/no-restricted-properties no-restricted-properties: - error - object: 'arguments' property: callee message: arguments.callee is deprecated - property: __defineGetter__ message: 'Please use Object.defineProperty instead.' - property: __defineSetter__ message: 'Please use Object.defineProperty instead.' - object: Math property: pow message: 'Use the exponentiation operator (**) instead.' # Prevent side effects to arguments objects, but also makes code sometimes more complexer # when you have some logic in place to deal with different argument sets. # Still with ES6 default arguments and destructing params it's easier solvable today than in the past. no-param-reassign: error # Access NodeJS environment. Used mostly for code variations e.g. `NODE_ENV` no-process-env: - off # Deprecated feature no-proto: error # Disabled. Therefor they are variables, right? no-redeclare: - off # Readability wins no-return-assign: error no-script-url: - error no-self-assign: - error no-self-compare: error # Omit magic syntax... Readability for all wins no-sequences: error # Good idea to keep some more error info: # "The fundamental benefit of Error objects is that they automatically keep track of where they were built and originated." no-throw-literal: error no-unmodified-loop-condition: - error no-unused-expressions: - error - allowTernary: true allowShortCircuit: true no-useless-call: - error no-useless-concat: - error no-useless-computed-key: - error no-useless-constructor: - error no-useless-escape: - error no-useless-rename: - error - ignoreDestructuring: false ignoreImport: false ignoreExport: false no-void: - error no-with: error # Mainly for securing code compatibility radix: - error - always # Does not improve maintainability in my opinion... instead makes # unused variables harder to track over time vars-on-top: - off # Prefer inside for readability wrap-iife: - error - inside # Actually interesting that this ugliness should be even something to consider yoda: - error - never # Enforce strict mode globally which also happens during bundling strict: - error - global # Only relevant in IE8 and earlier. Would not allow to use the same error variable in # the same scope. Still no good practice for understanding the code. no-catch-shadow: error # For better maintainability no-shadow: error # Cleaner code no-shadow-restricted-names: error no-sparse-arrays: error no-this-before-super: error # Stupid idea which needs to be prevented no-undef-init: error # I sometimes like using it to differentiate between null and undefined no-undefined: - off no-unexpected-multiline: error no-unreachable: error no-unused-vars: - error - varsIgnorePattern: '^_' args: none no-use-before-define: - error - functions: false classes: false ################################################################# # Stylistic ################################################################# array-bracket-spacing: - error - always - objectsInArrays: false block-spacing: - error - always # See also: https://en.wikipedia.org/wiki/Indent_style # brace-style: # - error # - 1tbs camelcase: error comma-spacing: - error - before: false after: true comma-style: - error - last computed-property-spacing: - error - never consistent-this: - error - self eol-last: error # Useful for debugging in older browsers, but a lot of work to manually add everywhere func-names: - off jsx-quotes: - error - prefer-double max-lines: - warn - skipBlankLines: true skipComments: true max: 250 # Prefering declaration func-style: - error - declaration - allowArrowFunctions: true max-statements-per-line: - error - max: 2 id-length: - error - min: 4 max: 40 # 'i' + 'l' = typical looping constructs # 't' = support convention in ava test runner # 'fs' = built-in fs module exceptions: ["i", "l", "t", "id", "fs", "url", "uri", "key", "obj", "pos", "row", "col", "map", "min", "max"] properties: never # Makes sense in NodeJS for native methods but is flawed because it is based purely on the # naming and marks errors for a lot of user written UI code. no-sync: - off lines-around-directive: - error key-spacing: - error - beforeColon: false afterColon: true mode: strict keyword-spacing: error lines-around-comment: - error - beforeBlockComment: true afterBlockComment: false beforeLineComment: true afterLineComment: false allowBlockStart: true allowBlockEnd: false allowObjectStart: true allowObjectEnd: false allowArrayStart: true allowArrayEnd: false max-depth: - error - maximum: 3 max-len: - error - code: 140 comments: 160 ignoreUrls: true tabWidth: 2 max-nested-callbacks: - error - 3 max-params: - error - 3 max-statements: - error - 25 - ignoreTopLevelFunctions: true new-cap: - error - capIsNew: false new-parens: error # It good to have newlines when declaring a block of variables, but not for just one # where we directly have some actionable stuff afterwards. newline-after-var: - off # Increase readability, but does not work everywhere... therefor we keep it off # and let the individual developer decide. newline-before-return: off newline-per-chained-call: off no-array-constructor: error # Generally prevents errors + rule can be disabled locally when required no-bitwise: error # Don't see why this is regarded as problematic no-continue: off no-control-regex: error no-delete-var: error no-dupe-args: error no-dupe-keys: error no-duplicate-case: error no-empty-character-class: error no-ex-assign: error no-extra-bind: error no-extra-label: error no-func-assign: error no-invalid-regexp: error no-label-var: error no-labels: - error - allowLoop: false allowSwitch: false # Leads to complexer to overlook code no-inline-comments: error # Might be used to improve code for human logic no-lonely-if: off no-multiple-empty-lines: - error - max: 4 maxEOF: 1 maxBOF: 0 # Can help, but also can make code more complex/unnaturally structured no-negated-condition: off no-nested-ternary: error no-new-object: error no-obj-calls: error # Seems to be a new trend to omit this e.g. in Swift and other modern languages # But is pretty convenient in classic for-loops... therefor we allow it there no-plusplus: - error - allowForLoopAfterthoughts: true object-property-newline: - error - allowMultiplePropertiesPerLine: true no-confusing-arrow: error no-duplicate-imports: error no-new-symbol: error object-shorthand: - error - always - ignoreConstructors: true avoidQuotes: true no-restricted-syntax: - error - WithStatement - DebuggerStatement - LabeledStatement no-spaced-func: error no-ternary: - off # Lead to harder to diff changesets no-trailing-spaces: error no-underscore-dangle: off # Getting people to senior level... no-unneeded-ternary: error no-whitespace-before-property: error object-curly-spacing: - error - always one-var: - error - initialized: never one-var-declaration-per-line: - error - initializations operator-assignment: error operator-linebreak: - error - after rest-spread-spacing: - error - never unicode-bom: - error - never use-isnan: error # Not needed with Alman style. Interestingly deals with the same issue in a different way. padded-blocks: - error - never # That's a neat little setting for keeping code readable quote-props: - error - consistent-as-needed semi-spacing: - error - after: true before: false # Variables and Imports should be sorted in semantic groups not by name sort-imports: - off sort-vars: - off # Keeping things readable space-before-blocks: - error - always # Parens belong to the function... a spacing could break easy grasping of the code space-before-function-paren: - error - never space-in-parens: - error - never space-infix-ops: error space-unary-ops: - error - words: true nonwords: false spaced-comment: - error - always # I like the improved readability when using parens wrap-regex: error no-negated-in-lhs: error no-regex-spaces: error no-template-curly-in-string: error no-undef: error no-unused-labels: error require-yield: error ################################################################# # ES6+ ################################################################# # Call me old fashioned arrow-body-style: - error - as-needed arrow-parens: - error - always arrow-spacing: error constructor-super: error # The star is no operator but a modifier of the function generator-star-spacing: - error - before no-class-assign: error no-prototype-builtins: error no-loop-func: error no-const-assign: error no-dupe-class-members: error # Trying to start new code the modern way - at least for what it makes sense prefer-arrow-callback: - error prefer-rest-params: - error prefer-spread: - error prefer-template: error ####################################################################################### # Compat Plugin ####################################################################################### compat/compat: warn ####################################################################################### # Import Plugin ####################################################################################### # Loader syntax is useful when loading files with alternative approaches e.g. # to detect images sizes, generating API docs, etc. import/no-webpack-loader-syntax: off import/no-absolute-path: error import/no-namespace: error import/no-commonjs: error import/no-amd: error ####################################################################################### # React Plugin ####################################################################################### react/jsx-no-undef: - error react/jsx-pascal-case: - error - allowAllCaps: true ignore: [] react/jsx-uses-react: - error react/jsx-uses-vars: - error react/jsx-filename-extension: - error - extensions: [ ".js" ] # Developer Support react/display-name: error react/require-render-return: error react/jsx-key: error # Bad practise react/no-children-prop: error # Make sure React is imported when using JSX react/react-in-jsx-scope: error # Good idea but currently warns on too many false issues react/no-unused-prop-types: off # Good idea but currently breaks with helper rendering methods for functional components react/no-multi-comp: off # Clean code react/prefer-es6-class: error react/prefer-stateless-function: error react/self-closing-comp: error react/sort-comp: error react/jsx-wrap-multilines: error # Formatting react/jsx-closing-bracket-location: - error - line-aligned react/jsx-curly-spacing: - error react/jsx-handler-names: - off react/jsx-indent: - error - 2 react/jsx-indent-props: - error - 2 # Unsafe react/no-danger: error react/no-danger-with-children: error react/no-direct-mutation-state: error react/no-unescaped-entities: error react/style-prop-object: error react/jsx-no-duplicate-props: - error - ignoreCase: true react/jsx-no-target-blank: error # Don't pollute DOM react/no-unknown-property: error # Deprecated react/no-deprecated: error react/no-is-mounted: error react/no-string-refs: error # Unsafe + Bad performance + Deprecated react/no-find-dom-node: error # Bad performance react/no-did-mount-set-state: error react/no-did-update-set-state: error react/jsx-no-bind: warn ####################################################################################### # Accessibility Plugin ####################################################################################### jsx-a11y/aria-role: error jsx-a11y/img-has-alt: error jsx-a11y/img-redundant-alt: error jsx-a11y/no-access-key: error jsx-a11y/aria-props: error jsx-a11y/label-has-for: error jsx-a11y/role-has-required-aria-props: error ####################################################################################### # Promise Plugin ####################################################################################### promise/param-names: error promise/always-return: off promise/catch-or-return: warn promise/no-native: off # Currently fails with hard eslint parse errors in some use cases (v3) # promise/no-return-wrap: error ####################################################################################### # Other Plugins ####################################################################################### # Prevent old style extensions of native objects no-use-extend-native/no-use-extend-native: error # Don't allow dashes or underscores. Keep in sync with exported symbol name. filenames/match-regex: - error - "^[a-zA-Z][a-zA-Z0-9.]+$" filenames/match-exported: error # Index files are okay filenames/no-index: off # Most of the normal ES2015 methods are okay to use nowadays lodash/prefer-lodash-method: off # Not every type check has to use a lodash method lodash/prefer-lodash-typecheck: off # Utility method should not be a requirement lodash/prefer-constant: off # Warns on "global" imports, but also detects cherry imports (which are the future) lodash/import-scope: off # Typically we use Babel/Buble in most projects right now node/no-unsupported-features: off # NPM installs in a flat hierarchy which prevent detecting request solved by dependencies node/no-unpublished-require: off # Duplicated unicorn/no-process-exit: off # We have something more powerful available to check filenames unicorn/filename-case: off unicorn/catch-error-name: - error - name: error # Improve support for usage of Flowtype flowtype-errors/show-errors: error