eslint-plugin-typescript-heck

Some extended eslint rules for typescript

Usage no npm install needed!

<script type="module">
  import eslintPluginTypescriptHeck from 'https://cdn.skypack.dev/eslint-plugin-typescript-heck';
</script>

README

eslint-plugin-typescript-heck

This package includes extended eslint rules for usage with Typescript.

Rules

Name Description
array-type-spacing Enforces correct spacing between type name and square brackets of array types.

array-type-spacing

This rule enforces correct spacing between type name and square brackets of array types. It also enforces no spaces between the square brackets.

🔧 The --fix option on the command line can automatically fix the problems reported by this rule.

Options

This rule takes one option:

  • "never" (default) enforces no space between type name and square brackets.
  • "always" enforces exactly one space between type name and square brackets.
"array-type-spacing": ["warn", "never"]

never:

👎 Examples of incorrect code for this rule:

const myVar: string [] = [];
function myFunc (parameter: number []) {
    // ...
}

👍 Examples of correct code for this rule:

const myVar: string[] = [];
function myFunc (parameter: number[]) {
    // ...
}

always:

👎 Examples of incorrect code for this rule:

const myVar: string[] = [];
function myFunc (parameter: number[]) {
    // ...
}

👍 Examples of correct code for this rule:

const myVar: string [] = [];
function myFunc (parameter: number []) {
    // ...
}

There is an optional configuration object:

betweenDimensions:

  • "never" (default) enforces no space between consecutive square brackets.
  • "always" enforces exactly one space between consecutive square brackets.
{
    "betweenDimensions": "never"
}

betweenDimensions: "never":

👎 Examples of incorrect code for this rule:

const myVar: string[] [] = [];
function myFunc (parameter: number[] []) {
    // ...
}

👍 Examples of correct code for this rule:

const myVar: string [][] = [];
function myFunc (parameter: number [][]) {
    // ...
}

betweenDimensions: "always":

👎 Examples of incorrect code for this rule:

const myVar: string[][] = [];
function myFunc (parameter: number[][]) {
    // ...
}

👍 Examples of correct code for this rule:

const myVar: string [] [] = [];
function myFunc (parameter: number [] []) {
    // ...
}