ESLint custom parser + rules for linting CoffeeScript source files
- Getting Started
- Why does this project exist?
- How does eslint-plugin-coffee work?
- Can I use all of the existing ESLint plugins and rules without any changes?
- Installation
- Usage
- Usage with Prettier
- Supported Rules
- Supported CoffeeScript version
- Supported ESLint version
- Supported versions of eslint-plugin-react, eslint-plugin-import, eslint-plugin-react-native
- Migrating from CoffeeLint
- How can I help?
- License
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.
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 β¨ π β¨
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...
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
,
and eslint-plugin-react-native
.
Here's a guide to all of the supported rules.
Make sure you have supported versions of CoffeeScript and ESLint installed and install the plugin:
yarn:
# yarn seems to occasionally get confused by Github dependencies, so I'd recommend clearing your lockfile first
rm yarn.lock
# then explicitly install the dependencies and plugin
yarn add --dev github:jashkenas/coffeescript#05d45e9b eslint@^6.0.0 eslint-plugin-coffee
npm:
# npm also seems to occasionally get confused by Github dependencies, so I'd recommend clearing your lockfile first
rm package-lock.json
# then explicitly install the dependencies
npm install --save-dev github:jashkenas/coffeescript#05d45e9b eslint@^6.0.0 eslint-plugin-coffee
Add eslint-plugin-coffee
to the parser
field and coffee
to the plugins section of your .eslintrc
configuration file:
{
"parser": "eslint-plugin-coffee",
"plugins": ["coffee"]
}
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"
]
}
If you want to use rules from eslint-plugin-react
, eslint-plugin-import
and/or eslint-plugin-react-native
(whether rules that "just work" or CoffeeScript custom overrides), install supported versions of those dependencies:
npm install --save-dev eslint-plugin-react
npm install --save-dev eslint-plugin-import
npm install --save-dev eslint-plugin-react-native
And correspondingly add those plugins and rules to your config:
{
"plugins": [
"coffee",
"react",
"import",
"react-native"
],
"rules": {
// Can include existing rules that "just work":
"react/no-array-index-key": "error",
"import/prefer-default-export": "error",
"react-native/no-inline-styles": "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",
"import/no-anonymous-default-export": "off",
"coffee/no-anonymous-default-export": "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 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 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.
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
},
]
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!
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"]
}
Key: βοΈ = ESLint recommended, π§ = fixable
Name | Description | ||
---|---|---|---|
βοΈ | coffee/no-async-promise-executor |
disallow using an async function as a Promise executor | |
coffee/no-await-in-loop |
disallow await inside of loops |
||
βοΈ | coffee/no-compare-neg-zero |
disallow comparing against -0 | |
βοΈ | coffee/no-cond-assign |
disallow assignment operators in conditional expressions | |
no-console |
disallow the use of console |
||
βοΈ | coffee/no-constant-condition |
disallow constant expressions in conditions | |
βοΈ | no-control-regex |
disallow control characters in regular expressions | |
βοΈ | no-debugger |
disallow the use of debugger |
|
βοΈ | no-dupe-keys |
disallow duplicate keys in object literals | |
βοΈ | no-duplicate-case |
disallow duplicate case labels | |
βοΈ | no-empty |
disallow empty block statements | |
βοΈ | coffee/no-empty-character-class |
disallow empty character classes in regular expressions | |
βοΈ | no-ex-assign |
disallow reassigning exceptions in catch clauses |
|
βοΈ | coffee/no-extra-boolean-cast |
disallow unnecessary boolean casts |
|
βοΈ | coffee/no-inner-declarations |
disallow variable or function "declarations" in nested blocks |
|
βοΈ | no-invalid-regexp |
disallow invalid regular expression strings in RegExp constructors |
|
βοΈ | no-irregular-whitespace |
disallow irregular whitespace | |
βοΈ | no-misleading-character-class |
disallow characters which are made with multiple code points in character class syntax | |
βοΈ | no-obj-calls |
disallow calling global object properties as functions | |
βοΈ | no-prototype-builtins |
disallow calling some Object.prototype methods directly on objects |
|
βοΈ | π§ | coffee/no-regex-spaces |
disallow multiple spaces in regular expressions |
βοΈ | no-sparse-arrays |
disallow sparse arrays | |
coffee/no-template-curly-in-string |
disallow template literal placeholder syntax in regular strings | ||
βοΈ | coffee/no-unreachable |
disallow unreachable code after return , throw , continue , and break statements |
|
βοΈ | no-unsafe-finally |
disallow control flow statements in finally blocks |
|
βοΈ | coffee/no-unsafe-negation |
disallow negating the left operand of relational operators | |
βοΈ | require-atomic-updates |
disallow assignments that can lead to race conditions due to usage of await or yield |
|
βοΈ | coffee/use-isnan |
require calls to isNaN() when checking for NaN |
|
βοΈ | coffee/valid-typeof |
enforce comparing typeof expressions against valid strings |
Name | Description | ||
---|---|---|---|
accessor-pairs |
enforce getter and setter pairs in objects and classes Object.defineProperty() since CoffeeScript doesn't support getters/setters |
||
coffee/block-scoped-var |
enforce the use of variables within the scope they are defined | ||
coffee/class-methods-use-this |
enforce that class methods utilize this |
||
coffee/complexity |
enforce a maximum cyclomatic complexity allowed in a program | ||
default-case |
require else cases in switch statements |
||
π§ | coffee/dot-location |
enforce consistent newlines before and after dots | |
π§ | coffee/dot-notation |
enforce dot notation whenever possible | |
coffee/guard-for-in |
require for-of loops to include own or an if statement |
||
max-classes-per-file |
enforce a maximum number of classes per file | ||
no-alert |
disallow the use of alert , confirm , and prompt |
||
no-caller |
disallow the use of arguments.caller or arguments.callee |
||
π§ | coffee/no-div-regex |
disallow division operators explicitly at the beginning of regular expressions | |
coffee/no-else-return |
disallow else blocks after return statements in if statements |
||
coffee/no-empty-function |
disallow empty functions | ||
βοΈ | no-empty-pattern |
disallow empty destructuring patterns | |
no-eval |
disallow the use of eval() |
||
no-extend-native |
disallow extending native types | ||
π§ | coffee/no-extra-bind |
disallow unnecessary calls to .bind() |
|
π§ | no-floating-decimal |
disallow leading or trailing decimal points in numeric literals | |
βοΈ | no-global-assign |
disallow assignments to native objects or read-only global variables ++ operations since CoffeeScript generates declarations on other write references. |
|
π§ | coffee/no-implicit-coercion |
disallow shorthand type conversions | |
no-implied-eval |
disallow the use of eval() -like methods |
||
coffee/no-invalid-this |
disallow this keywords outside of classes or class-like objects |
||
no-iterator |
disallow the use of the __iterator__ property |
||
coffee/no-loop-func |
disallow function declarations that contain unsafe references inside loop statements | ||
coffee/no-magic-numbers |
disallow magic numbers | ||
π§ | coffee/no-multi-spaces |
disallow multiple spaces | |
coffee/no-new |
disallow new operators outside of assignments or comparisons |
||
no-new-func |
disallow new operators with the Function object |
||
no-new-wrappers |
disallow new operators with the String , Number , and Boolean objects |
||
no-param-reassign |
disallow reassigning function parameters |
||
no-proto |
disallow the use of the __proto__ property |
||
no-restricted-properties |
disallow certain properties on certain objects | ||
coffee/no-return-assign |
disallow assignment operators in return statements |
||
no-script-url |
disallow javascript: urls |
||
βοΈ | coffee/no-self-assign |
disallow assignments where both sides are exactly the same | |
coffee/no-self-compare |
disallow comparisons where both sides are exactly the same | ||
coffee/no-sequences |
disallow semicolon operators | ||
no-throw-literal |
disallow throwing literals as exceptions | ||
coffee/no-unmodified-loop-condition |
disallow unmodified loop conditions | ||
coffee/no-unused-expressions |
disallow unused expressions | ||
no-useless-call |
disallow unnecessary calls to .call() and .apply() |
||
no-useless-concat |
disallow unnecessary concatenation of literals or template literals | ||
βοΈ | coffee/no-useless-escape |
disallow unnecessary escape characters | |
π§ | coffee/no-useless-return |
disallow redundant return statements | |
no-warning-comments |
disallow specified warning terms in comments | ||
prefer-promise-reject-errors |
require using Error objects as Promise rejection reasons | ||
radix |
enforce the consistent use of the radix argument when using parseInt() |
||
require-unicode-regexp |
enforce the use of u flag on RegExp |
||
coffee/vars-on-top |
require "declarations" be placed at the top of their containing scope | ||
coffee/yoda |
require or disallow "Yoda" conditions |
||
βοΈ | no-delete-var |
disallow deleting variables | |
no-restricted-globals |
disallow specified global variables | ||
coffee/no-shadow |
disallow variable declarations from shadowing variables declared in the outer scope | ||
βοΈ | no-undef |
disallow the use of undeclared variables unless mentioned in ###global ### comments |
|
βοΈ | coffee/no-unused-vars |
disallow unused variables | |
coffee/no-use-before-define |
disallow the use of variables before they are "defined" |
Name | Description | ||
---|---|---|---|
coffee/callback-return |
require return statements after callbacks |
||
global-require |
require require() calls to be placed at top-level module scope |
||
handle-callback-err |
require error handling in callbacks | ||
no-buffer-constructor |
disallow use of the Buffer() constructor |
||
no-new-require |
disallow new operators with calls to require |
||
no-path-concat |
disallow string concatenation with __dirname and __filename |
||
no-process-env |
disallow the use of process.env |
||
no-process-exit |
disallow the use of process.exit() |
||
no-restricted-modules |
disallow specified modules when loaded by require |
||
no-sync |
disallow synchronous methods |
Name | Description | ||
---|---|---|---|
coffee/array-bracket-newline |
enforce linebreaks after opening and before closing array brackets |
||
π§ | coffee/array-bracket-spacing |
enforce consistent spacing inside array brackets | |
coffee/array-element-newline |
enforce line breaks after each array element |
||
coffee/camelcase |
enforce camelcase naming convention | ||
π§ | coffee/capitalized-comments |
enforce or disallow capitalization of the first letter of a comment | |
π§ | comma-spacing |
enforce consistent spacing before and after commas | |
coffee/comma-style |
enforce consistent comma style |
||
π§ | computed-property-spacing |
enforce consistent spacing inside computed property brackets | |
coffee/consistent-this |
enforce consistent naming when capturing the current execution context | ||
π§ | eol-last |
require or disallow newline at the end of files | |
coffee/function-paren-newline |
enforce consistent line breaks inside function parentheses |
||
id-blacklist |
disallow specified identifiers | ||
coffee/id-length |
enforce minimum and maximum identifier lengths | ||
coffee/id-match |
require identifiers to match a specified regular expression | ||
coffee/implicit-arrow-linebreak |
enforce the location of function bodies |
||
π§ | jsx-quotes |
enforce the consistent use of either double or single quotes in JSX attributes | |
π§ | key-spacing |
enforce consistent spacing between keys and values in object literal properties | |
π§ | coffee/keyword-spacing |
enforce consistent spacing before and after keywords | |
line-comment-position |
enforce position of line comments | ||
π§ | linebreak-style |
enforce consistent linebreak style | |
π§ | coffee/lines-around-comment |
require empty lines around comments | |
coffee/lines-between-class-members |
require or disallow an empty line between class members |
||
coffee/max-depth |
enforce a maximum depth that blocks can be nested | ||
coffee/max-len |
enforce a maximum line length | ||
max-lines |
enforce a maximum number of lines per file | ||
coffee/max-lines-per-function |
enforce a maximum number of line of code in a function | ||
max-nested-callbacks |
enforce a maximum depth that callbacks can be nested | ||
max-params |
enforce a maximum number of parameters in function definitions | ||
max-statements |
enforce a maximum number of statements allowed in function blocks | ||
π§ | coffee/multiline-comment-style |
enforce a particular style for multiline comments | |
new-cap |
require constructor names to begin with a capital letter | ||
π§ | new-parens |
enforce or disallow parentheses when invoking a constructor with no arguments | |
coffee/newline-per-chained-call |
require a newline after each call in a method chain |
||
no-array-constructor |
disallow Array constructors |
||
no-bitwise |
disallow bitwise operators | ||
no-continue |
disallow continue statements |
||
no-inline-comments |
disallow inline comments after code | ||
coffee/no-lonely-if |
disallow if statements as the only statement in else blocks |
||
coffee/no-mixed-operators |
disallow mixed binary operators | ||
no-multi-assign |
disallow use of chained assignment expressions | ||
π§ | coffee/no-multiple-empty-lines |
disallow multiple empty lines | |
coffee/no-negated-condition |
disallow negated conditions | ||
no-new-object |
disallow Object constructors |
||
no-plusplus |
disallow the unary operators ++ and -- |
||
no-restricted-syntax |
disallow specified syntax | ||
no-tabs |
disallow all tabs | ||
π§ | no-trailing-spaces |
disallow trailing whitespace at the end of lines | |
coffee/no-underscore-dangle |
disallow dangling underscores in identifiers | ||
π§ | coffee/no-unneeded-ternary |
disallow if /else expressions when simpler alternatives exist |
|
π§ | coffee/no-whitespace-before-property |
disallow whitespace before properties | |
π§ | coffee/object-curly-spacing |
enforce consistent spacing inside braces | |
coffee/object-property-newline |
enforce placing object properties on separate lines |
||
π§ | coffee/operator-assignment |
require or disallow assignment operator shorthand where possible | |
coffee/operator-linebreak |
enforce consistent linebreak style for operators |
||
coffee/prefer-object-spread |
disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead |
||
π§ | quote-props |
require quotes around object literal property names | |
sort-keys |
require object keys to be sorted | ||
π§ | space-in-parens |
enforce consistent spacing inside parentheses | |
π§ | coffee/space-infix-ops |
require spacing around infix operators | |
π§ | coffee/space-unary-ops |
enforce consistent spacing before or after unary operators | |
π§ | coffee/spaced-comment |
enforce consistent spacing after the # or ### in a comment |
|
π§ | unicode-bom |
require or disallow Unicode byte order mark (BOM) | |
π§ | coffee/wrap-regex |
require parenthesis around regex literals |
Name | Description | ||
---|---|---|---|
π§ | coffee/arrow-spacing |
enforce consistent spacing before and after the arrow in functions | |
βοΈ | constructor-super |
require super() calls in constructors |
|
βοΈ | coffee/no-class-assign |
disallow reassigning class members | |
βοΈ | no-dupe-class-members |
disallow duplicate class members | |
no-duplicate-imports |
disallow duplicate module imports | ||
βοΈ | no-new-symbol |
disallow new operators with the Symbol object |
|
no-restricted-imports |
disallow specified modules when loaded by import |
||
βοΈ | coffee/no-this-before-super |
disallow this /super before calling super() in constructors |
|
π§ | coffee/no-useless-computed-key |
disallow unnecessary computed property keys in objects and classes | |
coffee/no-useless-constructor |
disallow unnecessary constructors | ||
π§ | no-useless-rename |
disallow renaming import, export, and destructured assignments to the same name | |
coffee/object-shorthand |
require or disallow method and property shorthand syntax for object literals |
||
coffee/prefer-destructuring |
require destructuring from arrays and/or objects |
||
π§ | prefer-numeric-literals |
disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals |
|
prefer-rest-params |
require rest parameters instead of arguments |
||
prefer-spread |
require spread operators instead of .apply() |
||
π§ | coffee/prefer-template |
require interpolated strings instead of string concatenation | |
π§ | coffee/rest-spread-spacing |
enforce spacing between rest and spread operators and their expressions | |
π§ | sort-imports |
enforce sorted import declarations within modules | |
symbol-description |
require symbol descriptions | ||
π§ | coffee/template-curly-spacing |
require or disallow spacing around embedded expressions of template strings |
Name | Description | |
---|---|---|
coffee/capitalized-class-names |
Enforce capitalization of the first letter of a class name | |
coffee/no-backticks |
Disallow use of the backtick operator | |
coffee/english-operators |
Enforce or disallow use of "English" operators | |
coffee/implicit-object |
Disallow implicit objects | |
coffee/implicit-call |
Disallow implicit function calls | |
coffee/empty-func-parens |
Enforce or disallow the use of parentheses for empty parameter lists | |
coffee/shorthand-this |
Enforce or disallow use of @ vs this |
|
coffee/spread-direction |
Enforce consistent use of prefix vs postfix ... |
|
π§ | coffee/postfix-comprehension-assign-parens |
Require parentheses around potentially confusing assignments in postfix comprehensions |
coffee/no-nested-interpolation |
Disallow nesting interpolations | |
coffee/no-private-function-fat-arrows |
Disallow use of => for "private" functions in class bodies |
|
coffee/no-unnecessary-double-quotes |
Disallow use of double quotes for strings when single quotes would suffice |
Key: βοΈ = recommended, π§ = fixable
Name | Description | ||
---|---|---|---|
coffee/boolean-prop-naming |
Enforces consistent naming for boolean props | ||
react/button-has-type |
Forbid "button" element without an explicit "type" attribute | ||
coffee/default-props-match-prop-types |
Prevent extraneous defaultProps on components | ||
coffee/destructuring-assignment |
Rule enforces consistent usage of destructuring assignment in component | ||
βοΈ | coffee/display-name |
Prevent missing displayName in a React component definition |
|
react/forbid-component-props |
Forbid certain props on Components | ||
react/forbid-dom-props |
Forbid certain props on DOM Nodes | ||
react/forbid-elements |
Forbid certain elements | ||
coffee/forbid-prop-types |
Forbid certain propTypes | ||
react/forbid-foreign-prop-types |
Forbid foreign propTypes | ||
coffee/no-access-state-in-setstate |
Prevent using this.state inside this.setState | ||
react/no-array-index-key |
Prevent using Array index in key props |
||
βοΈ | react/no-children-prop |
Prevent passing children as props | |
react/no-danger |
Prevent usage of dangerous JSX properties | ||
βοΈ | coffee/no-danger-with-children |
Prevent problem with children and props.dangerouslySetInnerHTML | |
βοΈ | coffee/no-deprecated |
Prevent usage of deprecated methods, including component lifecycle methods | |
react/no-did-mount-set-state |
Prevent usage of setState in componentDidMount |
||
react/no-did-update-set-state |
Prevent usage of setState in componentDidUpdate |
||
βοΈ | react/no-direct-mutation-state |
Prevent direct mutation of this.state |
|
βοΈ | react/no-find-dom-node |
Prevent usage of findDOMNode |
|
βοΈ | react/no-is-mounted |
Prevent usage of isMounted |
|
coffee/no-multi-comp |
Prevent multiple component definition per file | ||
coffee/no-redundant-should-component-update |
Prevent usage of shouldComponentUpdate when extending React.PureComponent |
||
βοΈ | coffee/no-render-return-value |
Prevent usage of the return value of React.render |
|
react/no-set-state |
Prevent usage of setState |
||
coffee/no-typos |
Prevent common casing typos | ||
βοΈ | react/no-string-refs |
Prevent using string references in ref attribute. |
|
coffee/no-this-in-sfc |
Prevent using this in stateless functional components |
||
βοΈ | coffee/no-unescaped-entities |
Prevent invalid characters from appearing in markup | |
βοΈ | π§ | react/no-unknown-property |
Prevent usage of unknown DOM property |
react/no-unsafe |
Prevent usage of unsafe lifecycle methods | ||
coffee/no-unused-prop-types |
Prevent definitions of unused prop types | ||
coffee/no-unused-state |
Prevent definitions of unused state properties | ||
react/no-will-update-set-state |
Prevent usage of setState in componentWillUpdate |
||
react/prefer-es6-class |
Enforce ES5 or ES6 class for React Components | ||
coffee/prefer-stateless-function |
Enforce stateless React Components to be written as a pure function | ||
βοΈ | coffee/prop-types |
Prevent missing props validation in a React component definition | |
βοΈ | react/react-in-jsx-scope |
Prevent missing React when using JSX |
|
coffee/require-default-props |
Enforce a defaultProps definition for every prop that is not a required prop | ||
react/require-optimization |
Enforce React components to have a shouldComponentUpdate method |
||
π§ | react/self-closing-comp |
Prevent extra closing tags for components without children | |
coffee/sort-comp |
Enforce component methods order |
||
coffee/sort-prop-types |
Enforce propTypes declarations alphabetical sorting | ||
coffee/style-prop-object |
Enforce style prop value being an object | ||
react/void-dom-elements-no-children |
Prevent void DOM elements (e.g. <img /> , <br /> ) from receiving children |
Name | Description | ||
---|---|---|---|
coffee/jsx-boolean-value |
Enforce boolean attributes notation in JSX |
||
react/jsx-child-element-spacing |
Enforce or disallow spaces inside of curly braces in JSX attributes and expressions. | ||
π§ | coffee/jsx-closing-bracket-location |
Validate closing bracket location in JSX | |
π§ | react/jsx-closing-tag-location |
Validate closing tag location in JSX | |
π§ | react/jsx-curly-spacing |
Enforce or disallow spaces inside of curly braces in JSX attributes and expressions | |
π§ | react/jsx-equals-spacing |
Enforce or disallow spaces around equal signs in JSX attributes | |
react/jsx-filename-extension |
Restrict file extensions that may contain JSX | ||
coffee/jsx-first-prop-new-line |
Enforce position of the first prop in JSX |
||
coffee/jsx-handler-names |
Enforce event handler naming conventions in JSX | ||
π§ | coffee/jsx-indent |
Validate JSX indentation | |
π§ | react/jsx-indent-props |
Validate props indentation in JSX | |
βοΈ | coffee/jsx-key |
Validate JSX has key prop when in array or iterator | |
react/jsx-max-depth |
Validate JSX maximum depth | ||
coffee/jsx-max-props-per-line |
Limit maximum of props on a single line in JSX |
||
coffee/jsx-no-bind |
Prevent usage of .bind() and arrow functions in JSX props |
||
βοΈ | coffee/jsx-no-comment-textnodes |
Prevent comments from being inserted as text nodes | |
βοΈ | react/jsx-no-duplicate-props |
Prevent duplicate props in JSX | |
react/jsx-no-literals |
Prevent usage of unwrapped JSX strings | ||
βοΈ | react/jsx-no-target-blank |
Prevent usage of unsafe target='_blank' |
|
βοΈ | react/jsx-no-undef |
Disallow undeclared variables in JSX | |
coffee/jsx-one-expression-per-line |
Limit to one expression per line in JSX | ||
π§ | react/jsx-curly-brace-presence |
Enforce curly braces or disallow unnecessary curly braces in JSX | |
react/jsx-pascal-case |
Enforce PascalCase for user-defined JSX components | ||
π§ | react/jsx-props-no-multi-spaces |
Disallow multiple spaces between inline JSX props | |
coffee/jsx-sort-default-props |
Enforce default props alphabetical sorting | ||
π§ | react/jsx-sort-props |
Enforce props alphabetical sorting | |
π§ | coffee/jsx-tag-spacing |
Validate whitespace in and around the JSX opening and closing brackets | |
βοΈ | react/jsx-uses-react |
Prevent React to be incorrectly marked as unused | |
βοΈ | react/jsx-uses-vars |
Prevent variables used in JSX to be incorrectly marked as unused | |
coffee/jsx-wrap-multilines |
Prevent missing parentheses around multilines JSX |
Name | Description |
---|---|
import/no-unresolved |
Ensure imports point to a file/module that can be resolved |
import/named |
Ensure named imports correspond to a named export in the remote file |
import/default |
Ensure a default export is present, given a default import |
coffee/namespace |
Ensure imported namespaces contain dereferenced properties as they are dereferenced |
import/no-restricted-paths |
Restrict which files can be imported in a given folder |
import/no-absolute-path |
Forbid import of modules using absolute paths |
import/no-dynamic-require |
Forbid require() calls with expressions |
import/no-internal-modules |
Prevent importing the submodules of other modules |
import/no-webpack-loader-syntax |
Forbid webpack loader syntax in imports |
import/no-self-import |
Forbid a module from importing itself |
import/no-cycle |
Forbid a module from importing a module with a dependency path back to itself |
import/no-useless-path-segments |
Prevent unnecessary path segments in import and require statements |
import/no-relative-parent-imports |
Forbid importing modules from parent directories |
coffee/no-unused-modules |
Forbid modules without any export, and exports not imported by any modules |
Name | Description |
---|---|
coffee/export |
Report any invalid exports, i.e. re-export of the same name |
Name | Description |
---|---|
coffee/no-commonjs |
Report CommonJS require calls and module.exports or exports.* . |
import/no-amd |
Report AMD require and define calls. |
import/no-nodejs-modules |
No Node.js builtin modules. |
Name | Description | |
---|---|---|
π§ | import/first |
Ensure all imports appear before other statements |
import/exports-last |
Ensure all exports appear after other statements | |
import/no-namespace |
Forbid namespace (a.k.a. "wildcard" * ) imports |
|
π§ | import/newline-after-import |
Enforce a newline after import statements |
import/prefer-default-export |
Prefer a default export if module exports a single name | |
import/max-dependencies |
Limit the maximum number of dependencies a module can have | |
coffee/no-default-export |
Forbid default exports | |
coffee/no-anonymous-default-export |
Forbid anonymous values as default exports | |
import/group-exports |
Prefer named exports to be grouped together in a single export declaration | |
coffee/dynamic-import-chunkname |
Enforce a leading comment with the webpackChunkName for dynamic imports |
Name | Description |
---|---|
coffee/no-unused-styles |
Detect StyleSheet rules which are not used in your React components |
coffee/split-platform-components |
Enforce using platform specific filenames when necessary |
react-native/no-inline-styles |
Detect JSX components with inline styles that contain literal values |
coffee/no-color-literals |
Detect StyleSheet rules and inline styles containing color literals instead of variables |
Some rules included with ESLint, eslint-plugin-react
and eslint-plugin-import
don't apply to CoffeeScript. These include:
for-direction
getter-return
no-dupe-args
no-extra-semi
no-func-assign
no-unexpected-multiline
array-callback-return
consistent-return
curly
eqeqeq
no-case-declarations
no-eq-null
no-extra-label
no-fallthrough
no-implicit-globals
no-labels
no-lone-blocks
no-octal
no-octal-escape
no-redeclare
no-unused-labels
no-void
no-with
require-await
wrap-iife
init-declarations
no-label-var
no-shadow-restricted-names
no-undef-init
no-undefined
no-mixed-requires
block-spacing
brace-style
func-call-spacing
func-name-matching
func-names
func-style
max-statements-per-line
no-mixed-spaces-and-tabs
no-nested-ternary
no-ternary
nonblock-statement-body-position
object-curly-newline
one-var
one-var-declaration-per-line
semi
semi-spacing
semi-style
sort-vars
space-before-blocks
space-before-function-paren
switch-colon-spacing
template-tag-spacing
arrow-body-style
arrow-parens
generator-star-spacing
no-confusing-arrow
no-const-assign
no-var
prefer-arrow-callback
prefer-const
require-yield
yield-star-spacing
no-multi-str
react/require-render-return
import/no-mutable-exports
We will always endeavor to support the latest stable version of CoffeeScript.
Currently to run this plugin you need to use the latest Coffeescript ast
branch: github:jashkenas/coffeescript#05d45e9b.
The version range of ESLint currently supported by this plugin is >=6.0.0
.
The version range of eslint-plugin-react
currently supported by this plugin is >=7.17.0
.
The version range of eslint-plugin-import
currently supported by this plugin is >=2.19.0
.
The version range of eslint-plugin-react-native
currently supported by this plugin is >=3.8.0
.
Here is a mapping from CoffeeLint rules to their corresponding ESLint rules:
CoffeeLint rule | ESLint rule |
---|---|
arrow_spacing |
coffee/arrow-spacing |
braces_spacing |
coffee/object-curly-spacing |
camel_case_classes |
coffee/camelcase + coffee/capitalized-class-names |
coffeescript_error |
If the CoffeeScript compiler fails to parse/produce AST for a source file, ESLint will report it as a parsing error. |
colon_assignment_spacing |
key-spacing |
cyclomatic_complexity |
coffee/complexity |
duplicate_key |
no-dupe-keys |
empty_constructor_needs_parens |
new-parens |
ensure_comprehensions |
coffee/postfix-comprehension-assign-parens (this behavior is also covered if you're using Prettier) |
eol_last |
eol-last |
indentation |
Not yet implemented. (this behavior is also covered if you're using Prettier) |
line_endings |
linebreak-style |
max_line_length |
coffee/max-len |
missing_fat_arrows |
coffee/no-invalid-this |
newlines_after_classes |
Not yet implemented. (this behavior is also partially covered if you're using Prettier) |
no_backticks |
coffee/no-backticks |
no_debugger |
no-debugger |
no_empty_functions |
coffee/no-empty-function |
no_empty_param_list |
coffee/empty-func-parens |
no_implicit_braces |
coffee/implicit-object |
no_implicit_parens |
coffee/implicit-call |
no_interpolation_in_single_quotes |
coffee/no-template-curly-in-string |
no_nested_string_interpolation |
coffee/no-nested-interpolation |
no_plusplus |
no-plusplus |
no_private_function_fat_arrows |
coffee/no-private-function-fat-arrows |
no_stand_alone_at |
coffee/shorthand-this |
no_tabs |
no-tabs |
no_this |
coffee/shorthand-this |
no_throwing_strings |
no-throw-literal |
no_trailing_semicolons |
Not yet implemented. (this behavior is also covered if you're using Prettier) |
no_trailing_whitespace |
no-trailing-spaces |
no_unnecessary_double_quotes |
coffee/no-unnecessary-double-quotes |
no_unnecessary_fat_arrows |
coffee/no-unnecessary-fat-arrow |
non_empty_constructor_needs_parens |
coffee/implicit-call |
prefer_english_operator |
coffee/english-operators |
space_operators |
coffee/space-infix-ops + coffee/space-unary-ops |
spacing_after_comma |
comma-spacing |
transform_messes_up_line_numbers |
Doesn't apply. |
If you haven't used ESLint before, you'll just need an .eslintrc
config file in your project root - the Installation and Usage sections above cover how to get started. For further information, you may want to look at the official ESLint guide.
See an issue? Report it!
If you have the time and inclination, you can even take it a step further and submit a PR to improve the project.
eslint-plugin-coffee
is licensed under the MIT License.