0.1.15 • Published 3 years ago

eslint-plugin-coffee v0.1.15

Weekly downloads
2,807
License
MIT
Repository
github
Last release
3 years ago

eslint-plugin-coffee

ESLint custom parser + rules for linting CoffeeScript source files

Table of Contents

Getting Started

The following sections will give you an overview of what this project is, why it exists and how it works.

If you are ready to get started you can jump to Installation.

Why does this project exist?

ESLint is the preeminent linter in the JavaScript world.

As of CoffeeScript v2.5.0, the CoffeeScript compiler exposes an Abstract Syntax Tree (AST) representation of your source code which enables usage with AST-based tools like ESLint.

eslint-plugin-coffee is the package that allows you to use ESLint in CoffeeScript-based projects :sparkles: :rainbow: :sparkles:

How does eslint-plugin-coffee work?

The AST (see above) produced by CoffeeScript is different than the AST format that ESLint requires to work.

This means that by default, the CoffeeScript AST is not compatible with the 1000s of rules which have been written by and for ESLint users over the many years the project has been going.

The great thing is, though, we can provide ESLint with an alternative parser to use - that is a first-class use case offered by ESLint. eslint-plugin-coffee provides ESLint with that alternative parser for CoffeeScript.

At that point, ESLint is capable of "digesting" CoffeeScript source code. But what about the rules? Keep reading...

Can I use all of the existing ESLint plugins and rules without any changes?

The short answer is, no.

The great news is, there are many rules which will "just work" without you having to change anything about them or provide any custom alternatives.

For rules which don't "just work" for CoffeeScript, eslint-plugin-coffee aims to provide a CoffeeScript-compatible custom alternative rule - this includes rules that come with ESLint, as well as from the popular ESLint plugins eslint-plugin-react, eslint-plugin-import, eslint-plugin-react-native, and eslint-plugin-jsx-a11y.

Here's a guide to all of the supported rules.

Installation

Make sure you have supported versions of CoffeeScript and ESLint installed and install the plugin:

yarn:

yarn add --dev coffeescript@^2.5.0 eslint@^6.0.0 eslint-plugin-coffee

npm:

npm install --save-dev coffeescript@^2.5.0 eslint@^6.0.0 eslint-plugin-coffee

Usage

Add eslint-plugin-coffee to the parser field and coffee to the plugins section of your .eslintrc configuration file, and disable ESLint rules that aren't compatible with CoffeeScript:

{
  "parser": "eslint-plugin-coffee",
  "plugins": ["coffee"],
  "extends": [
    "plugin/coffee:disable-incompatible"
  ]
}

Then configure the rules you want to use under the rules section.

