12.5.0 • Published 2 years ago

@typelib/eslint-plugin v12.5.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

ESLint plugin

Table of contents

Installation

npm install --save-dev @typelib/eslint-plugin

eslintrc.js

module.exports = {
  plugins: ["@typelib/eslint-plugin"]
};

Rules

class-member-typedef

Requires type definition for class members without initializer.

eslintrc.js

"@typelib/class-member-typedef": "error"

consistent-empty-lines

Requires consistent empty lines.

eslintrc.js

"@typelib/consistent-empty-lines": [
  "error",
  {
    rules: [
      {
        averageLinesGte?: number,
        everyLinesGte?: number,
        selector: string,
        someHasDocComment?: boolean,
        someLinesGte?: number
      },
      ...
    ]
  }
]

Options

NameDescription
averageLinesGteSpread group if average lines >= given value.
everyLinesGteSpread group if every lines >= given value.
selectorAST selector.
someHasDocCommentSpread group if some item has doc comment.
someLinesGteSpread group if some lines >= given value.

consistent-import

Requires consistent import. Auto-imports provided sources.

eslintrc.js

"@typelib/consistent-import": [
  "error",
  {
    sources: [
      {
        altLocalNames?: string[],
        autoImportSource?: string,
        localName?: string,
        sourcePattern: string,
        type: "default" | "wildcard"
      },
      ...
    ]
  }
]

Options

NameDescription
altLocalNamesAlternative local names to be used if localName is occupied.
autoImportSourceAuto-import source (defaults to sourcePattern).
localNameLocal name.
sourcePatternSource (minimatch pattern).
typeImport type.

disallow-by-regexp

Disallows code by regular expression.

eslintrc.js

"@typelib/disallow-by-regexp": [
  "error",
  {
    contexts?: Array<"code" | "comment" | "string">,
    rules: [
      {
        contexts?: Array<"code" | "comment" | "string">,
        patterns: string[],
        replacement?: string
      },
      ...
    ]
  }
]

Options

NameDescription
contextsContexts (defaults to all contexts).
patternsPatterns (regular expressions).
replacementReplacement.

disallow-identifier

Disallows identifiers.

eslintrc.js

"@typelib/disallow-identifier": [
  "error",
  {
    rules: [
      {
        ids: string[],
        replacement?: string
      },
      ...
    ]
  }
]

Options

NameDescription
idsIdentifiers.
replacementReplacement.

disallow-import

Disallows import.

eslintrc.js

"@typelib/disallow-import": [
  "error",
  {
    rules: [
      {
        allow?: string[],
        disallow?: string[]
      },
      ...
    ]
  }
]

Options

NameDescription
allowAllowed sources (minimatch patterns).
disallowDisallowed sources (minimatch patterns).

empty-lines-around-comment

Requires consistent empty lines around comments.

eslintrc.js

"@typelib/empty-lines-around-comment": "error"

exhaustive-switch

Requires exhaustive switch (replaces "@typescript-eslint/switch-exhaustiveness-check" rule, correctly treats typeof operator).

eslintrc.js

"@typelib/exhaustive-switch": "error"

no-inferrable-types

Forbids inferrable types (complements "@typescript-eslint/no-inferrable-types" rule).

eslintrc.js

"@typelib/no-inferrable-types": "error"

no-mutable-signature

Forbids mutable signatures.

eslintrc.js

"@typelib/no-mutable-signature": [
  "error",
  {
    ignoreClasses?: boolean,
    ignoreIdentifiers?: string[],
    ignoreNumberSignature?: boolean,
    ignoreStringSignature?: boolean,
    ignoreTypes?: string[]
  }
]

Options

NameDescription
ignoreClassesIgnore classes (defaults to true).
ignoreIdentifiersIgnore identifiers (regular expressions).
ignoreNumberSignatureIgnore number signature (defaults to true).
ignoreStringSignatureIgnore string signature.
ignoreTypesIgnore types.

no-unnecessary-readonly

Forbids unnecessary Readonly|DeepReadonly wrapper.

eslintrc.js

"@typelib/no-unnecessary-readonly": [
  "error",
  {
    ignoreClasses?: boolean,
    ignoreTypes?: string[]
  }
]

Options

NameDescription
ignoreClassesIgnores classes.
ignoreTypesIgnores types.

no-unnecessary-writable

Forbids unnecessary Writable|DeepWritable wrapper.

eslintrc.js

"@typelib/no-unnecessary-writable": [
  "error",
  {
    ignoreClasses?: boolean,
    ignoreTypes?: string[]
  }
]

Options

NameDescription
ignoreClassesIgnores classes.
ignoreTypesIgnores types.

no-unsafe-object-assignment

Forbids:

  • Readonly-to-mutable assignments.
  • Optional assignments.

eslintrc.js

"@typelib/no-unsafe-object-assignment": "error"

no-unused-import

Removes unused import.

eslintrc.js

"@typelib/no-unused-import": "error"

prefer-readonly

Enforces the use of readonly properties.

eslintrc.js

