@corbinu/eslint-plugin-typescript

中文文档
25.0.1发布于 2019/01/19MITCommonJS近 30 天下载 2485

TypeScript plugin for ESLint

原始使用文档
文档目录4 节
  1. The below readme is for the upcoming 1.0.0 release. Please …
  2. Installation
  3. Usage
  4. Supported Rules

eslint-plugin-typescript

NPM version NPM downloads TravisCI

TypeScript support for ESLint. (This is still in the very early stages, so please be patient.)

The below readme is for the upcoming 1.0.0 release. Please see this tag for the current NPM version (0.14.0)

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install typescript if you haven’t already:

$ npm i typescript@~3.1.1 --save-dev

Last, install eslint-plugin-typescript:

$ npm install eslint-plugin-typescript --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-typescript globally.

Usage

Add eslint-plugin-typescript/parser to the parser field and typescript to the plugins section of your .eslintrc configuration file:

{
  "parser": "eslint-plugin-typescript/parser",
  "plugins": ["typescript"]
}

Note: The plugin provides its own version of the @typescript-eslint/parser via eslint-plugin-typescript/parser. This helps us guarantee 100% compatibility between the plugin and the parser.

Then configure the rules you want to use under the rules section.

{
  "parser": "eslint-plugin-typescript/parser",
  "plugins": ["typescript"],
  "rules": {
    "typescript/rule-name": "error"
  }
}

You can also enable all the recommended rules at once. Add plugin:typescript/recommended in extends:

{
  "extends": ["plugin:typescript/recommended"]
}

Supported Rules

Key: :heavy_check_mark: = recommended, :wrench: = fixable

NameDescription:heavy_check_mark::wrench:
typescript/adjacent-overload-signaturesRequire that member overloads be consecutive (adjacent-overload-signatures from TSLint):heavy_check_mark:
typescript/array-typeRequires using either T[] or Array<T> for arrays (array-type from TSLint):heavy_check_mark::wrench:
typescript/ban-typesEnforces that types will not to be used (ban-types from TSLint):heavy_check_mark::wrench:
typescript/camelcaseEnforce camelCase naming convention:heavy_check_mark:
typescript/class-name-casingRequire PascalCased class and interface names (class-name from TSLint):heavy_check_mark:
typescript/explicit-function-return-typeRequire explicit return types on functions and class methods:heavy_check_mark:
typescript/explicit-member-accessibilityRequire explicit accessibility modifiers on class properties and methods (member-access from TSLint):heavy_check_mark:
typescript/generic-type-namingEnforces naming of generic type variables
typescript/indentEnforce consistent indentation (indent from TSLint):heavy_check_mark::wrench:
typescript/interface-name-prefixRequire that interface names be prefixed with I (interface-name from TSLint):heavy_check_mark:
typescript/member-delimiter-styleRequire a specific member delimiter style for interfaces and type literals:heavy_check_mark::wrench:
typescript/member-namingEnforces naming conventions for class members by visibility.
typescript/member-orderingRequire a consistent member declaration order (member-ordering from TSLint)
typescript/no-angle-bracket-type-assertionEnforces the use of as Type assertions instead of <Type> assertions (no-angle-bracket-type-assertion from TSLint):heavy_check_mark:
typescript/no-array-constructorDisallow generic Array constructors:heavy_check_mark::wrench:
typescript/no-empty-interfaceDisallow the declaration of empty interfaces (no-empty-interface from TSLint):heavy_check_mark:
typescript/no-explicit-anyDisallow usage of the any type (no-any from TSLint):heavy_check_mark:
typescript/no-extraneous-classForbids the use of classes as namespaces (no-unnecessary-class from TSLint)
typescript/no-inferrable-typesDisallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. (no-inferrable-types from TSLint):heavy_check_mark::wrench:
typescript/no-misused-newEnforce valid definition of new and constructor. (no-misused-new from TSLint):heavy_check_mark:
typescript/no-namespaceDisallow the use of custom TypeScript modules and namespaces (no-namespace from TSLint):heavy_check_mark:
typescript/no-non-null-assertionDisallows non-null assertions using the ! postfix operator (no-non-null-assertion from TSLint):heavy_check_mark:
typescript/no-object-literal-type-assertionForbids an object literal to appear in a type assertion expression (no-object-literal-type-assertion from TSLint):heavy_check_mark:
typescript/no-parameter-propertiesDisallow the use of parameter properties in class constructors. (no-parameter-properties from TSLint):heavy_check_mark:
typescript/no-this-aliasDisallow aliasing this (no-this-assignment from TSLint)
typescript/no-triple-slash-referenceDisallow /// <reference path="" /> comments (no-reference from TSLint):heavy_check_mark:
typescript/no-type-aliasDisallow the use of type aliases (interface-over-type-literal from TSLint)
typescript/no-unused-varsDisallow unused variables (no-unused-variable from TSLint):heavy_check_mark:
typescript/no-use-before-defineDisallow the use of variables before they are defined:heavy_check_mark:
typescript/no-var-requiresDisallows the use of require statements except in import statements (no-var-requires from TSLint):heavy_check_mark:
typescript/prefer-interfacePrefer an interface declaration over a type literal (type T = { ... }) (interface-over-type-literal from TSLint):heavy_check_mark::wrench:
typescript/prefer-namespace-keywordRequire the use of the namespace keyword instead of the module keyword to declare custom TypeScript modules. (no-internal-module from TSLint):heavy_check_mark::wrench:
typescript/type-annotation-spacingRequire consistent spacing around type annotations (typedef-whitespace from TSLint):heavy_check_mark::wrench:

版本与发布记录

@corbinu/eslint-plugin-typescript 共发布 3 个版本,首次发布于 2017/05/12;过去 12 个月发布了 0 个版本。

版本发布日期距今
25.0.1latest2019/01/197 年前
23.0.02019/01/197 年前
0.2.02017/05/129 年前

关于 @corbinu/eslint-plugin-typescript 的常见问题

@corbinu/eslint-plugin-typescript 是什么?

TypeScript plugin for ESLint

如何安装 @corbinu/eslint-plugin-typescript?

在项目目录运行 npm install @corbinu/eslint-plugin-typescript,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eslint(>=4.13.1 < 6)、typescript(~3.2.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@corbinu/eslint-plugin-typescript 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/corbinu__eslint-plugin-typescript 是否存在。

@corbinu/eslint-plugin-typescript 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@corbinu/eslint-plugin-typescript 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=6。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@corbinu/eslint-plugin-typescript 可以商用吗?

@corbinu/eslint-plugin-typescript 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@corbinu/eslint-plugin-typescript 的下载量有多少?

根据 npm 官方下载统计,@corbinu/eslint-plugin-typescript 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,485 次,日均约 83 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@corbinu/eslint-plugin-typescript 还在维护吗?

最新版本 25.0.1 发布于 2019/01/19(7 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2017/05/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。