{
  "parser": "eslint-plugin-coffee",
  "plugins": ["coffee"],
  "rules": {
    // Can include existing rules that "just work":
    "no-undef": "error",
    "react/no-array-index-key": "error",
    // ...CoffeeScript-specific rules:
    "coffee/spread-direction": ["error", "postfix"],
    // ...and CoffeeScript custom overriding rules.
    // For these, the corresponding existing rule should also be disabled if need be:
    "no-unused-vars": "off",
    "coffee/no-unused-vars": "error"
}

To apply eslint:recommended (the set of rules which are recommended for all projects by the ESLint team) with this plugin, add plugin:coffee/eslint-recommended (which will adjust the eslint:recommended config appropriately for CoffeeScript) to your config:

{
  "extends": [
    "plugin:coffee/eslint-recommended"
  ]
}

To apply the well-known Airbnb config with this plugin, add plugin:coffee/airbnb (for React projects) or plugin:coffee/airbnb-base (for non-React projects) to your config:

{
  "extends": [
    // for React projects:
    "plugin:coffee/airbnb",
    // OR for non-React projects:
    "plugin:coffee/airbnb-base"
  ],
  "rules": {
    // You may then want to disable some of the more "controversial" Airbnb rules
    // when applied to CoffeeScript, e.g.:
    "coffee/implicit-arrow-linebreak": "off",
    "coffee/comma-style": "off",
    "coffee/jsx-wrap-multilines": "off"
  }
}

eslint-plugin-import

If you want to use rules from eslint-plugin-import (whether rules that "just work" or CoffeeScript custom overrides), add plugin:coffee/import (which configures eslint-plugin-import to work with CoffeeScript) to your config, along with the rules you want to use:

{
  "extends": [
    "plugin:coffee/import"
  ],
  "rules": {
    // Can include existing rules that "just work":
    "import/no-unresolved": "error",
    // ...and CoffeeScript custom overriding rules.
    // For these, the corresponding existing rule should also be disabled if need be:
    "import/no-anonymous-default-export": "off",
    "coffee/no-anonymous-default-export": "error",
  }
}

See below for a list of all supported rules from eslint-plugin-import.

eslint-plugin-react, eslint-plugin-react-native, eslint-plugin-jsx-a11y

If you want to use rules from eslint-plugin-react, eslint-plugin-react-native and/or eslint-plugin-jsx-a11y (whether rules that "just work" or CoffeeScript custom overrides), add those plugins and rules to your config:

{
  "plugins": [
    "coffee",
    "react",
    "react-native",
    "jsx-a11y"
  ],
  "rules": {
    // Can include existing rules that "just work":
    "react/no-array-index-key": "error",
    "react-native/no-inline-styles": "error",
    "jsx-a11y/accessible-emoji": "error",
    // ...and CoffeeScript custom overriding rules.
    // For these, the corresponding existing rule should also be disabled if need be:
    "react/prop-types": "off",
    "coffee/prop-types": "error",
    "react-native/no-unused-styles": "off",
    "coffee/no-unused-styles": "error",
  }
} 

To apply the recommended config from eslint-plugin-react, add plugin:coffee/react-recommended to your config:

{
  "extends": [
    "plugin:coffee/react-recommended"
  ]
}

To apply the all config from eslint-plugin-react, add plugin:coffee/react-all to your config:

{
  "extends": [
    "plugin:coffee/react-all"
  ]
}

To apply the recommended config from eslint-plugin-jsx-a11y, add plugin:jsx-a11y/recommended to your config:

{
  "plugins: [
    "coffee",
    "jsx-a11y"
  ],
  "extends": [
    "plugin:jsx-a11y/recommended"
  ]
}

To apply the strict config from eslint-plugin-jsx-a11y, add plugin:jsx-a11y/strict to your config:

{
  "plugins: [
    "coffee",
    "jsx-a11y"
  ],
  "extends": [
    "plugin:jsx-a11y/strict"
  ]
}

See below for a list of all supported rules from eslint-plugin-react, eslint-plugin-react-native and eslint-plugin-jsx-a11y.

Running from the command line

To invoke ESLint from the command line, you can add an appropriate script to your package.json scripts section, for example:

{
  "scripts": {
    "lint": "eslint 'src/**/*.coffee'",
    "lint-fix": "eslint --fix 'src/**/*.coffee'"
  }
}

Then you can invoke those scripts as needed from the command line to lint the CoffeeScript source files in your project:

npm run lint

Running from your editor

Running ESLint directly from your code editor (e.g. on save) provides a quick feedback loop while developing.

Depending on your editor, there may or may not currently be a straightforward way to get ESLint running against .coffee files (e.g. using an ESLint editor plugin).

If you're having trouble getting ESLint running in your editor (and it's not listed below), please file an issue and we'll try and help with support for your editor.

VS Code

To run ESLint from VS Code, first install the VS Code ESLint extension.

Then add to your VS Code settings.json:

"eslint.validate": [
    // "javascript", "javascriptreact" is the default setting
    "javascript",
    "javascriptreact",
    {
        "language": "coffeescript",
        "autoFix": true
    },
]

Sublime Text