"@typelib/prefer-readonly": [
  "error",
  {
    excludeSelectors?: string[],
    ignoreClasses?: boolean,
    ignoreIdentifiers?: string[],
    ignoreTypes?: string[],
    includeSelectors?: string[],
    noDefaultSelectors?: boolean
  }
]

Options

NameDescription
excludeSelectorsExclude AST selectors.
ignoreClassesIgnore classes.
ignoreIdentifiersIgnore identifiers (regular expressions).
ignoreTypesIgnore types.
includeSelectorsAdd AST selectors.
noDefaultSelectorsDo not use default AST selectors.

require-jsdoc

Requires JSDoc comments.

eslintrc.js

"@typelib/require-jsdoc": [
  "error",
  {
    excludeSelectors?: string[],
    includeSelectors?: string[],
    interfaceOptions?: Array<"callSignatures" | "constructSignatures" | "interface">,
    noDefaultSelectors?: string[],
    propertyOptions?: Array<"function" | "nonFunction">
  }
]

Options

NameDescription
excludeSelectorsExcludes AST selectors.
includeSelectorsAdds AST selectors.
interfaceOptions.callSignaturesRequire JSDoc comment for call signatures.
interfaceOptions.constructSignaturesRequire JSDoc comment for constructor signatures.
interfaceOptions.interfaceRequire JSDoc comment for interface.
noDefaultSelectorsDo not use default AST selectors.
propertyOptions.functionRequire JSDoc comment for function property.
propertyOptions.nonFunctionRequire JSDoc comment for non-function property.

sort-class-members

Sorts class member.

eslintrc.js

"@typelib/sort-class-members": [
  "error",
  {
    sortingOrder: string[]
  }
]

Options

NameDescription
sortingOrderSorting order array may contain member types (accessor, constructor, field, get, method, set, signature), accessibility modifiers (public, private, protected), dynamic/static modifiers (dynamic, static), or any combination of them (e.g. public-accessor, get-private, static-method).

template-literal-format

Checks template literal format.

eslintrc.js

"@typelib/template-literal-format": "error"

Shared options

eslintrc.js

"@typelib/<rule-id>": [
  "error",
  {
    filesToLint?: string[],
    filesToSkip?: string[],
    <sub-options-key>: [
      {
        filesToLint?: string[],
        filesToSkip?: string[],
        subOptionsId?: string
      },
      ...
    ]
  }
]

Options

NameDescription
filesToLintFiles to lint (minimatch patterns).
filesToSkipFiles to skip (minimatch patterns).
subOptionsIdSuboptions ID.

Configuration comment

/* typelib/\<rule-id\> disable \<\>[\<sub-options-id\>] */
12.4.0

2 years ago

12.5.0

2 years ago

12.2.0

3 years ago

12.3.0

3 years ago

12.3.1

3 years ago

12.3.2

3 years ago

12.1.4

3 years ago

12.1.5

3 years ago

12.1.3

3 years ago

12.1.2

3 years ago

12.0.7

3 years ago

12.0.8

3 years ago

12.0.9

3 years ago

12.0.3

3 years ago

12.0.4

3 years ago

12.0.5

3 years ago

12.0.6

3 years ago

12.0.1

3 years ago

12.0.2

3 years ago

12.1.0

3 years ago

12.1.1

3 years ago

12.0.0

3 years ago

11.12.0

3 years ago

11.12.2

3 years ago

11.12.1

3 years ago

11.12.4

3 years ago

11.12.3

3 years ago

11.10.0

3 years ago

11.8.4

3 years ago

11.8.5

3 years ago

11.8.2

3 years ago

11.8.3

3 years ago

11.8.0

3 years ago

11.8.1

3 years ago

11.11.0

3 years ago

11.9.0

3 years ago

11.7.0

3 years ago

11.7.1

3 years ago

11.7.2

3 years ago

11.6.0

3 years ago

11.6.1

3 years ago

11.6.2

3 years ago

11.4.0

3 years ago

11.4.1

3 years ago

11.3.1

3 years ago

11.5.0

3 years ago

11.3.0

3 years ago

11.2.2

3 years ago

11.2.1

3 years ago

11.2.0

3 years ago

11.1.0

3 years ago

10.2.0

3 years ago

11.0.0

3 years ago

10.1.4

3 years ago

10.1.0

3 years ago

10.1.1

3 years ago

10.1.2

3 years ago

10.1.3

3 years ago

10.0.0

3 years ago

9.0.0

3 years ago

8.1.0

3 years ago

8.0.0

3 years ago

7.0.0

3 years ago

7.0.3

3 years ago

7.0.2

3 years ago

7.0.1

3 years ago

6.0.1

3 years ago

5.6.0

3 years ago

6.0.0

3 years ago

5.5.1

3 years ago

5.5.0

3 years ago

5.4.0

3 years ago

5.3.0

3 years ago

5.5.3

3 years ago

5.5.2

3 years ago

5.2.0

3 years ago

5.1.0

3 years ago

5.0.0

3 years ago

4.0.1

3 years ago

4.0.2

3 years ago

4.0.0

3 years ago

3.0.0

3 years ago

2.1.0

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.0

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago