eslint-plugin-etc
raw JSON → 2.0.3 verified Sat Apr 25 auth: no javascript
ESLint plugin providing TypeScript-focused, general-purpose lint rules. Current version 2.0.3 (stable). The package reimplements TSLint-etc rules for ESLint, covering areas like array mutation, commented-out code, const enums, deprecated APIs, and more. It requires TypeScript 4.0+ and ESLint 8. Some rules are opinionated and excluded from the recommended config, giving developers flexibility. Compared to @typescript-eslint/eslint-plugin, it offers unique rules like no-t, no-const-enum, and no-implicit-any-catch for Promise rejections.
Common errors
error Error: Cannot find module 'eslint-plugin-etc' ↓
cause The plugin is not installed globally or locally.
fix
Run 'npm install eslint-plugin-etc --save-dev'.
error Configuration for rule 'etc/no-t' is invalid: Value "error" should be a boolean. ↓
cause Old syntax using 'true' instead of 'error'/'warn'/'off'.
fix
Use 'error' or 'warn' instead of 'true'.
error Parsing error: The 'project' option must be set to a path to a tsconfig.json file. ↓
cause Missing or incorrect parserOptions.project in ESLint config.
fix
Set parserOptions.project to a valid path to your tsconfig.json.
Warnings
breaking Version 2.0.0+ may have changed configuration schema or dropped rules; check migration docs. ↓
fix Review the changelog on GitHub for breaking changes.
deprecated Some rules have been deprecated or renamed from the original tslint-etc set. ↓
fix Check the documentation for each rule to ensure you are using the correct name.
gotcha The 'no-deprecated' rule requires a TypeScript project and may produce false positives if type information is incomplete. ↓
fix Ensure the parserOptions.project points to a valid tsconfig.json and type information is available.
gotcha Some opinionated rules (e.g., no-enum, no-const-enum) are not in the 'recommended' config and need explicit enabling. ↓
fix Add the rule to your 'rules' object with the desired severity.
Install
npm install eslint-plugin-etc yarn add eslint-plugin-etc pnpm add eslint-plugin-etc Imports
- plugin wrong
const plugin = require('eslint-plugin-etc'); // incorrect usage in configcorrectplugins: ['etc'] - etc/recommended wrong
extends: ['etc/recommended'] // missing 'plugin:' prefixcorrectextends: ['plugin:etc/recommended'] - rules wrong
rules: { 'no-t': 'error' } // missing 'etc/' prefixcorrectrules: { 'etc/no-t': 'error' }
Quickstart
// In .eslintrc.js
const { join } = require('path');
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2019,
project: join(__dirname, './tsconfig.json'),
sourceType: 'module'
},
plugins: ['etc'],
extends: ['plugin:etc/recommended'],
rules: {
'etc/no-t': 'error'
}
};