ESLint equivalents in Elm

Elmcraft

10 min read Original article ↗

enforce getter and setter pairs in objects and classes

There are no getters or setters in Elm.

require braces around arrow function bodies

All Elm expressions are expressions, and there are no individual statements.

enforce the use of variables within the scope they are defined

Can't use variables not in scope.

enforce camelcase naming convention

There are corresponding elm-review rules for this:

enforce or disallow capitalization of the first letter of a comment

There is as of yet no equivalent to this rule in the Elm community.

enforce that class methods utilize `this`

There are no concept of this in Elm.

enforce a maximum cyclomatic complexity allowed in a program

require `return` statements to either always or never specify values

All Elm expressions are expressions, and there are no individual statements.

enforce consistent naming when capturing the current execution context

There are no concept of this in Elm.

enforce consistent brace style for all control statements

All Elm expressions are expressions, and there are no individual statements.

require `default` cases in `switch` statements

This would be handled using Elm's pattern matching syntax, which makes sure that all cases are handled.

enforce default clauses in switch statements to be last

This would be handled using Elm's pattern matching syntax, which makes sure that all cases are handled.

enforce default parameters to be last

Each Elm function has a fixed number of parameters and takes a fixed number of arguments when called.

enforce dot notation whenever possible

There are no dynamic or computed properties in Elm.

require the use of `===` and `!==`

There is only one operator to check for equality.

require function names to match the name of the variable or property to which they are assigned

Elm forbids name shadowing.

require or disallow named `function` expressions

Anonymous functions can't have names.

enforce the consistent use of either `function` declarations or expressions

There is only one way of defining functions.

require grouped accessor pairs in object literals and classes

There are no getters or setters in Elm.

require `for-in` loops to include an `if` statement

There are no loops in Elm.

disallow specified identifiers

There is as of yet no equivalent to this rule in the Elm community.

enforce minimum and maximum identifier lengths

There is as of yet no equivalent to this rule in the Elm community.

require identifiers to match a specified regular expression

There are corresponding elm-review rules for this:

require or disallow initialization in variable declarations

All values need to be initialized when they are declared.

enforce a maximum number of classes per file

There are no classes in Elm.

enforce a maximum depth that blocks can be nested

enforce a maximum number of lines per file

There is as of yet no equivalent to this rule in the Elm community.

enforce a maximum number of lines of code in a function

There is as of yet no equivalent to this rule in the Elm community.

enforce a maximum depth that callbacks can be nested

There is as of yet no equivalent to this rule in the Elm community.

enforce a maximum number of parameters in function definitions

There is as of yet no equivalent to this rule in the Elm community.

enforce a maximum number of statements allowed in function blocks

All Elm expressions are expressions, and there are no individual statements.

enforce a particular style for multiline comments

There is as of yet no equivalent to this rule in the Elm community.

require constructor names to begin with a capital letter

There are no classes in Elm.

disallow the use of `alert`, `confirm`, and `prompt`

These functions don't exist in Elm.

disallow `Array` constructors

There are no classes in Elm.

disallow bitwise operators

The underlying problem would result in a type error.

disallow the use of `arguments.caller` or `arguments.callee`

These functions don't exist in Elm.

disallow lexical declarations in case clauses

This would be handled using Elm's pattern matching syntax, which makes sure that all cases are handled.

disallow arrow functions where they could be confused with comparisons

This would be a type error.

disallow the use of `console`

These functions don't exist in Elm.

disallow `continue` statements

There are no labels in Elm.

disallow deleting variables

There is no delete keyword.

disallow division operators explicitly at the beginning of regular expressions

There is no special support for regular expressions in Elm.

disallow `else` blocks after `return` statements in `if` statements

All Elm expressions are expressions, and there are no individual statements.

disallow empty block statements

All Elm expressions are expressions, and there are no individual statements.

All Elm expressions are expressions, and there are no individual statements.

disallow `null` comparisons without type-checking operators

There is no null or undefined in Elm.

disallow the use of `eval()`

There is no eval function in Elm.

disallow extending native types

Elm doesn't allow you to extend existing types.

disallow unnecessary calls to `.bind()`

There are no concept of this in Elm.

disallow unnecessary boolean casts

There are corresponding elm-review rules for this:

disallow unnecessary labels

There are no labels in Elm.

disallow unnecessary semicolons

All Elm expressions are expressions, and there are no individual statements.

disallow leading or trailing decimal points in numeric literals

Floating numbers need to have numbers before the dot.

disallow assignments to native objects or read-only global variables

Elm doesn't support mutating values.

disallow shorthand type conversions

There is no syntax for coercion. Elm requires explicit type conversions.

disallow declarations in the global scope

Can't use variables not in scope.

disallow the use of `eval()`-like methods

There is no eval function in Elm.

disallow inline comments after code

🪄 This is automatically handled by elm-format.

disallow `this` keywords outside of classes or class-like objects

There are no concept of this in Elm.

disallow the use of the `__iterator__` property

There are no loops in Elm.

disallow labels that share a name with a variable

There are no labels in Elm.

disallow labeled statements

There are no labels in Elm.

disallow unnecessary nested blocks

All Elm expressions are expressions, and there are no individual statements.

disallow `if` statements as the only statement in `else` blocks

Can't have a lonely if that doesn't have an else

disallow function declarations that contain unsafe references inside loop statements

There are no loops in Elm.

There is as of yet no equivalent to this rule in the Elm community.

disallow mixed binary operators

disallow use of chained assignment expressions

Can't declare multiple variables at once.

disallow multiline strings

This is not a valid way of writing strings in Elm.

disallow negated conditions

There is as of yet no equivalent to this rule in the Elm community.

