Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@typescript-eslint/eslint-plugin

Package Overview
Dependencies
Maintainers
2
Versions
3842
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@typescript-eslint/eslint-plugin - npm Package Compare versions

Comparing version 6.1.0 to 6.4.0

dist/rules/class-methods-use-this.js

2

dist/configs/all.js

@@ -22,2 +22,4 @@ "use strict";

'@typescript-eslint/class-literal-property-style': 'error',
'class-methods-use-this': 'off',
'@typescript-eslint/class-methods-use-this': 'error',
'comma-dangle': 'off',

@@ -24,0 +26,0 @@ '@typescript-eslint/comma-dangle': 'error',

32

dist/rules/consistent-type-imports.js

@@ -234,23 +234,17 @@ "use strict";

}
else {
return {
messageId: 'aImportIsOnlyTypes',
data: { typeImports },
};
}
return {
messageId: 'aImportIsOnlyTypes',
data: { typeImports },
};
}
else {
if (isTypeImport) {
return {
messageId: 'someImportsInDecoMeta',
data: { typeImports }, // typeImports are all the value specifiers that are in the type position
};
}
else {
return {
messageId: 'someImportsAreOnlyTypes',
data: { typeImports }, // typeImports are all the type specifiers in the value position
};
}
if (isTypeImport) {
return {
messageId: 'someImportsInDecoMeta',
data: { typeImports }, // typeImports are all the value specifiers that are in the type position
};
}
return {
messageId: 'someImportsAreOnlyTypes',
data: { typeImports }, // typeImports are all the type specifiers in the value position
};
})();

@@ -257,0 +251,0 @@ context.report({

@@ -165,17 +165,15 @@ "use strict";

}
else {
return {
type,
accessibility: undefined,
declare: false,
decorators: [],
definite: false,
optional: false,
override: false,
readonly: false,
static: false,
typeAnnotation: undefined,
...base,
};
}
return {
type,
accessibility: undefined,
declare: false,
decorators: [],
definite: false,
optional: false,
override: false,
readonly: false,
static: false,
typeAnnotation: undefined,
...base,
};
}

@@ -182,0 +180,0 @@ return Object.assign({}, rules, {

@@ -15,2 +15,3 @@ "use strict";

const class_literal_property_style_1 = __importDefault(require("./class-literal-property-style"));
const class_methods_use_this_1 = __importDefault(require("./class-methods-use-this"));
const comma_dangle_1 = __importDefault(require("./comma-dangle"));

@@ -149,2 +150,3 @@ const comma_spacing_1 = __importDefault(require("./comma-spacing"));

'class-literal-property-style': class_literal_property_style_1.default,
'class-methods-use-this': class_methods_use_this_1.default,
'comma-dangle': comma_dangle_1.default,

@@ -151,0 +153,0 @@ 'comma-spacing': comma_spacing_1.default,

@@ -119,5 +119,3 @@ "use strict";

}
else {
return fixer.insertTextBefore(typeAnnotation, ' '.repeat(-difference));
}
return fixer.insertTextBefore(typeAnnotation, ' '.repeat(-difference));
},

@@ -147,5 +145,3 @@ data: {

}
else {
return fixer.insertTextBefore(typeAnnotation.typeAnnotation, ' '.repeat(-difference));
}
return fixer.insertTextBefore(typeAnnotation.typeAnnotation, ' '.repeat(-difference));
},

@@ -255,5 +251,3 @@ data: {

}
else {
return fixer.insertTextBefore(toCheck, ' '.repeat(-difference));
}
return fixer.insertTextBefore(toCheck, ' '.repeat(-difference));
},

@@ -260,0 +254,0 @@ data: {

@@ -618,2 +618,5 @@ "use strict";

function naturalOutOfOrder(name, previousName, order) {
if (name === previousName) {
return false;
}
switch (order) {

@@ -620,0 +623,0 @@ case 'alphabetically':

@@ -47,2 +47,3 @@ "use strict";

create(context) {
const sourceCode = context.getSourceCode();
const rules = baseRule.create(context);

@@ -90,4 +91,5 @@ function binaryExp(node) {

if (node.arguments.length === 1 &&
node.typeArguments?.params.some(param => param.type === utils_1.AST_NODE_TYPES.TSImportType ||
param.type === utils_1.AST_NODE_TYPES.TSArrayType)) {
// is there any opening parenthesis in type arguments
sourceCode.getTokenAfter(node.callee, util.isOpeningParenToken) !==
sourceCode.getTokenBefore(node.arguments[0], util.isOpeningParenToken)) {
return rule({

@@ -94,0 +96,0 @@ ...node,

@@ -104,8 +104,6 @@ "use strict";

}
else {
return [
fixer.insertTextBefore(node, 'void ('),
fixer.insertTextAfterRange([expression.range[1], expression.range[1]], ')'),
];
}
return [
fixer.insertTextBefore(node, 'void ('),
fixer.insertTextAfterRange([expression.range[1], expression.range[1]], ')'),
];
},

@@ -134,8 +132,6 @@ },

}
else {
return [
fixer.insertTextBefore(node, 'await ('),
fixer.insertTextAfterRange([expression.range[1], expression.range[1]], ')'),
];
}
return [
fixer.insertTextBefore(node, 'await ('),
fixer.insertTextAfterRange([expression.range[1], expression.range[1]], ')'),
];
},

@@ -200,5 +196,3 @@ },

}
else {
return { isUnhandled: true, nonFunctionHandler: true };
}
return { isUnhandled: true, nonFunctionHandler: true };
}

