non-arrow functions are forbidden Open
argLiteral.parse = function(): string {
- Read upRead up
- Exclude checks
Rule: only-arrow-functions
Disallows traditional (non-arrow) function expressions.
Note that non-arrow functions are allowed if 'this' appears somewhere in its body (as such functions cannot be converted to arrow functions).
Rationale
Traditional functions don't bind lexical scope, which can lead to unexpected behavior when accessing 'this'.
Config
Two arguments may be optionally provided:
-
"allow-declarations"
allows standalone function declarations. -
"allow-named-functions"
allows the expressionfunction foo() {}
but notfunction() {}
.
Examples
"only-arrow-functions": true
"only-arrow-functions": true,allow-declarations,allow-named-functions
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"allow-declarations",
"allow-named-functions"
]
},
"minLength": 0,
"maxLength": 1
}
For more information see this page.
Multiple variable declarations in the same statement are forbidden Open
const block = JSON.parse(`"${rawBlock}"`),
{
[this.tagName]: tag,
[this.argList]: argList = ''
} = block.match(this.blockSyntax),
- Read upRead up
- Exclude checks
Rule: one-variable-per-declaration
Disallows multiple variable definitions in the same declaration statement.
Config
One argument may be optionally provided:
-
ignore-for-loop
allows multiple variable definitions in a for loop declaration.
Examples
"one-variable-per-declaration": true
"one-variable-per-declaration": true,ignore-for-loop
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"ignore-for-loop"
]
},
"minLength": 0,
"maxLength": 1
}
For more information see this page.
non-arrow functions are forbidden Open
argLiteral.text = function(): string {
- Read upRead up
- Exclude checks
Rule: only-arrow-functions
Disallows traditional (non-arrow) function expressions.
Note that non-arrow functions are allowed if 'this' appears somewhere in its body (as such functions cannot be converted to arrow functions).
Rationale
Traditional functions don't bind lexical scope, which can lead to unexpected behavior when accessing 'this'.
Config
Two arguments may be optionally provided:
-
"allow-declarations"
allows standalone function declarations. -
"allow-named-functions"
allows the expressionfunction foo() {}
but notfunction() {}
.
Examples
"only-arrow-functions": true
"only-arrow-functions": true,allow-declarations,allow-named-functions
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"allow-declarations",
"allow-named-functions"
]
},
"minLength": 0,
"maxLength": 1
}
For more information see this page.
file should end with a newline Open
}
- Read upRead up
- Exclude checks
Rule: eofline
Ensures the file ends with a newline.
Fix for single-line files is not supported.
Rationale
It is a standard convention to end files with a newline.
Notes
- Has Fix
Config
Not configurable.
Examples
"eofline": true
For more information see this page.
non-arrow functions are forbidden Open
argLiteral.arg = function(key: number): string {
- Read upRead up
- Exclude checks
Rule: only-arrow-functions
Disallows traditional (non-arrow) function expressions.
Note that non-arrow functions are allowed if 'this' appears somewhere in its body (as such functions cannot be converted to arrow functions).
Rationale
Traditional functions don't bind lexical scope, which can lead to unexpected behavior when accessing 'this'.
Config
Two arguments may be optionally provided:
-
"allow-declarations"
allows standalone function declarations. -
"allow-named-functions"
allows the expressionfunction foo() {}
but notfunction() {}
.
Examples
"only-arrow-functions": true
"only-arrow-functions": true,allow-declarations,allow-named-functions
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"allow-declarations",
"allow-named-functions"
]
},
"minLength": 0,
"maxLength": 1
}
For more information see this page.
Forbidden constructor, use a literal or simple function call instead Open
const argLiteral: WaxLiteral = new String(list);
- Read upRead up
- Exclude checks
Rule: no-construct
Disallows access to the constructors of String
, Number
, and Boolean
.
Disallows constructor use such as new Number(foo)
but does not disallow Number(foo)
.
Rationale
There is little reason to use String
, Number
, or Boolean
as constructors.
In almost all cases, the regular function-call version is more appropriate.
More details are available on StackOverflow.
Config
Not configurable.
Examples
"no-construct": true
For more information see this page.
Multiple variable declarations in the same statement are forbidden Open
let text = this.text,
layout = '';
- Read upRead up
- Exclude checks
Rule: one-variable-per-declaration
Disallows multiple variable definitions in the same declaration statement.
Config
One argument may be optionally provided:
-
ignore-for-loop
allows multiple variable definitions in a for loop declaration.
Examples
"one-variable-per-declaration": true
"one-variable-per-declaration": true,ignore-for-loop
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"ignore-for-loop"
]
},
"minLength": 0,
"maxLength": 1
}
For more information see this page.
" should be ' Open
if(tag === "extends" && position === 0){
- Read upRead up
- Exclude checks
Rule: quotemark
Enforces quote character for string literals.
Notes
- Has Fix
Config
Five arguments may be optionally provided:
-
"single"
enforces single quotes. -
"double"
enforces double quotes. -
"backtick"
enforces backticks. -
"jsx-single"
enforces single quotes for JSX attributes. -
"jsx-double"
enforces double quotes for JSX attributes. -
"avoid-template"
forbids single-line untagged template strings that do not contain string interpolations. Note that backticks may still be used if"avoid-escape"
is enabled and both single and double quotes are present in the string (the latter option takes precedence). -
"avoid-escape"
allows you to use the "other" quotemark in cases where escaping would normally be required. For example,[true, "double", "avoid-escape"]
would not report a failure on the string literal'Hello "World"'
.
Examples
"quotemark": true,single,avoid-escape,avoid-template
"quotemark": true,single,jsx-double
Schema
{
"type": "array",
"items": {
"type": "string",
"enum": [
"single",
"double",
"backtick",
"jsx-single",
"jsx-double",
"avoid-escape",
"avoid-template"
]
},
"minLength": 0,
"maxLength": 5
}
For more information see this page.
comment must start with a space Open
//handle template extending specially
- Read upRead up
- Exclude checks
Rule: comment-format
Enforces formatting rules for single-line comments.
Rationale
Helps maintain a consistent, readable style in your codebase.
Notes
- Has Fix
Config
Four arguments may be optionally provided:
-
"check-space"
requires that all single-line comments must begin with a space, as in// comment
- note that for comments starting with multiple slashes, e.g.
///
, leading slashes are ignored - TypeScript reference comments are ignored completely
- note that for comments starting with multiple slashes, e.g.
-
"check-lowercase"
requires that the first non-whitespace character of a comment must be lowercase, if applicable. -
"check-uppercase"
requires that the first non-whitespace character of a comment must be uppercase, if applicable. -
"allow-trailing-lowercase"
allows that only the first comment of a series of comments needs to be uppercase.- requires
"check-uppercase"
- comments must start at the same position
- requires
Exceptions to "check-lowercase"
or "check-uppercase"
can be managed with object that may be passed as last
argument.
One of two options can be provided in this object:
-
"ignore-words"
- array of strings - words that will be ignored at the beginning of the comment. -
"ignore-pattern"
- string - RegExp pattern that will be ignored at the beginning of the comment.
Examples
"comment-format": true,check-space,check-uppercase,allow-trailing-lowercase
"comment-format": true,check-lowercase,[object Object]
"comment-format": true,check-lowercase,[object Object]
Schema
{
"type": "array",
"items": {
"anyOf": [
{
"type": "string",
"enum": [
"check-space",
"check-lowercase",
"check-uppercase",
"allow-trailing-lowercase"
]
},
{
"type": "object",
"properties": {
"ignore-words": {
"type": "array",
"items": {
"type": "string"
}
},
"ignore-pattern": {
"type": "string"
}
},
"minProperties": 1,
"maxProperties": 1
}
]
},
"minLength": 1,
"maxLength": 5
}
For more information see this page.