disallow nested ternary expressions

There are no ternary operators, only if expressions which are more readable when nested.

disallow `new` operators outside of assignments or comparisons

There are no classes in Elm.

disallow `new` operators with the `Function` object

There are no classes in Elm.

disallow `Object` constructors

There are no classes in Elm.

disallow `new` operators with the `String`, `Number`, and `Boolean` objects

There are no classes in Elm.

disallow `\8` and `\9` escape sequences in string literals

There is no syntax for literal octal or binary in Elm.

There is no syntax for literal octal or binary in Elm.

disallow octal escape sequences in string literals

There is no syntax for literal octal or binary in Elm.

disallow reassigning `function` parameters

Elm forbids name shadowing.

disallow the unary operators `++` and `--`

Elm doesn't support mutating values.

disallow the use of the `__proto__` property

There are no prototypes in Elm.

disallow variable redeclaration

Elm forbids name shadowing.

disallow multiple spaces in regular expressions

There is no special support for regular expressions in Elm.

disallow specified names in exports

There is as of yet no equivalent to this rule in the Elm community.

disallow specified global variables

There is as of yet no equivalent to this rule in the Elm community.

disallow specified modules when loaded by `import`

disallow certain properties on certain objects

There is as of yet no equivalent to this rule in the Elm community.

disallow specified syntax

There is as of yet no equivalent to this rule in the Elm community.

disallow assignment operators in `return` statements

All Elm expressions are expressions, and there are no individual statements.

disallow unnecessary `return await`

There is no async/await syntax in Elm.

disallow `javascript:` urls

The virtual-dom implementation prevents the execution of arbitrary JavaScript code.

There is no such comma operator in Elm.

disallow variable declarations from shadowing variables declared in the outer scope

Elm forbids name shadowing.

disallow identifiers from shadowing restricted names

Elm forbids name shadowing.

disallow ternary operators

There are no ternary operators, only if expressions.

disallow throwing literals as exceptions

There are no exceptions in Elm.

disallow initializing variables to `undefined`

There is no null or undefined in Elm.

disallow the use of `undefined` as an identifier

There is no null or undefined in Elm.

disallow dangling underscores in identifiers

There is as of yet no equivalent to this rule in the Elm community.

disallow ternary operators when simpler alternatives exist

There are no ternary operators, only if expressions.

disallow unused expressions

All Elm expressions are expressions, and there are no individual statements.

There are no labels in Elm.

disallow unnecessary calls to `.call()` and `.apply()`

These functions don't exist in Elm.

disallow unnecessary `catch` clauses

There are no exceptions in Elm.

disallow unnecessary computed property keys in objects and classes

There are no dynamic or computed properties in Elm.

disallow unnecessary concatenation of literals or template literals

There are corresponding elm-review rules for this:

disallow unnecessary constructors

There are no classes in Elm.

disallow unnecessary escape characters

🪄 This is automatically handled by elm-format.

disallow renaming import, export, and destructured assignments to the same name

disallow redundant return statements

All Elm expressions are expressions, and there are no individual statements.

require `let` or `const` instead of `var`

Variables are not defined using a keyword.

disallow `void` operators

There is no void operator.

disallow specified warning terms in comments

disallow `with` statements

There is no with command.

require or disallow method and property shorthand syntax for object literals

Shorthands are not available

enforce variables to be declared either together or separately in functions

Every variable is declared separately.

require or disallow newlines around variable declarations

🪄 This is automatically handled by elm-format.

require or disallow assignment operator shorthand where possible

Elm doesn't support mutating values.

require using arrow functions for callbacks

There is only one way to define function expressions.

require `const` declarations for variables that are never reassigned after declared

Variables are not defined using a keyword.

require destructuring from arrays and/or objects

There is as of yet no equivalent to this rule in the Elm community.

disallow the use of `Math.pow` in favor of the `**` operator

There is only the (^) operator in the core language.

enforce using named capture group in regular expression

There is no special support for regular expressions in Elm.

disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals

There is no syntax for literal octal or binary in Elm.

disallow use of `Object.prototype.hasOwnProperty.call()` and prefer use of `Object.hasOwn()`

Available properties are always known, no need for these functions.

disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead.

Elm doesn't support mutating values.

require using Error objects as Promise rejection reasons

There are no exceptions in Elm.

disallow use of the `RegExp` constructor in favor of regular expression literals

There is only one function to create a regular expression.

require rest parameters instead of `arguments`

Each Elm function has a fixed number of parameters and takes a fixed number of arguments when called.

require spread operators instead of `.apply()`

Each Elm function has a fixed number of parameters and takes a fixed number of arguments when called.

require template literals instead of string concatenation

There are no template literals in Elm.

require quotes around object literal property names

Property names can't be surrounded with quotes.

enforce the consistent use of the radix argument when using `parseInt()`

Each Elm function has a fixed number of parameters and takes a fixed number of arguments when called.

disallow async functions which have no `await` expression

There is no async/await syntax in Elm.

enforce the use of `u` flag on RegExp

There is no special support for regular expressions in Elm.

require generator functions to contain `yield`

There are no generators in Elm.

enforce sorted import declarations within modules

🪄 This is automatically handled by elm-format.

require object keys to be sorted

require variables within the same declaration block to be sorted

enforce consistent spacing after the `//` or `/*` in a comment

There is as of yet no equivalent to this rule in the Elm community.

require or disallow strict mode directives

There is no strict mode in Elm.

require symbol descriptions

There are no symbols in Elm.

require `var` declarations be placed at the top of their containing scope

This is somewhat enforced by the design of let declarations.

require or disallow " Yoda " conditions

Elm doesn't support mutating values.