From @PatrickKing:

  • Enable Package Control (if it is not already enabled).
  • Enable CoffeeScript language support by installing Better CoffeeScript with Package Control (if it is not already installed).
  • Install SublimeLinter and SublimeLinter-eslint with Package Control.
  • Ensure eslint and eslint-plugin-coffee are installed locally with package.json or globally. (If globally, Try eslint some_file.coffee at your terminal to make sure.)
  • Open "Preferences: SublimeLinter settings", and add/modify your user settings with:
"linters": {
    "eslint": {
        "selector": "source.js - meta.attribute-with-value, source.coffee"
    }
}

Other editors

We will add instructions for different code editors here as they become supported.

If you've gotten ESLint running in an editor not listed here and would like to share back, please file an issue!

Usage with Prettier

You can now use Prettier to format your CoffeeScript code, see the Prettier CoffeeScript plugin README for instructions.

To disable our code formatting related rules, install eslint-config-prettier:

npm install --save-dev eslint-config-prettier

Then use the prettier config exposed by this plugin:

{
  "extends": ["plugin:coffee/prettier"]
}

Alternatively, if you want to run Prettier as an ESLint rule (a nice option especially if you're running ESLint in fix mode via your editor):

npm install --save-dev eslint-config-prettier eslint-plugin-prettier

Then use the prettier-run-as-rule config exposed by this plugin:

{
  "extends": ["plugin:coffee/prettier-run-as-rule"]
}

Supported Rules

Key: :heavy_check_mark: = ESLint recommended, :wrench: = fixable

ESLint-included rules

Possible Errors

NameDescription
:heavy_check_mark:coffee/no-async-promise-executordisallow using an async function as a Promise executor
coffee/no-await-in-loopdisallow await inside of loops
:heavy_check_mark:coffee/no-compare-neg-zerodisallow comparing against -0
:heavy_check_mark:coffee/no-cond-assigndisallow assignment operators in conditional expressions
no-consoledisallow the use of console
:heavy_check_mark:coffee/no-constant-conditiondisallow constant expressions in conditions
:heavy_check_mark:no-control-regexdisallow control characters in regular expressions
:heavy_check_mark:no-debuggerdisallow the use of debugger
:heavy_check_mark:no-dupe-keysdisallow duplicate keys in object literals
:heavy_check_mark:no-duplicate-casedisallow duplicate case labels
:heavy_check_mark:no-emptydisallow empty block statements
:heavy_check_mark:coffee/no-empty-character-classdisallow empty character classes in regular expressions
:heavy_check_mark:no-ex-assigndisallow reassigning exceptions in catch clauses
:heavy_check_mark:coffee/no-extra-boolean-castdisallow unnecessary boolean casts :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
:heavy_check_mark:coffee/no-inner-declarationsdisallow variable or function "declarations" in nested blocks
:heavy_check_mark:no-invalid-regexpdisallow invalid regular expression strings in RegExp constructors
:heavy_check_mark:no-irregular-whitespacedisallow irregular whitespace
:heavy_check_mark:no-misleading-character-classdisallow characters which are made with multiple code points in character class syntax
:heavy_check_mark:no-obj-callsdisallow calling global object properties as functions
:heavy_check_mark:no-prototype-builtinsdisallow calling some Object.prototype methods directly on objects
:heavy_check_mark::wrench:coffee/no-regex-spacesdisallow multiple spaces in regular expressions
:heavy_check_mark:no-sparse-arraysdisallow sparse arrays
coffee/no-template-curly-in-stringdisallow template literal placeholder syntax in regular strings
:heavy_check_mark:coffee/no-unreachabledisallow unreachable code after return, throw, continue, and break statements
:heavy_check_mark:no-unsafe-finallydisallow control flow statements in finally blocks
:heavy_check_mark:coffee/no-unsafe-negationdisallow negating the left operand of relational operators
:heavy_check_mark:require-atomic-updatesdisallow assignments that can lead to race conditions due to usage of await or yield
:heavy_check_mark:coffee/use-isnanrequire calls to isNaN() when checking for NaN
:heavy_check_mark:coffee/valid-typeofenforce comparing typeof expressions against valid strings

Best Practices

NameDescription
accessor-pairsenforce getter and setter pairs in objects and classes :warning: Only checks e.g. Object.defineProperty() since CoffeeScript doesn't support getters/setters
coffee/block-scoped-varenforce the use of variables within the scope they are defined
coffee/class-methods-use-thisenforce that class methods utilize this
coffee/complexityenforce a maximum cyclomatic complexity allowed in a program
default-caserequire else cases in switch statements
:wrench:coffee/dot-locationenforce consistent newlines before and after dots
:wrench:coffee/dot-notationenforce dot notation whenever possible
coffee/guard-for-inrequire for-of loops to include own or an if statement
max-classes-per-fileenforce a maximum number of classes per file
no-alertdisallow the use of alert, confirm, and prompt
no-callerdisallow the use of arguments.caller or arguments.callee
:wrench:coffee/no-div-regexdisallow division operators explicitly at the beginning of regular expressions
coffee/no-else-returndisallow else blocks after return statements in if statements :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
coffee/no-empty-functiondisallow empty functions
:heavy_check_mark:no-empty-patterndisallow empty destructuring patterns
no-evaldisallow the use of eval()
no-extend-nativedisallow extending native types
:wrench:coffee/no-extra-binddisallow unnecessary calls to .bind()
:wrench:no-floating-decimaldisallow leading or trailing decimal points in numeric literals
:heavy_check_mark:no-global-assigndisallow assignments to native objects or read-only global variables :warning: Only applies to e.g. ++ operations since CoffeeScript generates declarations on other write references.
:wrench:coffee/no-implicit-coerciondisallow shorthand type conversions
no-implied-evaldisallow the use of eval()-like methods
coffee/no-invalid-thisdisallow this keywords outside of classes or class-like objects
no-iteratordisallow the use of the __iterator__ property
coffee/no-loop-funcdisallow function declarations that contain unsafe references inside loop statements
coffee/no-magic-numbersdisallow magic numbers
:wrench:coffee/no-multi-spacesdisallow multiple spaces
coffee/no-newdisallow new operators outside of assignments or comparisons
no-new-funcdisallow new operators with the Function object
no-new-wrappersdisallow new operators with the String, Number, and Boolean objects
no-param-reassigndisallow reassigning function parameters
no-protodisallow the use of the __proto__ property
no-restricted-propertiesdisallow certain properties on certain objects
coffee/no-return-assigndisallow assignment operators in return statements :warning: Currently, this also flags assignments in implicit return statements
no-script-urldisallow javascript: urls
:heavy_check_mark:coffee/no-self-assigndisallow assignments where both sides are exactly the same
coffee/no-self-comparedisallow comparisons where both sides are exactly the same
coffee/no-sequencesdisallow semicolon operators
no-throw-literaldisallow throwing literals as exceptions
coffee/no-unmodified-loop-conditiondisallow unmodified loop conditions
coffee/no-unused-expressionsdisallow unused expressions
no-useless-calldisallow unnecessary calls to .call() and .apply()
:heavy_check_mark:no-useless-catchdisallow unnecessary catch clauses
no-useless-concatdisallow unnecessary concatenation of literals or template literals
:heavy_check_mark:coffee/no-useless-escapedisallow unnecessary escape characters
:wrench:coffee/no-useless-returndisallow redundant return statements
no-warning-commentsdisallow specified warning terms in comments
prefer-promise-reject-errorsrequire using Error objects as Promise rejection reasons
radixenforce the consistent use of the radix argument when using parseInt()
require-unicode-regexpenforce the use of u flag on RegExp
coffee/vars-on-toprequire "declarations" be placed at the top of their containing scope
coffee/yodarequire or disallow "Yoda" conditions :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
:heavy_check_mark:no-delete-vardisallow deleting variables
no-restricted-globalsdisallow specified global variables
coffee/no-shadowdisallow variable declarations from shadowing variables declared in the outer scope
:heavy_check_mark:no-undefdisallow the use of undeclared variables unless mentioned in ###global ### comments
:heavy_check_mark:coffee/no-unused-varsdisallow unused variables
coffee/no-use-before-definedisallow the use of variables before they are "defined"

Node.js and CommonJS

NameDescription
coffee/callback-returnrequire return statements after callbacks
global-requirerequire require() calls to be placed at top-level module scope
handle-callback-errrequire error handling in callbacks
no-buffer-constructordisallow use of the Buffer() constructor
no-new-requiredisallow new operators with calls to require
no-path-concatdisallow string concatenation with __dirname and __filename
no-process-envdisallow the use of process.env
no-process-exitdisallow the use of process.exit()
no-restricted-modulesdisallow specified modules when loaded by require
no-syncdisallow synchronous methods

Stylistic Issues

NameDescription
coffee/array-bracket-newlineenforce linebreaks after opening and before closing array brackets :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
:wrench:coffee/array-bracket-spacingenforce consistent spacing inside array brackets
coffee/array-element-newlineenforce line breaks after each array element :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
coffee/camelcaseenforce camelcase naming convention
:wrench:coffee/capitalized-commentsenforce or disallow capitalization of the first letter of a comment
:wrench:comma-spacingenforce consistent spacing before and after commas
coffee/comma-styleenforce consistent comma style :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
:wrench:computed-property-spacingenforce consistent spacing inside computed property brackets
coffee/consistent-thisenforce consistent naming when capturing the current execution context
:wrench:eol-lastrequire or disallow newline at the end of files
coffee/function-paren-newlineenforce consistent line breaks inside function parentheses :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
id-blacklistdisallow specified identifiers
coffee/id-lengthenforce minimum and maximum identifier lengths
coffee/id-matchrequire identifiers to match a specified regular expression
coffee/implicit-arrow-linebreakenforce the location of function bodies :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
:wrench:jsx-quotesenforce the consistent use of either double or single quotes in JSX attributes
:wrench:key-spacingenforce consistent spacing between keys and values in object literal properties
:wrench:coffee/keyword-spacingenforce consistent spacing before and after keywords
line-comment-positionenforce position of line comments
:wrench:linebreak-styleenforce consistent linebreak style
:wrench:coffee/lines-around-commentrequire empty lines around comments
coffee/lines-between-class-membersrequire or disallow an empty line between class members :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
coffee/max-depthenforce a maximum depth that blocks can be nested
coffee/max-lenenforce a maximum line length
max-linesenforce a maximum number of lines per file
coffee/max-lines-per-functionenforce a maximum number of line of code in a function
max-nested-callbacksenforce a maximum depth that callbacks can be nested
max-paramsenforce a maximum number of parameters in function definitions
max-statementsenforce a maximum number of statements allowed in function blocks
:wrench:coffee/multiline-comment-styleenforce a particular style for multiline comments
new-caprequire constructor names to begin with a capital letter
:wrench:new-parensenforce or disallow parentheses when invoking a constructor with no arguments
coffee/newline-per-chained-callrequire a newline after each call in a method chain :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
no-array-constructordisallow Array constructors
no-bitwisedisallow bitwise operators
no-continuedisallow continue statements
no-inline-commentsdisallow inline comments after code
coffee/no-lonely-ifdisallow if statements as the only statement in else blocks :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
coffee/no-mixed-operatorsdisallow mixed binary operators
no-multi-assigndisallow use of chained assignment expressions
:wrench:coffee/no-multiple-empty-linesdisallow multiple empty lines
coffee/no-negated-conditiondisallow negated conditions
no-new-objectdisallow Object constructors
no-plusplusdisallow the unary operators ++ and --
no-restricted-syntaxdisallow specified syntax
no-tabsdisallow all tabs
:wrench:no-trailing-spacesdisallow trailing whitespace at the end of lines
coffee/no-underscore-dangledisallow dangling underscores in identifiers
:wrench:coffee/no-unneeded-ternarydisallow if/else expressions when simpler alternatives exist
:wrench:coffee/no-whitespace-before-propertydisallow whitespace before properties
:wrench:coffee/object-curly-spacingenforce consistent spacing inside braces
coffee/object-property-newlineenforce placing object properties on separate lines :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
:wrench:coffee/operator-assignmentrequire or disallow assignment operator shorthand where possible
coffee/operator-linebreakenforce consistent linebreak style for operators :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
coffee/prefer-object-spreaddisallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
:wrench:quote-propsrequire quotes around object literal property names
sort-keysrequire object keys to be sorted
:wrench:space-in-parensenforce consistent spacing inside parentheses
:wrench:coffee/space-infix-opsrequire spacing around infix operators
:wrench:coffee/space-unary-opsenforce consistent spacing before or after unary operators
:wrench:coffee/spaced-commentenforce consistent spacing after the # or ### in a comment
:wrench:unicode-bomrequire or disallow Unicode byte order mark (BOM)
:wrench:coffee/wrap-regexrequire parenthesis around regex literals

"ECMAScript 6"

NameDescription
:wrench:coffee/arrow-spacingenforce consistent spacing before and after the arrow in functions
:heavy_check_mark:constructor-superrequire super() calls in constructors
:heavy_check_mark:coffee/no-class-assigndisallow reassigning class members
:heavy_check_mark:no-dupe-class-membersdisallow duplicate class members
no-duplicate-importsdisallow duplicate module imports
:heavy_check_mark:no-new-symboldisallow new operators with the Symbol object
no-restricted-importsdisallow specified modules when loaded by import
:heavy_check_mark:coffee/no-this-before-superdisallow this/super before calling super() in constructors
:wrench:coffee/no-useless-computed-keydisallow unnecessary computed property keys in objects and classes
coffee/no-useless-constructordisallow unnecessary constructors
:wrench:no-useless-renamedisallow renaming import, export, and destructured assignments to the same name
coffee/object-shorthandrequire or disallow method and property shorthand syntax for object literals :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
coffee/prefer-destructuringrequire destructuring from arrays and/or objects :warning: Unlike the ESLint rule, the CoffeeScript version is not fixable
:wrench:prefer-numeric-literalsdisallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals
prefer-rest-paramsrequire rest parameters instead of arguments
prefer-spreadrequire spread operators instead of .apply()
:wrench:coffee/prefer-templaterequire interpolated strings instead of string concatenation
:wrench:coffee/rest-spread-spacingenforce spacing between rest and spread operators and their expressions
:wrench:sort-importsenforce sorted import declarations within modules
symbol-descriptionrequire symbol descriptions
:wrench:coffee/template-curly-spacingrequire or disallow spacing around embedded expressions of template strings

CoffeeScript-specific rules

NameDescription
coffee/capitalized-class-namesEnforce capitalization of the first letter of a class name
coffee/no-backticksDisallow use of the backtick operator
coffee/english-operatorsEnforce or disallow use of "English" operatorscoffee/no-unnecessary-fat-arrowDisallow unnecessary use of =>coffee/no-overwriteDisallow modifying variables from the same or outer scopes
coffee/implicit-objectDisallow implicit objects
coffee/implicit-callDisallow implicit function calls
coffee/empty-func-parensEnforce or disallow the use of parentheses for empty parameter lists
coffee/shorthand-thisEnforce or disallow use of @ vs this
coffee/spread-directionEnforce consistent use of prefix vs postfix ...
:wrench:coffee/postfix-comprehension-assign-parensRequire parentheses around potentially confusing assignments in postfix comprehensions
coffee/no-nested-interpolationDisallow nesting interpolations
coffee/no-private-function-fat-arrowsDisallow use of => for "private" functions in class bodies
coffee/no-unnecessary-double-quotesDisallow use of double quotes for strings when single quotes would suffice
:wrench:coffee/boolean-keywordsRequire or disallow usage of specific boolean keywords

eslint-plugin-react rules

Key: :heavy_check_mark: = recommended, :wrench: = fixable

NameDescription
coffee/boolean-prop-namingEnforces consistent naming for boolean props
react/button-has-typeForbid "button" element without an explicit "type" attribute
coffee/default-props-match-prop-typesPrevent extraneous defaultProps on components
coffee/destructuring-assignmentRule enforces consistent usage of destructuring assignment in component
:heavy_check_mark:coffee/display-namePrevent missing displayName in a React component definition
react/forbid-component-propsForbid certain props on Components
react/forbid-dom-propsForbid certain props on DOM Nodes
react/forbid-elementsForbid certain elements
coffee/forbid-prop-typesForbid certain propTypes
react/forbid-foreign-prop-typesForbid foreign propTypes
coffee/no-access-state-in-setstatePrevent using this.state inside this.setState
react/no-array-index-keyPrevent using Array index in key props
:heavy_check_mark:react/no-children-propPrevent passing children as props
react/no-dangerPrevent usage of dangerous JSX properties
:heavy_check_mark:coffee/no-danger-with-childrenPrevent problem with children and props.dangerouslySetInnerHTML
:heavy_check_mark:coffee/no-deprecatedPrevent usage of deprecated methods, including component lifecycle methods
react/no-did-mount-set-statePrevent usage of setState in componentDidMount
react/no-did-update-set-statePrevent usage of setState in componentDidUpdate
:heavy_check_mark:react/no-direct-mutation-statePrevent direct mutation of this.state
:heavy_check_mark:react/no-find-dom-nodePrevent usage of findDOMNode
:heavy_check_mark:react/no-is-mountedPrevent usage of isMounted
coffee/no-multi-compPrevent multiple component definition per file
coffee/no-redundant-should-component-updatePrevent usage of shouldComponentUpdate when extending React.PureComponent
:heavy_check_mark:coffee/no-render-return-valuePrevent usage of the return value of React.render
react/no-set-statePrevent usage of setState
coffee/no-typosPrevent common casing typos
:heavy_check_mark:react/no-string-refsPrevent using string references in ref attribute.
coffee/no-this-in-sfcPrevent using this in stateless functional components
:heavy_check_mark:coffee/no-unescaped-entitiesPrevent invalid characters from appearing in markup
:heavy_check_mark::wrench:react/no-unknown-propertyPrevent usage of unknown DOM property
react/no-unsafePrevent usage of unsafe lifecycle methods
coffee/no-unused-prop-typesPrevent definitions of unused prop types
coffee/no-unused-statePrevent definitions of unused state properties
react/no-will-update-set-statePrevent usage of setState in componentWillUpdate
react/prefer-es6-classEnforce ES5 or ES6 class for React Components
coffee/prefer-stateless-functionEnforce stateless React Components to be written as a pure function
:heavy_check_mark:coffee/prop-typesPrevent missing props validation in a React component definition
:heavy_check_mark:react/react-in-jsx-scopePrevent missing React when using JSX
coffee/require-default-propsEnforce a defaultProps definition for every prop that is not a required prop
react/require-optimizationEnforce React components to have a shouldComponentUpdate method
:wrench:react/self-closing-compPrevent extra closing tags for components without children
coffee/sort-compEnforce component methods order :warning: Unlike the eslint-plugin-react rule, the CoffeeScript version is not fixable
coffee/sort-prop-typesEnforce propTypes declarations alphabetical sorting
react/static-property-placementEnforces where React component static properties should be positioned
coffee/style-prop-objectEnforce style prop value being an object
react/void-dom-elements-no-childrenPrevent void DOM elements (e.g. <img />, <br />) from receiving children

JSX-specific rules

NameDescription
coffee/jsx-boolean-valueEnforce boolean attributes notation in JSX :warning: Unlike the eslint-plugin-react rule, the CoffeeScript version is not fixable
react/jsx-child-element-spacingEnforce or disallow spaces inside of curly braces in JSX attributes and expressions.
:wrench:coffee/jsx-closing-bracket-locationValidate closing bracket location in JSX
:wrench:react/jsx-closing-tag-locationValidate closing tag location in JSX
coffee/jsx-curly-newlineEnforce or disallow newlines inside of curly braces in JSX attributes and expressions :warning: Unlike the eslint-plugin-react rule, the CoffeeScript version is not fixable
:wrench:react/jsx-curly-spacingEnforce or disallow spaces inside of curly braces in JSX attributes and expressions
:wrench:react/jsx-equals-spacingEnforce or disallow spaces around equal signs in JSX attributes
react/jsx-filename-extensionRestrict file extensions that may contain JSX
coffee/jsx-first-prop-new-lineEnforce position of the first prop in JSX :warning: Unlike the eslint-plugin-react rule, the CoffeeScript version is not fixable
coffee/jsx-handler-namesEnforce event handler naming conventions in JSX
:wrench:coffee/jsx-indentValidate JSX indentation
:wrench:react/jsx-indent-propsValidate props indentation in JSX
:heavy_check_mark:coffee/jsx-keyValidate JSX has key prop when in array or iterator
react/jsx-max-depthValidate JSX maximum depth
coffee/jsx-max-props-per-lineLimit maximum of props on a single line in JSX :warning: Unlike the eslint-plugin-react rule, the CoffeeScript version is not fixable
coffee/jsx-no-bindPrevent usage of .bind() and arrow functions in JSX props
:heavy_check_mark:coffee/jsx-no-comment-textnodesPrevent comments from being inserted as text nodes
:heavy_check_mark:react/jsx-no-duplicate-propsPrevent duplicate props in JSX
react/jsx-no-literalsPrevent usage of unwrapped JSX strings
:heavy_check_mark:coffee/jsx-no-target-blankPrevent usage of unsafe target='_blank'
:heavy_check_mark:react/jsx-no-undefDisallow undeclared variables in JSX
coffee/jsx-one-expression-per-lineLimit to one expression per line in JSX
:wrench:react/jsx-curly-brace-presenceEnforce curly braces or disallow unnecessary curly braces in JSX
:wrench:coffee/jsx-fragmentsEnforce shorthand or standard form for React fragments
react/jsx-pascal-caseEnforce PascalCase for user-defined JSX components
:wrench:react/jsx-props-no-multi-spacesDisallow multiple spaces between inline JSX props
react/jsx-props-no-spreadingDisallow JSX props spreading
coffee/jsx-sort-default-propsEnforce default props alphabetical sorting
:wrench:react/jsx-sort-propsEnforce props alphabetical sorting
:wrench:coffee/jsx-tag-spacingValidate whitespace in and around the JSX opening and closing brackets
:heavy_check_mark:react/jsx-uses-reactPrevent React to be incorrectly marked as unused
:heavy_check_mark:react/jsx-uses-varsPrevent variables used in JSX to be incorrectly marked as unused
coffee/jsx-wrap-multilinesPrevent missing parentheses around multilines JSX :warning: Unlike the eslint-plugin-react rule, the CoffeeScript version is not fixable

eslint-plugin-import rules

Static analysis

NameDescription
import/no-unresolvedEnsure imports point to a file/module that can be resolved
import/namedEnsure named imports correspond to a named export in the remote file
import/defaultEnsure a default export is present, given a default import
coffee/namespaceEnsure imported namespaces contain dereferenced properties as they are dereferenced
import/no-restricted-pathsRestrict which files can be imported in a given folder
import/no-absolute-pathForbid import of modules using absolute paths
import/no-dynamic-requireForbid require() calls with expressions

| import/no-internal-modules(h