Rules Overview
CoffeeLint 2.1.0 ships with 37 built-in rules plus coffeescript_error, the check that reports syntax errors. This page lists them all with their default levels so you can quickly see what runs out of the box and what you can opt into. Each rule is described in detail, with examples and options, on its category page.
How to Read the Defaults
- error: active by default and fails the run.
- warn: active by default but does not affect the exit code.
- ignore: available but off until you enable it in your configuration.
Out of the box, 10 rules run at error level, 6 at warn, and the remaining 22 are opt-in. Run coffeelint --makeconfig to print the exact defaults of the version you have installed.
Whitespace and Formatting
Details: Whitespace and Formatting.
| Rule | Default | Options | Checks |
|---|---|---|---|
arrow_spacing |
ignore | Spaces around -> and => |
|
braces_spacing |
ignore | spaces, empty_object_spaces |
Spaces inside { } |
colon_assignment_spacing |
ignore | spacing.left, spacing.right |
Spaces around : in object and class properties |
eol_last |
ignore | File ends with exactly one newline | |
indentation |
error | value (2) |
Consistent indentation width |
line_endings |
ignore | value (unix) |
Unix or Windows line endings |
max_line_length |
error | value (80), limitComments |
Maximum line length |
newlines_after_classes |
ignore | value (3) |
Blank lines after a class body |
no_tabs |
error | Tabs in indentation | |
no_trailing_semicolons |
error | Semicolons at the end of lines | |
no_trailing_whitespace |
error | allowed_in_comments, allowed_in_empty_lines |
Whitespace at the end of lines |
space_operators |
ignore | Spaces around operators | |
spacing_after_comma |
ignore | Space after commas |
Style and Syntax
Details: Style and Syntax.
| Rule | Default | Options | Checks |
|---|---|---|---|
camel_case_classes |
error | Class names are UpperCamelCase | |
empty_constructor_needs_parens |
ignore | new Foo() instead of new Foo |
|
ensure_comprehensions |
warn | Parentheses around assigned comprehensions | |
no_backticks |
error | Embedded JavaScript | |
no_empty_param_list |
ignore | -> instead of () -> |
|
no_implicit_braces |
ignore | strict |
Object literals without braces |
no_implicit_parens |
ignore | strict |
Function calls without parentheses |
no_interpolation_in_single_quotes |
ignore | #{} inside single-quoted strings |
|
no_nested_string_interpolation |
warn | Interpolation inside interpolation | |
no_plusplus |
ignore | ++ and -- |
|
no_stand_alone_at |
ignore | A bare @ |
|
no_this |
ignore | this instead of @ |
|
no_unnecessary_double_quotes |
ignore | Double quotes without interpolation or single quotes | |
non_empty_constructor_needs_parens |
ignore | new Foo(a) instead of new Foo a |
|
prefer_english_operator |
ignore | doubleNotLevel |
and, or, is, isnt, not over symbols |
Functions and Classes
Details: Functions and Classes.
| Rule | Default | Options | Checks |
|---|---|---|---|
cyclomatic_complexity |
ignore | value (10) |
Function complexity |
missing_fat_arrows |
ignore | is_strict |
this used in a thin-arrow function |
no_empty_functions |
ignore | Empty function bodies | |
no_private_function_fat_arrows |
warn | Fat arrows on private class functions | |
no_unnecessary_fat_arrows |
warn | Fat arrows where this is not used |
Errors and Debugging
Details: Errors and Debugging.
| Rule | Default | Options | Checks |
|---|---|---|---|
coffeescript_error |
error | CoffeeScript syntax errors | |
duplicate_key |
error | Duplicate keys in objects and classes | |
no_debugger |
warn | console |
debugger statements (and optionally console calls) |
no_throwing_strings |
error | throw with a string literal |
|
transform_messes_up_line_numbers |
warn | Transforms that change the line count |
Choosing Rules for Your Project
A common progression:
- Start with the defaults. They catch real bugs (syntax errors, duplicate keys, thrown strings) and enforce the essentials of CoffeeScript formatting.
- Pick your formatting conventions and turn on the matching opt-in rules:
arrow_spacing,space_operators,spacing_after_comma,braces_spacing,colon_assignment_spacing,eol_last, andline_endingscover most of what code reviews argue about. - Add bug-catching rules that fit your code style:
missing_fat_arrows,no_empty_functions, andcyclomatic_complexity(start as a warning). - Decide on syntax preferences as a team: implicit parens and braces, English operators,
thisversus@, and quote style.
Rules can also be added from npm packages or your own code. See Writing Custom Rules.