@@ -210,5 +204,3 @@ const thenRejectionHandler = getRejectionHandlerFromThenCall(node);

}
else {
return { isUnhandled: true, nonFunctionHandler: true };
}
return { isUnhandled: true, nonFunctionHandler: true };
}

@@ -231,5 +223,3 @@ // `x.finally()` is transparent to resolution of the promise, so check `x`.

}
else {
return isUnhandledPromise(checker, node.consequent);
}
return isUnhandledPromise(checker, node.consequent);
}

@@ -249,5 +239,3 @@ else if (node.type === utils_1.AST_NODE_TYPES.MemberExpression ||

}
else {
return isUnhandledPromise(checker, node.right);
}
return isUnhandledPromise(checker, node.right);
}

@@ -305,5 +293,3 @@ // We conservatively return false for all other types of expressions because

}
else {
return undefined;
}
return undefined;
}

@@ -317,5 +303,3 @@ function getRejectionHandlerFromThenCall(expression) {

}
else {
return undefined;
}
return undefined;
}

@@ -322,0 +306,0 @@ function getObjectFromFinallyCall(expression) {

@@ -182,6 +182,11 @@ "use strict";

}
node.params.filter(param => param.type === utils_1.AST_NODE_TYPES.AssignmentPattern &&
param.left &&
param.right).forEach(param => {
reportInferrableType(param, param.left.typeAnnotation, param.right);
node.params.forEach(param => {
if (param.type === utils_1.AST_NODE_TYPES.TSParameterProperty) {
param = param.parameter;
}
if (param.type === utils_1.AST_NODE_TYPES.AssignmentPattern &&
param.left &&
param.right) {
reportInferrableType(param, param.left.typeAnnotation, param.right);
}
});

@@ -188,0 +193,0 @@ }

@@ -6,2 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const ignore_1 = __importDefault(require("ignore"));

@@ -173,3 +174,5 @@ const util_1 = require("../util");

ImportDeclaration(node) {
if (node.importKind === 'type') {
if (node.importKind === 'type' ||
node.specifiers.every(specifier => specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier &&
specifier.importKind === 'type')) {
const importSource = node.source.value.trim();

@@ -186,3 +189,4 @@ if (!isAllowedTypeImportPath(importSource) &&

'ExportNamedDeclaration[source]'(node) {
if (node.exportKind === 'type') {
if (node.exportKind === 'type' ||
node.specifiers.every(specifier => specifier.exportKind === 'type')) {
const importSource = node.source.value.trim();

@@ -189,0 +193,0 @@ if (!isAllowedTypeImportPath(importSource) &&

@@ -404,7 +404,5 @@ "use strict";

}
else {
return {
global: true,
};
}
return {
global: true,
};
}

@@ -411,0 +409,0 @@ /**

@@ -72,3 +72,3 @@ "use strict";

return {
'BinaryExpression[operator=/=|<|>/]'(node) {
'BinaryExpression[operator=/^[<>!=]?={0,2}$/]'(node) {
const left = getTypeFromNode(node.left);

@@ -75,0 +75,0 @@ const right = getTypeFromNode(node.right);

@@ -69,5 +69,3 @@ "use strict";

}
else {
return ((type.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined)) !== 0);
}
return (type.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined)) !== 0;
};

@@ -111,5 +109,9 @@ const sameTypeWithoutNullish = (assertedTypes, originalTypes) => {

if (sameTypeWithoutNullish(assertedTypes, originalTypes)) {
const expressionSourceCode = sourceCode.getText(node.expression);
const higherPrecedenceThanUnary = util.getOperatorPrecedence(services.esTreeNodeToTSNodeMap.get(node.expression).kind, ts.SyntaxKind.Unknown) > util.OperatorPrecedence.Unary;
context.report({
fix(fixer) {
return fixer.replaceText(node, `${sourceCode.getText(node.expression)}!`);
return fixer.replaceText(node, higherPrecedenceThanUnary
? `${expressionSourceCode}!`
: `(${expressionSourceCode})!`);
},

@@ -116,0 +118,0 @@ messageId: 'preferNonNullAssertion',

@@ -60,9 +60,17 @@ "use strict";

ignorePrimitives: {
type: 'object',
properties: {
bigint: { type: 'boolean' },
boolean: { type: 'boolean' },
number: { type: 'boolean' },
string: { type: 'boolean' },
},
oneOf: [
{
type: 'object',
properties: {
bigint: { type: 'boolean' },
boolean: { type: 'boolean' },
number: { type: 'boolean' },
string: { type: 'boolean' },
},
},
{
type: 'boolean',
enum: [true],
},
],
},

@@ -247,10 +255,16 @@ ignoreTernaryTests: {

const ignorableFlags = [
ignorePrimitives.bigint && ts.TypeFlags.BigInt,
ignorePrimitives.boolean && ts.TypeFlags.BooleanLiteral,
ignorePrimitives.number && ts.TypeFlags.Number,
ignorePrimitives.string && ts.TypeFlags.String,
(ignorePrimitives === true || ignorePrimitives.bigint) &&
ts.TypeFlags.BigInt,
(ignorePrimitives === true || ignorePrimitives.boolean) &&
ts.TypeFlags.BooleanLiteral,
(ignorePrimitives === true || ignorePrimitives.number) &&
ts.TypeFlags.Number,
(ignorePrimitives === true || ignorePrimitives.string) &&
ts.TypeFlags.String,
]
.filter((flag) => flag !== undefined)
.filter((flag) => typeof flag === 'number')
.reduce((previous, flag) => previous | flag, 0);
if (type.types.some(t => tsutils.isTypeFlagSet(t, ignorableFlags))) {
if (type.flags !== ts.TypeFlags.Null &&
type.flags !== ts.TypeFlags.Undefined &&
type.types.some(t => tsutils.isTypeFlagSet(t, ignorableFlags))) {
return;

@@ -257,0 +271,0 @@ }

@@ -254,11 +254,9 @@ "use strict";

}
else {
const unaryOperator = lastOperand.node.left.type === utils_1.AST_NODE_TYPES.UnaryExpression
? lastOperand.node.left.operator + ' '
: '';
return {
left: unaryOperator + newCode,
right: sourceCode.getText(lastOperand.node.right),
};
}
const unaryOperator = lastOperand.node.left.type === utils_1.AST_NODE_TYPES.UnaryExpression
? lastOperand.node.left.operator + ' '
: '';
return {
left: unaryOperator + newCode,
right: sourceCode.getText(lastOperand.node.right),
};
})();

@@ -265,0 +263,0 @@ newCode = `${left} ${operator} ${right}`;

@@ -97,9 +97,7 @@ "use strict";

}
else {
return {
comparedExpression: operand.right,
comparedValue: getComparisonValueType(operand.left),
isYoda: true,
};
}
return {
comparedExpression: operand.right,
comparedValue: getComparisonValueType(operand.left),
isYoda: true,
};
})();

@@ -106,0 +104,0 @@ if (comparedValue === "UndefinedStringLiteral" /* ComparisonValueType.UndefinedStringLiteral */) {

@@ -164,7 +164,9 @@ "use strict";

* @param pattern The RegExp pattern text to parse.
* @param uFlag The Unicode flag of the RegExp.
* @param unicode Whether the RegExp is unicode.
*/
function parseRegExpText(pattern, uFlag) {
function parseRegExpText(pattern, unicode) {
// Parse it.
const ast = regexpp.parsePattern(pattern, undefined, undefined, uFlag);
const ast = regexpp.parsePattern(pattern, undefined, undefined, {
unicode,
});
if (ast.alternatives.length !== 1) {

@@ -171,0 +173,0 @@ return null;

@@ -137,8 +137,6 @@ "use strict";

}
else {
return [
fixer.insertTextBefore(node, 'await ('),
fixer.insertTextAfter(node, ')'),
];
}
return [
fixer.insertTextBefore(node, 'await ('),
fixer.insertTextAfter(node, ')'),
];
}

@@ -145,0 +143,0 @@ function isHigherPrecedenceThanAwait(node) {

@@ -623,8 +623,13 @@ "use strict";

messageId: 'conditionErrorNullableObject',
fix: util.getWrappingFixer({
sourceCode,
node: node.parent,
innerNode: node,
wrap: code => `${code} == null`,
}),
suggest: [
{
messageId: 'conditionFixCompareNullish',
fix: util.getWrappingFixer({
sourceCode,
node: node.parent,
innerNode: node,
wrap: code => `${code} == null`,
}),
},
],
});

@@ -637,7 +642,12 @@ }

messageId: 'conditionErrorNullableObject',
fix: util.getWrappingFixer({
sourceCode,
node,
wrap: code => `${code} != null`,
}),
suggest: [
{
messageId: 'conditionFixCompareNullish',
fix: util.getWrappingFixer({
sourceCode,
node,
wrap: code => `${code} != null`,
}),
},
],
});

@@ -644,0 +654,0 @@ }

@@ -61,5 +61,3 @@ "use strict";

}
else {
return rules.colon;
}
return rules.colon;
}

@@ -80,5 +78,3 @@ function getRules(rules, node) {

}
else {
return rules.colon;
}
return rules.colon;
}

