Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

eslint-plugin-dtslint

cartant125MIT3.0.2

ESLint rules for dtslint tests

dtslint, lint, rules, eslint

readme

eslint-plugin-dtslint

GitHub License NPM version Downloads Build status dependency status devDependency Status peerDependency Status

This repo contains ESLint versions of the dtslint rules in the tslint-etc package. They're useful if you have an existing suite of dtslint tests. However, if you've not yet started writing tests for your TypeScript types, you should look at using tsd instead.

Install

Install the ESLint TypeScript parser using npm:

npm install @typescript-eslint/parser --save-dev

Install the package using npm:

npm install eslint-plugin-dtslint --save-dev

Configure the parser and the parserOptions for ESLint. Here, I use a .eslintrc.js file for the configuration:

const { join } = require("path");
module.exports = {
  parser: "@typescript-eslint/parser",
  parserOptions: {
    ecmaVersion: 2019,
    project: join(__dirname, "./tsconfig.json"),
    sourceType: "module"
  },
  plugins: ["dtslint"],
  extends: [],
  rules: {
    "dtslint/expect-deprecation": "error",
    "dtslint/expect-type": "error",
    "dtslint/no-typo": "error"
  }
};

Or, using the recommended configuration:

const { join } = require("path");
module.exports = {
  parser: "@typescript-eslint/parser",
  parserOptions: {
    ecmaVersion: 2019,
    project: join(__dirname, "./tsconfig.json"),
    sourceType: "module"
  },
  extends: ["plugin:dtslint/recommended"],
};

Rules

The package includes the following rules:

Rule Description Recommended
expect-deprecation Asserts deprecations with $ExpectDeprecation and $ExpectNoDeprecation. Yes
expect-type Asserts types with $ExpectType and presence of errors with $ExpectError. You can use ESLint and this rule to perform your type tests without having to install or run dtslint. Yes
no-typo Forbids dtslint-like expectations that have typographical errors. Yes

changelog

3.0.2 (2023-05-09)

Changes

  • Widen the TypeScript peer dependency. (b263d4c)

3.0.1 (2022-07-16)

Changes

  • Upgrade dependencies.

3.0.0 (2021-10-17)

Breaking Changes

  • Support eslint v8 and @typescript-eslint v5. (d6cf4d5)

2.0.8 (2021-10-17)

Fixes

  • Support changes made to the comment AST in TypeScript 4.3. (60af1ab)

2.0.7 (2021-03-22)

Fixes

  • Set minimum eslint-etc version. (4aac0fe)

2.0.6 (2021-03-20)

Fixes

  • Enable TypeScript's strict option and fix related problems. (52a106f)

2.0.5 (2021-01-11)

Changes

  • Fix GitHub URL for docs. (be46734)

2.0.4 (2020-11-28)

Changes

  • Use file in package.json instead of .npmignore. (483f4c3)

2.0.3 (2020-11-03)

Changes

  • Update rule metadata.

2.0.2 (2020-10-23)

Changes

  • Specify engines in package.json.
  • Downlevel the TypeScript output to ES2019.

2.0.1 (2020-10-21)

Changes

  • Add docs and recommended config.

2.0.0 (2020-09-02)

Changes

1.1.2 (2020-09-02)

Changes

  • Upgrade @typescript-eslint dependencies. (f0e464f)

1.1.1 (2020-08-23)

Fixes

  • In expect-type, ignore diagnostics that don't have a line. (9be1afa)

1.1.0 (2020-08-23)

Features

  • Add the expect-type rule (from dtslint). (adfb8b9)

1.0.1 (2020-06-24)

Changes

  • Don't distribute the yarn.lock file.