@@ -85,0 +81,0 @@ exports.default = util.createRule({

"use strict";
// adapted from https://github.com/eslint/eslint/blob/5bdaae205c3a0089ea338b382df59e21d5b06436/lib/rules/utils/ast-utils.js#L1668-L1787
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFunctionHeadLoc = void 0;
const utils_1 = require("@typescript-eslint/utils");
const astUtils_1 = require("./astUtils");
/**
* Creates a report location for the given function.
* The location only encompasses the "start" of the function, and not the body
* Gets the `(` token of the given function node.
* @param node The function node to get.
* @param sourceCode The source code object to get tokens.
* @returns `(` token.
*/
function getOpeningParenOfParams(node, sourceCode) {
// If the node is an arrow function and doesn't have parens, this returns the identifier of the first param.
if (node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression &&
node.params.length === 1) {
const argToken = utils_1.ESLintUtils.nullThrows(sourceCode.getFirstToken(node.params[0]), utils_1.ESLintUtils.NullThrowsReasons.MissingToken('parameter', 'arrow function'));
const maybeParenToken = sourceCode.getTokenBefore(argToken);
return maybeParenToken && (0, astUtils_1.isOpeningParenToken)(maybeParenToken)
? maybeParenToken
: argToken;
}
// Otherwise, returns paren.
return node.id != null
? utils_1.ESLintUtils.nullThrows(sourceCode.getTokenAfter(node.id, astUtils_1.isOpeningParenToken), utils_1.ESLintUtils.NullThrowsReasons.MissingToken('id', 'function'))
: utils_1.ESLintUtils.nullThrows(sourceCode.getFirstToken(node, astUtils_1.isOpeningParenToken), utils_1.ESLintUtils.NullThrowsReasons.MissingToken('opening parenthesis', 'function'));
}
/**
* Gets the location of the given function node for reporting.
*
* eg.
*
* ```
* function foo(args) {}
* ^^^^^^^^^^^^^^^^^^
*
* get y(args) {}
* ^^^^^^^^^^^
*
* const x = (args) => {}
* ^^^^^^^^^
* ```
* - `function foo() {}`
* ^^^^^^^^^^^^
* - `(function foo() {})`
* ^^^^^^^^^^^^
* - `(function() {})`
* ^^^^^^^^
* - `function* foo() {}`
* ^^^^^^^^^^^^^
* - `(function* foo() {})`
* ^^^^^^^^^^^^^
* - `(function*() {})`
* ^^^^^^^^^
* - `() => {}`
* ^^
* - `async () => {}`
* ^^
* - `({ foo: function foo() {} })`
* ^^^^^^^^^^^^^^^^^
* - `({ foo: function() {} })`
* ^^^^^^^^^^^^^
* - `({ ['foo']: function() {} })`
* ^^^^^^^^^^^^^^^^^
* - `({ [foo]: function() {} })`
* ^^^^^^^^^^^^^^^
* - `({ foo() {} })`
* ^^^
* - `({ foo: function* foo() {} })`
* ^^^^^^^^^^^^^^^^^^
* - `({ foo: function*() {} })`
* ^^^^^^^^^^^^^^
* - `({ ['foo']: function*() {} })`
* ^^^^^^^^^^^^^^^^^^
* - `({ [foo]: function*() {} })`
* ^^^^^^^^^^^^^^^^
* - `({ *foo() {} })`
* ^^^^
* - `({ foo: async function foo() {} })`
* ^^^^^^^^^^^^^^^^^^^^^^^
* - `({ foo: async function() {} })`
* ^^^^^^^^^^^^^^^^^^^
* - `({ ['foo']: async function() {} })`
* ^^^^^^^^^^^^^^^^^^^^^^^
* - `({ [foo]: async function() {} })`
* ^^^^^^^^^^^^^^^^^^^^^
* - `({ async foo() {} })`
* ^^^^^^^^^
* - `({ get foo() {} })`
* ^^^^^^^
* - `({ set foo(a) {} })`
* ^^^^^^^
* - `class A { constructor() {} }`
* ^^^^^^^^^^^
* - `class A { foo() {} }`
* ^^^
* - `class A { *foo() {} }`
* ^^^^
* - `class A { async foo() {} }`
* ^^^^^^^^^
* - `class A { ['foo']() {} }`
* ^^^^^^^
* - `class A { *['foo']() {} }`
* ^^^^^^^^
* - `class A { async ['foo']() {} }`
* ^^^^^^^^^^^^^
* - `class A { [foo]() {} }`
* ^^^^^
* - `class A { *[foo]() {} }`
* ^^^^^^
* - `class A { async [foo]() {} }`
* ^^^^^^^^^^^
* - `class A { get foo() {} }`
* ^^^^^^^
* - `class A { set foo(a) {} }`
* ^^^^^^^
* - `class A { static foo() {} }`
* ^^^^^^^^^^
* - `class A { static *foo() {} }`
* ^^^^^^^^^^^
* - `class A { static async foo() {} }`
* ^^^^^^^^^^^^^^^^
* - `class A { static get foo() {} }`
* ^^^^^^^^^^^^^^
* - `class A { static set foo(a) {} }`
* ^^^^^^^^^^^^^^
* - `class A { foo = function() {} }`
* ^^^^^^^^^^^^^^
* - `class A { static foo = function() {} }`
* ^^^^^^^^^^^^^^^^^^^^^
* - `class A { foo = (a, b) => {} }`
* ^^^^^^
* @param node The function node to get.
* @param sourceCode The source code object to get tokens.
* @returns The location of the function node for reporting.
*/
function getFunctionHeadLoc(node, sourceCode) {
function getLocStart() {
if (node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition) {
// return the start location for class method
if (node.parent.decorators && node.parent.decorators.length > 0) {
// exclude decorators
return sourceCode.getTokenAfter(node.parent.decorators[node.parent.decorators.length - 1]).loc.start;
}
return node.parent.loc.start;
const parent = node.parent;
let start = null;
let end = null;
if (parent.type === utils_1.AST_NODE_TYPES.MethodDefinition ||
parent.type === utils_1.AST_NODE_TYPES.PropertyDefinition) {
// the decorator's range is included within the member
// however it's usually irrelevant to the member itself - so we don't want
// to highlight it ever.
if (parent.decorators.length > 0) {
const lastDecorator = parent.decorators[parent.decorators.length - 1];
const firstTokenAfterDecorator = utils_1.ESLintUtils.nullThrows(sourceCode.getTokenAfter(lastDecorator), utils_1.ESLintUtils.NullThrowsReasons.MissingToken('modifier or member name', 'class member'));
start = firstTokenAfterDecorator.loc.start;
}
if (node.parent.type === utils_1.AST_NODE_TYPES.Property && node.parent.method) {
// return the start location for object method shorthand
return node.parent.loc.start;
else {
start = parent.loc.start;
}
// return the start location for a regular function
return node.loc.start;
end = getOpeningParenOfParams(node, sourceCode).loc.start;
}
function getLocEnd() {
if (node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression) {
// find the end location for arrow function expression
return sourceCode.getTokenBefore(node.body, token => token.type === utils_1.AST_TOKEN_TYPES.Punctuator && token.value === '=>').loc.end;
}
// return the end location for a regular function
return sourceCode.getTokenBefore(node.body).loc.end;
else if (parent.type === utils_1.AST_NODE_TYPES.Property) {
start = parent.loc.start;
end = getOpeningParenOfParams(node, sourceCode).loc.start;
}
else if (node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression) {
const arrowToken = utils_1.ESLintUtils.nullThrows(sourceCode.getTokenBefore(node.body, astUtils_1.isArrowToken), utils_1.ESLintUtils.NullThrowsReasons.MissingToken('arrow token', 'arrow function'));
start = arrowToken.loc.start;
end = arrowToken.loc.end;
}
else {
start = node.loc.start;
end = getOpeningParenOfParams(node, sourceCode).loc.start;
}
return {
start: getLocStart(),
end: getLocEnd(),
start: Object.assign({}, start),
end: Object.assign({}, end),
};

@@ -51,0 +161,0 @@ }

@@ -24,2 +24,3 @@ "use strict";

__exportStar(require("./getOperatorPrecedence"), exports);
__exportStar(require("./getStaticStringValue"), exports);
__exportStar(require("./getStringLength"), exports);

@@ -26,0 +27,0 @@ __exportStar(require("./getThisExpression"), exports);

@@ -132,8 +132,6 @@ "use strict";

}
else {
return {
type: MemberNameType.Normal,
name,
};
}
return {
type: MemberNameType.Normal,
name,
};
}

@@ -140,0 +138,0 @@ return {

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/block-spacing`](https://eslint.org/docs/rules/block-spacing) rule.
This version adds support for TypeScript related blocks (interfaces, object type literals and enums).

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/brace-style`](https://eslint.org/docs/rules/brace-style) rule.
It adds support for `enum`, `interface`, `namespace` and `module` declarations.

@@ -9,4 +9,2 @@ ---

## Examples
This rule extends the base [`eslint/comma-dangle`](https://eslint.org/docs/rules/comma-dangle) rule.

@@ -13,0 +11,0 @@ It adds support for TypeScript syntax.

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/comma-spacing`](https://eslint.org/docs/rules/comma-spacing) rule.
It adds support for trailing comma in a types parameters list.

@@ -9,4 +9,2 @@ ---

## Examples
This rule extends the base [`eslint/default-param-last`](https://eslint.org/docs/rules/default-param-last) rule.

@@ -13,0 +11,0 @@ It adds support for optional parameters.

@@ -9,4 +9,2 @@ ---

## Examples
This rule extends the base [`eslint/dot-notation`](https://eslint.org/docs/rules/dot-notation) rule.

@@ -13,0 +11,0 @@ It adds:

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing) rule.
It adds support for generic type parameters on function calls.

@@ -17,5 +17,3 @@ ---

## Examples
This rule extends the base [`eslint/indent`](https://eslint.org/docs/rules/indent) rule.
It adds support for TypeScript nodes.

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/init-declarations`](https://eslint.org/docs/rules/init-declarations) rule.
It adds support for TypeScript's `declare` variables.

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/key-spacing`](https://eslint.org/docs/rules/key-spacing) rule.
This version adds support for type annotations on interfaces, classes and type literals properties.
It adds support for type annotations on interfaces, classes and type literals properties.

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/keyword-spacing`](https://eslint.org/docs/rules/keyword-spacing) rule.
This version adds support for generic type parameters on function calls.
It adds support for generic type parameters on function calls.

@@ -9,4 +9,2 @@ ---

## Rule Details
This rule extends the base [`eslint/lines-around-comment`](https://eslint.org/docs/rules/lines-around-comment) rule.

@@ -13,0 +11,0 @@ It adds support for TypeScript syntax.

@@ -9,6 +9,2 @@ ---

This rule improves readability by enforcing lines between class members. It will not check empty lines before the first member and after the last member. This rule will require or disallow an empty line between class members.
## Examples
This rule extends the base [`eslint/lines-between-class-members`](https://eslint.org/docs/rules/lines-between-class-members) rule.

@@ -15,0 +11,0 @@ It adds support for ignoring overload methods in a class.

@@ -9,4 +9,2 @@ ---

## Examples
This rule extends the base [`eslint/no-array-constructor`](https://eslint.org/docs/rules/no-array-constructor) rule.

@@ -13,0 +11,0 @@ It adds support for the generically typed `Array` constructor (`new Array<Foo>()`).

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/no-dupe-class-members`](https://eslint.org/docs/rules/no-dupe-class-members) rule.
It adds support for TypeScript's method overload definitions.

@@ -13,4 +13,2 @@ ---

## Rule Details
This rule disallows duplicate union or intersection constituents.

@@ -17,0 +15,0 @@ We consider types to be duplicate if they evaluate to the same result in the type system.

@@ -9,4 +9,2 @@ ---

## Examples
This rule extends the base [`eslint/no-empty-function`](https://eslint.org/docs/rules/no-empty-function) rule.

@@ -13,0 +11,0 @@ It adds support for handling TypeScript specific code that would otherwise trigger the rule.

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/no-extra-parens`](https://eslint.org/docs/rules/no-extra-parens) rule.
It adds support for TypeScript type assertions.

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/no-extra-semi`](https://eslint.org/docs/rules/no-extra-semi) rule.
It adds support for class properties.

@@ -61,3 +61,3 @@ ---

Promise.reject('value').finally(() => {});
await Promise.reject('value').finally(() => {});
```

@@ -64,0 +64,0 @@

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/no-invalid-this`](https://eslint.org/docs/rules/no-invalid-this) rule.
It adds support for TypeScript's `this` parameters.

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/no-loop-func`](https://eslint.org/docs/rules/no-loop-func) rule.
It adds support for TypeScript types.

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/no-loss-of-precision`](https://eslint.org/docs/rules/no-loss-of-precision) rule.
It adds support for [numeric separators](https://github.com/tc39/proposal-numeric-separator).

@@ -9,4 +9,2 @@ ---

## Examples
This rule extends the base [`eslint/no-magic-numbers`](https://eslint.org/docs/rules/no-magic-numbers) rule.

@@ -13,0 +11,0 @@ It adds support for:

@@ -9,4 +9,2 @@ ---

## Examples
This rule extends the base [`eslint/no-redeclare`](https://eslint.org/docs/rules/no-redeclare) rule.

@@ -13,0 +11,0 @@ It adds support for TypeScript function overloads, and declaration merging.

@@ -9,4 +9,2 @@ ---

## Examples
This rule extends the base [`eslint/no-restricted-imports`](https://eslint.org/docs/rules/no-restricted-imports) rule.

@@ -13,0 +11,0 @@

@@ -9,4 +9,2 @@ ---

## Examples
This rule extends the base [`eslint/no-shadow`](https://eslint.org/docs/rules/no-shadow) rule.

@@ -13,0 +11,0 @@ It adds support for TypeScript's `this` parameters and global augmentation, and adds options for TypeScript features.

@@ -100,2 +100,18 @@ ---

This rule has a known edge case of triggering on conditions that were modified within function calls (as side effects).
It is due to limitations of TypeScript's type narrowing.
See [#9998](https://github.com/microsoft/TypeScript/issues/9998) for details.
We recommend upcasting the variable with a [type assertion](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions).
```ts
let condition = false as boolean;
const f = () => (condition = true);
f();
if (condition) {
}
```
## Related To

@@ -102,0 +118,0 @@

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/no-unused-expressions`](https://eslint.org/docs/rules/no-unused-expressions) rule.
It adds support for optional call expressions `x?.()`, and directive in module declarations.

@@ -9,5 +9,20 @@ ---

## Examples
This rule extends the base [`eslint/no-unused-vars`](https://eslint.org/docs/rules/no-unused-vars) rule.
It adds support for TypeScript features, such as types.
## Benefits Over TypeScript
TypeScript provides [`noUnusedLocals`](https://www.typescriptlang.org/tsconfig#noUnusedLocals) and [`noUnusedParameters`](https://www.typescriptlang.org/tsconfig#noUnusedParameters) compiler options that can report errors on unused local variables or parameters, respectively.
Those compiler options can be convenient to use if you don't want to set up ESLint and typescript-eslint.
However:
- These lint rules are more configurable than TypeScript's compiler options.
- For example, the [`varsIgnorePattern` option](https://eslint.org/docs/latest/rules/no-unused-vars#varsignorepattern) can customize what names are always allowed to be exempted. TypeScript hardcodes its exemptions to names starting with `_`.
- [ESLint can be configured](https://eslint.org/docs/latest/use/configure/rules) within lines, files, and folders. TypeScript compiler options are linked to their TSConfig file.
- Many projects configure TypeScript's reported errors to block builds more aggressively than ESLint complaints. Blocking builds on unused variables can be inconvenient.
We generally recommend using `@typescript-eslint/no-unused-vars` to flag unused locals and parameters instead of TypeScript.
:::tip
Editors such as VS Code will still generally "grey out" unused variables even if `noUnusedLocals` and `noUnusedParameters` are not enabled in a project.
:::

@@ -9,4 +9,2 @@ ---

## Examples
This rule extends the base [`eslint/no-use-before-define`](https://eslint.org/docs/rules/no-use-before-define) rule.

@@ -13,0 +11,0 @@ It adds support for `type`, `interface` and `enum` declarations.

@@ -9,4 +9,2 @@ ---

## Examples
This rule extends the base [`eslint/no-useless-constructor`](https://eslint.org/docs/rules/no-useless-constructor) rule.

@@ -13,0 +11,0 @@ It adds support for:

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/object-curly-spacing`](https://eslint.org/docs/rules/object-curly-spacing) rule.
It adds support for TypeScript's object types.

@@ -9,4 +9,2 @@ ---

## Examples
This rule extends the base [`eslint/padding-line-between-statements`](https://eslint.org/docs/rules/padding-line-between-statements) rule.

@@ -13,0 +11,0 @@ It adds support for TypeScript constructs such as `interface` and `type`.

@@ -25,3 +25,3 @@ ---

Setting this option to `true` (the default) will cause the rule to ignore any ternary expressions that could be simplified by using the nullish coalescing operator.
Setting this option to `true` will cause the rule to ignore any ternary expressions that could be simplified by using the nullish coalescing operator. This is set to `false` by default.

@@ -66,3 +66,3 @@ Incorrect code for `ignoreTernaryTests: false`, and correct code for `ignoreTernaryTests: true`:

Setting this option to `true` (the default) will cause the rule to ignore any cases that are located within a conditional test.
Setting this option to `true` will cause the rule to ignore any cases that are located within a conditional test. This is set to `false` by default.

@@ -109,3 +109,3 @@ Generally expressions within conditional tests intentionally use the falsy fallthrough behavior of the logical or operator, meaning that fixing the operator to the nullish coalesce operator could cause bugs.

Setting this option to `true` (the default) will cause the rule to ignore any logical or expressions that are part of a mixed logical expression (with `&&`).
Setting this option to `true` will cause the rule to ignore any logical or expressions that are part of a mixed logical expression (with `&&`). This is set to `false` by default.

@@ -171,2 +171,4 @@ Generally expressions within mixed logical expressions intentionally use the falsy fallthrough behavior of the logical or operator, meaning that fixing the operator to the nullish coalesce operator could cause bugs.

Also, if you would like to ignore all primitives types, you can set `ignorePrimitives: true`. It would be equivalent to `ignorePrimitives: { string: true, number: true, bigint: true, boolean: true }`.
## When Not To Use It

@@ -173,0 +175,0 @@

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/quotes`](https://eslint.org/docs/rules/quotes) rule.
It adds support for TypeScript features which allow quoted names, but not backtick quoted names.

@@ -9,7 +9,7 @@ ---

## Examples
This rule extends the base [`eslint/require-await`](https://eslint.org/docs/rules/require-await) rule.
It uses type information to add support for `async` functions that return a `Promise`.
## Examples
Examples of **correct** code for this rule:

@@ -16,0 +16,0 @@

@@ -11,7 +11,7 @@ ---

## Examples
This rule builds on top of the [`eslint/no-return-await`](https://eslint.org/docs/rules/no-return-await) rule.
It expands upon the base rule to add support for optionally requiring `return await` in certain cases.
The extended rule is named `return-await` instead of `no-return-await` because the extended rule can enforce the positive or the negative. Additionally, while the core rule is now deprecated, the extended rule is still useful in many contexts.
## Options

@@ -18,0 +18,0 @@

@@ -9,6 +9,2 @@ ---

This rule enforces consistent use of semicolons after statements.
## Examples
This rule extends the base [`eslint/semi`](https://eslint.org/docs/rules/semi) rule.

@@ -15,0 +11,0 @@ It adds support for TypeScript features that require semicolons.

@@ -9,4 +9,2 @@ ---

## Examples
This rule extends the base [`eslint/space-before-blocks`](https://eslint.org/docs/rules/space-before-blocks) rule.

@@ -13,0 +11,0 @@ It adds support for interfaces and enums.

@@ -9,5 +9,3 @@ ---

## Examples
This rule extends the base [`eslint/space-before-function-paren`](https://eslint.org/docs/rules/space-before-function-paren) rule.
It adds support for generic type parameters on function calls.

@@ -0,4 +1,8 @@

---
description: '<Description from rule metadata here>'
---
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/your-rule-name** for documentation.
> See **https://typescript-eslint.io/rules/RULE_NAME_REPLACEME** for documentation.

@@ -5,0 +9,0 @@ ## Examples

{
"name": "@typescript-eslint/eslint-plugin",
"version": "6.1.0",
"version": "6.4.0",
"description": "TypeScript plugin for ESLint",

@@ -54,3 +54,3 @@ "files": [

"lint": "nx lint",
"test": "jest --coverage",
"test": "jest --coverage --logHeapUsage",
"test-single": "jest --no-coverage",

@@ -61,6 +61,6 @@ "typecheck": "tsc -p tsconfig.json --noEmit"

"@eslint-community/regexpp": "^4.5.1",
"@typescript-eslint/scope-manager": "6.1.0",
"@typescript-eslint/type-utils": "6.1.0",
"@typescript-eslint/utils": "6.1.0",
"@typescript-eslint/visitor-keys": "6.1.0",
"@typescript-eslint/scope-manager": "6.4.0",
"@typescript-eslint/type-utils": "6.4.0",
"@typescript-eslint/utils": "6.4.0",
"@typescript-eslint/visitor-keys": "6.4.0",
"debug": "^4.3.4",

@@ -70,3 +70,2 @@ "graphemer": "^1.4.0",

"natural-compare": "^1.4.0",
"natural-compare-lite": "^1.4.0",
"semver": "^7.5.4",

@@ -80,4 +79,4 @@ "ts-api-utils": "^1.0.1"

"@types/prettier": "*",
"@typescript-eslint/rule-schema-to-typescript-types": "6.1.0",
"@typescript-eslint/rule-tester": "6.1.0",
"@typescript-eslint/rule-schema-to-typescript-types": "6.4.0",
"@typescript-eslint/rule-tester": "6.4.0",
"ajv": "^6.12.6",

@@ -107,3 +106,3 @@ "chalk": "^5.3.0",

},
"gitHead": "d98f1e811a6a06128a86f10824b6005984dc8265"
"gitHead": "14bea42e4864c72d28f502e0d15e675fe8bd729a"
}

@@ -40,6 +40,7 @@ /*

export interface TypeScriptESLintRules {
[ruleName: string]: RuleModule<string, unknown[]>;
}
export type TypeScriptESLintRules = Record<
string,
RuleModule<string, unknown[]>
>;
declare const rules: TypeScriptESLintRules;
export = rules;
export default rules;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc