Socket
Socket
Sign inDemoInstall

@typescript-eslint/eslint-plugin

Package Overview
Dependencies
Maintainers
2
Versions
3732
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.4.0 to 6.15.0

dist/rules/max-params.js

6

dist/configs/all.js

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

'@typescript-eslint/lines-between-class-members': 'error',
'max-params': 'off',
'@typescript-eslint/max-params': 'error',
'@typescript-eslint/member-delimiter-style': 'error',

@@ -127,2 +129,3 @@ '@typescript-eslint/member-ordering': 'error',

'@typescript-eslint/no-unsafe-return': 'error',
'@typescript-eslint/no-unsafe-unary-minus': 'error',
'no-unused-expressions': 'off',

@@ -137,2 +140,3 @@ '@typescript-eslint/no-unused-expressions': 'error',

'@typescript-eslint/no-useless-empty-export': 'error',
'@typescript-eslint/no-useless-template-literals': 'error',
'@typescript-eslint/no-var-requires': 'error',

@@ -146,2 +150,4 @@ '@typescript-eslint/non-nullable-type-assertion-style': 'error',

'@typescript-eslint/prefer-as-const': 'error',
'prefer-destructuring': 'off',
'@typescript-eslint/prefer-destructuring': 'error',
'@typescript-eslint/prefer-enum-initializers': 'error',

@@ -148,0 +154,0 @@ '@typescript-eslint/prefer-for-of': 'error',

3

dist/configs/disable-type-checked.js

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

'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-unary-minus': 'off',
'@typescript-eslint/no-useless-template-literals': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/prefer-destructuring': 'off',
'@typescript-eslint/prefer-includes': 'off',

@@ -40,0 +43,0 @@ '@typescript-eslint/prefer-nullish-coalescing': 'off',

38

dist/configs/eslint-recommended.js

@@ -7,21 +7,21 @@ "use strict";

rules: {
'constructor-super': 'off',
'getter-return': 'off',
'no-const-assign': 'off',
'no-dupe-args': 'off',
'no-dupe-class-members': 'off',
'no-dupe-keys': 'off',
'no-func-assign': 'off',
'no-import-assign': 'off',
'no-new-symbol': 'off',
'no-obj-calls': 'off',
'no-redeclare': 'off',
'no-setter-return': 'off',
'no-this-before-super': 'off',
'no-undef': 'off',
'no-unreachable': 'off',
'no-unsafe-negation': 'off',
'no-var': 'error',
'prefer-const': 'error',
'prefer-rest-params': 'error',
'constructor-super': 'off', // ts(2335) & ts(2377)
'getter-return': 'off', // ts(2378)
'no-const-assign': 'off', // ts(2588)
'no-dupe-args': 'off', // ts(2300)
'no-dupe-class-members': 'off', // ts(2393) & ts(2300)
'no-dupe-keys': 'off', // ts(1117)
'no-func-assign': 'off', // ts(2630)
'no-import-assign': 'off', // ts(2632) & ts(2540)
'no-new-symbol': 'off', // ts(7009)
'no-obj-calls': 'off', // ts(2349)
'no-redeclare': 'off', // ts(2451)
'no-setter-return': 'off', // ts(2408)
'no-this-before-super': 'off', // ts(2376) & ts(17009)
'no-undef': 'off', // ts(2304) & ts(2552)
'no-unreachable': 'off', // ts(7027)
'no-unsafe-negation': 'off', // ts(2365) & ts(2322) & ts(2358)
'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more
'prefer-const': 'error', // ts provides better types with const
'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply

@@ -28,0 +28,0 @@ },

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

'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-useless-template-literals': 'error',
'@typescript-eslint/no-var-requires': 'error',

@@ -61,0 +62,0 @@ '@typescript-eslint/prefer-as-const': 'error',

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'adjacent-overload-signatures',

@@ -43,3 +21,3 @@ meta: {

create(context) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
/**

@@ -51,5 +29,2 @@ * Gets the name and attribute of the member being processed.

function getMemberMethod(member) {
if (!member) {
return null;
}
const isStatic = 'static' in member && !!member.static;

@@ -76,3 +51,3 @@ switch (member.type) {

callSignature: false,
type: util.MemberNameType.Normal,
type: util_1.MemberNameType.Normal,
};

@@ -82,3 +57,3 @@ }

return {
...util.getNameFromMember(member, sourceCode),
...(0, util_1.getNameFromMember)(member, sourceCode),
static: isStatic,

@@ -92,3 +67,3 @@ callSignature: false,

callSignature: true,
type: util.MemberNameType.Normal,
type: util_1.MemberNameType.Normal,
};

@@ -100,7 +75,7 @@ case utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration:

callSignature: false,
type: util.MemberNameType.Normal,
type: util_1.MemberNameType.Normal,
};
case utils_1.AST_NODE_TYPES.MethodDefinition:
return {
...util.getNameFromMember(member, sourceCode),
...(0, util_1.getNameFromMember)(member, sourceCode),
static: isStatic,

@@ -137,27 +112,25 @@ callSignature: false,

const members = getMembers(node);
if (members) {
let lastMethod = null;
const seenMethods = [];
members.forEach(member => {
const method = getMemberMethod(member);
if (method == null) {
lastMethod = null;
return;
}
const index = seenMethods.findIndex(seenMethod => isSameMethod(method, seenMethod));
if (index > -1 && !isSameMethod(method, lastMethod)) {
context.report({
node: member,
messageId: 'adjacentSignature',
data: {
name: `${method.static ? 'static ' : ''}${method.name}`,
},
});
}
else if (index === -1) {
seenMethods.push(method);
}
lastMethod = method;
});
}
let lastMethod = null;
const seenMethods = [];
members.forEach(member => {
const method = getMemberMethod(member);
if (method == null) {
lastMethod = null;
return;
}
const index = seenMethods.findIndex(seenMethod => isSameMethod(method, seenMethod));
if (index > -1 && !isSameMethod(method, lastMethod)) {
context.report({
node: member,
messageId: 'adjacentSignature',
data: {
name: `${method.static ? 'static ' : ''}${method.name}`,
},
});
}
else if (index === -1) {
seenMethods.push(method);
}
lastMethod = method;
});
}

@@ -164,0 +137,0 @@ return {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
/**

@@ -52,4 +30,3 @@ * Check whatever node can be considered as simple

case utils_1.AST_NODE_TYPES.TSTypeReference:
if (node.typeName &&
node.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
if (node.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&
node.typeName.name === 'Array') {

@@ -95,3 +72,3 @@ if (!node.typeArguments) {

}
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'array-type',

@@ -140,3 +117,3 @@ meta: {

create(context, [options]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const defaultOption = options.default;

@@ -148,3 +125,3 @@ const readonlyOption = options.readonly ?? defaultOption;

function getMessageType(node) {
if (node && isSimpleType(node)) {
if (isSimpleType(node)) {
return sourceCode.getText(node);

@@ -226,4 +203,4 @@ }

const parentParens = readonlyPrefix &&
node.parent?.type === utils_1.AST_NODE_TYPES.TSArrayType &&
!util.isParenthesized(node.parent.elementType, sourceCode);
node.parent.type === utils_1.AST_NODE_TYPES.TSArrayType &&
!(0, util_1.isParenthesized)(node.parent.elementType, sourceCode);
const start = `${parentParens ? '(' : ''}${readonlyPrefix}${typeParens ? '(' : ''}`;

@@ -230,0 +207,0 @@ const end = `${typeParens ? ')' : ''}[]${parentParens ? ')' : ''}`;

@@ -26,5 +26,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'await-thenable',

@@ -37,4 +38,6 @@ meta: {

},
hasSuggestions: true,
messages: {
await: 'Unexpected `await` of a non-Promise (non-"Thenable") value.',
removeAwait: 'Remove unnecessary `await`.',
},

@@ -46,3 +49,3 @@ schema: [],

create(context) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();

@@ -52,3 +55,3 @@ return {

const type = services.getTypeAtLocation(node.argument);
if (util.isTypeAnyType(type) || util.isTypeUnknownType(type)) {
if ((0, util_1.isTypeAnyType)(type) || (0, util_1.isTypeUnknownType)(type)) {
return;

@@ -61,2 +64,12 @@ }

node,
suggest: [
{
messageId: 'removeAwait',
fix(fixer) {
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const awaitKeyword = (0, util_1.nullThrows)(sourceCode.getFirstToken(node, util_1.isAwaitKeyword), util_1.NullThrowsReasons.MissingToken('await', 'await expression'));
return fixer.remove(awaitKeyword);
},
},
],
});

@@ -63,0 +76,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultMinimumDescriptionLength = void 0;
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.defaultMinimumDescriptionLength = 3;
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'ban-ts-comment',

@@ -40,5 +18,8 @@ meta: {

tsDirectiveComment: 'Do not use "@ts-{{directive}}" because it alters compilation errors.',
tsIgnoreInsteadOfExpectError: 'Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free.',
tsDirectiveCommentRequiresDescription: 'Include a description after the "@ts-{{directive}}" directive to explain why the @ts-{{directive}} is necessary. The description must be {{minimumDescriptionLength}} characters or longer.',
tsDirectiveCommentDescriptionNotMatchPattern: 'The description for the "@ts-{{directive}}" directive must match the {{format}} format.',
replaceTsIgnoreWithTsExpectError: 'Replace "@ts-ignore" with "@ts-expect-error".',
},
hasSuggestions: true,
schema: [

@@ -98,3 +79,3 @@ {

const commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@ts-(?<directive>expect-error|ignore|check|nocheck)(?<description>.*)/;
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const descriptionFormats = new Map();

@@ -127,7 +108,27 @@ for (const directive of [

if (option === true) {
context.report({
data: { directive },
node: comment,
messageId: 'tsDirectiveComment',
});
if (directive === 'ignore') {
// Special case to suggest @ts-expect-error instead of @ts-ignore
context.report({
node: comment,
messageId: 'tsIgnoreInsteadOfExpectError',
suggest: [
{
messageId: 'replaceTsIgnoreWithTsExpectError',
fix(fixer) {
const commentText = comment.value.replace(/@ts-ignore/, '@ts-expect-error');
return fixer.replaceText(comment, comment.type === utils_1.AST_TOKEN_TYPES.Line
? `//${commentText}`
: `/*${commentText}*/`);
},
},
],
});
}
else {
context.report({
data: { directive },
node: comment,
messageId: 'tsDirectiveComment',
});
}
}

@@ -138,4 +139,3 @@ if (option === 'allow-with-description' ||

const format = descriptionFormats.get(fullDirective);
if (util.getStringLength(description.trim()) <
minimumDescriptionLength) {
if ((0, util_1.getStringLength)(description.trim()) < minimumDescriptionLength) {
context.report({

@@ -142,0 +142,0 @@ data: { directive, minimumDescriptionLength },

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
// tslint regex

@@ -34,3 +12,3 @@ // https://github.com/palantir/tslint/blob/95d9d958833fd9dc0002d18cbe34db20d0fbf437/src/enableDisableRules.ts#L32

: ['/*', text.trim(), '*/'].join(' ');
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'ban-tslint-comment',

@@ -51,3 +29,3 @@ meta: {

create: context => {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
return {

@@ -54,0 +32,0 @@ Program() {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TYPE_KEYWORDS = void 0;
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
function removeSpaces(str) {

@@ -115,3 +93,3 @@ return str.replace(/\s/g, '');

};
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'ban-types',

@@ -199,3 +177,3 @@ meta: {

const bannedTypes = new Map(Object.entries(types).map(([type, data]) => [removeSpaces(type), data]));
function checkBannedTypes(typeNode, name = stringifyNode(typeNode, context.getSourceCode())) {
function checkBannedTypes(typeNode, name = stringifyNode(typeNode, (0, eslint_utils_1.getSourceCode)(context))) {
const bannedType = bannedTypes.get(name);

@@ -230,3 +208,3 @@ if (bannedType === undefined || bannedType === false) {

}
const keywordSelectors = util.objectReduceKey(exports.TYPE_KEYWORDS, (acc, keyword) => {
const keywordSelectors = (0, util_1.objectReduceKey)(exports.TYPE_KEYWORDS, (acc, keyword) => {
if (bannedTypes.has(keyword)) {

@@ -233,0 +211,0 @@ acc[exports.TYPE_KEYWORDS[keyword]] = (node) => checkBannedTypes(node, keyword);

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('block-spacing');
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'block-spacing',

@@ -45,3 +23,3 @@ meta: {

create(context, [whenToApplyOption]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const baseRules = baseRule.create(context);

@@ -73,3 +51,3 @@ const always = whenToApplyOption !== 'never';

function isValid(left, right) {
return (!util.isTokenOnSameLine(left, right) ||
return (!(0, util_1.isTokenOnSameLine)(left, right) ||
sourceCode.isSpaceBetween(left, right) === always);

@@ -91,4 +69,3 @@ }

// Skip if the node is invalid or empty.
if (openBrace.type !== utils_1.AST_TOKEN_TYPES.Punctuator ||
openBrace.value !== '{' ||
if (openBrace.value !== '{' ||
closeBrace.type !== utils_1.AST_TOKEN_TYPES.Punctuator ||

@@ -95,0 +72,0 @@ closeBrace.value !== '}' ||

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");

@@ -25,3 +26,3 @@ const getESLintCoreRule_1 = require("../util/getESLintCoreRule");

const isAllmanStyle = style === 'allman';
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const rules = baseRule.create(context);

@@ -28,0 +29,0 @@ /**

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const printNodeModifiers = (node, final) => `${node.accessibility ?? ''}${node.static ? ' static' : ''} ${final} `.trimStart();

@@ -39,3 +17,3 @@ const isSupportedLiteral = (node) => {

};
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'class-literal-property-style',

@@ -87,3 +65,3 @@ meta: {

fix(fixer) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const name = sourceCode.getText(node.key);

@@ -117,3 +95,3 @@ let text = '';

fix(fixer) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const name = sourceCode.getText(node.key);

@@ -120,0 +98,0 @@ let text = '';

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'class-methods-use-this',

@@ -60,3 +38,13 @@ meta: {

ignoreClassesThatImplementAnInterface: {
type: 'boolean',
oneOf: [
{
type: 'boolean',
description: 'Ignore all classes that implement an interface',
},
{
type: 'string',
enum: ['public-fields'],
description: 'Ignore only the public fields of classes that implement an interface',
},
],
description: 'Ignore classes that specifically implement some interface',

@@ -83,3 +71,3 @@ },

let stack;
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
function pushContext(member) {

@@ -120,2 +108,8 @@ if (member?.parent.type === utils_1.AST_NODE_TYPES.ClassBody) {

}
function isPublicField(accessibility) {
if (!accessibility || accessibility === 'public') {
return true;
}
return false;
}
/**

@@ -137,3 +131,3 @@ * Check if the node is an instance method not excluded by config

const name = node.key.type === utils_1.AST_NODE_TYPES.Literal
? util.getStaticStringValue(node.key)
? (0, util_1.getStaticStringValue)(node.key)
: node.key.name || '';

@@ -150,7 +144,9 @@ return !exceptMethods.has(hashIfNeeded + (name ?? ''));

if (stackContext?.member == null ||
stackContext.class == null ||
stackContext.usesThis ||
(ignoreOverrideMethods && stackContext.member.override) ||
(ignoreClassesThatImplementAnInterface &&
stackContext.class.implements != null)) {
(ignoreClassesThatImplementAnInterface === true &&
stackContext.class.implements.length > 0) ||
(ignoreClassesThatImplementAnInterface === 'public-fields' &&
stackContext.class.implements.length > 0 &&
isPublicField(stackContext.member.accessibility))) {
return;

@@ -161,6 +157,6 @@ }

node,
loc: util.getFunctionHeadLoc(node, sourceCode),
loc: (0, util_1.getFunctionHeadLoc)(node, sourceCode),
messageId: 'missingThis',
data: {
name: util.getFunctionNameWithKind(node),
name: (0, util_1.getFunctionNameWithKind)(node),
},

@@ -167,0 +163,0 @@ });

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");

@@ -51,3 +29,3 @@ const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('comma-dangle');

}
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'comma-dangle',

@@ -104,3 +82,3 @@ meta: {

const rules = baseRule.create(context);
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const normalizedOptions = normalizeOptions(options);

@@ -144,3 +122,3 @@ const predicate = {

const trailing = getTrailingToken(node);
if (last && trailing && util.isCommaToken(trailing)) {
if (last && trailing && (0, util_1.isCommaToken)(trailing)) {
context.report({

@@ -158,3 +136,3 @@ node,

const trailing = getTrailingToken(node);
if (last && trailing && !util.isCommaToken(trailing)) {
if (last && trailing && !(0, util_1.isCommaToken)(trailing)) {
context.report({

@@ -161,0 +139,0 @@ node,

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");

@@ -42,3 +43,3 @@ exports.default = (0, util_1.createRule)({

create(context, [{ before: spaceBefore, after: spaceAfter }]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const tokensAndComments = sourceCode.tokensAndComments;

@@ -139,3 +140,3 @@ const ignoredTokens = new Set();

const prevToken = tokensAndComments[i - 1];
const nextToken = tokensAndComments[i + 1];
const nextToken = tokensAndComments.at(i + 1);
validateCommaSpacing(token, (0, util_1.isCommaToken)(prevToken) || ignoredTokens.has(token)

@@ -145,3 +146,3 @@ ? null

? null
: nextToken);
: nextToken ?? null);
});

@@ -148,0 +149,0 @@ },

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");

@@ -27,3 +28,3 @@ exports.default = (0, util_1.createRule)({

create(context, [mode]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
return {

@@ -84,24 +85,22 @@ 'VariableDeclarator,PropertyDefinition,:matches(FunctionDeclaration,FunctionExpression) > AssignmentPattern'(node) {

}
if (mode === 'constructor') {
if (lhs?.typeArguments && !rhs.typeArguments) {
const hasParens = sourceCode.getTokenAfter(rhs.callee)?.value === '(';
const extraComments = new Set(sourceCode.getCommentsInside(lhs.parent));
sourceCode
.getCommentsInside(lhs.typeArguments)
.forEach(c => extraComments.delete(c));
context.report({
node,
messageId: 'preferConstructor',
*fix(fixer) {
yield fixer.remove(lhs.parent);
for (const comment of extraComments) {
yield fixer.insertTextAfter(rhs.callee, sourceCode.getText(comment));
}
yield fixer.insertTextAfter(rhs.callee, sourceCode.getText(lhs.typeArguments));
if (!hasParens) {
yield fixer.insertTextAfter(rhs.callee, '()');
}
},
});
}
if (lhs?.typeArguments && !rhs.typeArguments) {
const hasParens = sourceCode.getTokenAfter(rhs.callee)?.value === '(';
const extraComments = new Set(sourceCode.getCommentsInside(lhs.parent));
sourceCode
.getCommentsInside(lhs.typeArguments)
.forEach(c => extraComments.delete(c));
context.report({
node,
messageId: 'preferConstructor',
*fix(fixer) {
yield fixer.remove(lhs.parent);
for (const comment of extraComments) {
yield fixer.insertTextAfter(rhs.callee, sourceCode.getText(comment));
}
yield fixer.insertTextAfter(rhs.callee, sourceCode.getText(lhs.typeArguments));
if (!hasParens) {
yield fixer.insertTextAfter(rhs.callee, '()');
}
},
});
}

@@ -108,0 +107,0 @@ },

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");

@@ -27,3 +28,3 @@ exports.default = (0, util_1.createRule)({

create(context, [mode]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
function checkMembers(members, node, parentId, prefix, postfix, safeFix = true) {

@@ -37,9 +38,6 @@ if (members.length !== 1) {

}
const [parameter] = member.parameters;
if (!parameter) {
const parameter = member.parameters.at(0);
if (parameter?.type !== utils_1.AST_NODE_TYPES.Identifier) {
return;
}
if (parameter.type !== utils_1.AST_NODE_TYPES.Identifier) {
return;
}
const keyType = parameter.typeAnnotation;

@@ -54,3 +52,3 @@ if (!keyType) {

if (parentId) {
const scope = context.getScope();
const scope = (0, eslint_utils_1.getScope)(context);
const superVar = utils_1.ASTUtils.findVariable(scope, parentId.name);

@@ -113,3 +111,3 @@ if (superVar) {

let genericTypes = '';
if (node.typeParameters?.params?.length) {
if (node.typeParameters?.params.length) {
genericTypes = `<${node.typeParameters.params

@@ -119,3 +117,3 @@ .map(p => sourceCode.getText(p))

}
checkMembers(node.body.body, node, node.id, `type ${node.id.name}${genericTypes} = `, ';', !node.extends?.length);
checkMembers(node.body.body, node, node.id, `type ${node.id.name}${genericTypes} = `, ';', !node.extends.length);
},

@@ -122,0 +120,0 @@ }),

@@ -27,4 +27,7 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const ts = __importStar(require("typescript"));
const util_1 = require("../util");
const getWrappedCode_1 = require("../util/getWrappedCode");
exports.default = (0, util_1.createRule)({
name: 'consistent-type-assertions',

@@ -87,3 +90,4 @@ meta: {

create(context, [options]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const parserServices = (0, util_1.getParserServices)(context, true);
function isConst(node) {

@@ -100,5 +104,5 @@ if (node.type !== utils_1.AST_NODE_TYPES.TSTypeReference) {

let afterCount = 0;
if (util.isParenthesized(node, sourceCode)) {
const bodyOpeningParen = sourceCode.getTokenBefore(node, util.isOpeningParenToken);
const bodyClosingParen = sourceCode.getTokenAfter(node, util.isClosingParenToken);
if ((0, util_1.isParenthesized)(node, sourceCode)) {
const bodyOpeningParen = sourceCode.getTokenBefore(node, util_1.isOpeningParenToken);
const bodyClosingParen = sourceCode.getTokenAfter(node, util_1.isClosingParenToken);
beforeCount = node.range[0] - bodyOpeningParen.range[0];

@@ -122,6 +126,22 @@ afterCount = bodyClosingParen.range[1] - node.range[1];

fix: messageId === 'as'
? (fixer) => [
fixer.replaceText(node, getTextWithParentheses(node.expression)),
fixer.insertTextAfter(node, ` as ${getTextWithParentheses(node.typeAnnotation)}`),
]
? (fixer) => {
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
/**
* AsExpression has lower precedence than TypeAssertionExpression,
* so we don't need to wrap expression and typeAnnotation in parens.
*/
const expressionCode = sourceCode.getText(node.expression);
const typeAnnotationCode = sourceCode.getText(node.typeAnnotation);
const asPrecedence = (0, util_1.getOperatorPrecedence)(ts.SyntaxKind.AsExpression, ts.SyntaxKind.Unknown);
const parentPrecedence = (0, util_1.getOperatorPrecedence)(tsNode.parent.kind, ts.isBinaryExpression(tsNode.parent)
? tsNode.parent.operatorToken.kind
: ts.SyntaxKind.Unknown, ts.isNewExpression(tsNode.parent)
? tsNode.parent.arguments != null &&
tsNode.parent.arguments.length > 0
: undefined);
const text = `${expressionCode} as ${typeAnnotationCode}`;
return fixer.replaceText(node, (0, util_1.isParenthesized)(node, sourceCode)
? text
: (0, getWrappedCode_1.getWrappedCode)(text, asPrecedence, parentPrecedence));
}
: undefined,

@@ -159,6 +179,5 @@ });

}
if (checkType(node.typeAnnotation) &&
node.expression.type === utils_1.AST_NODE_TYPES.ObjectExpression) {
if (checkType(node.typeAnnotation)) {
const suggest = [];
if (node.parent?.type === utils_1.AST_NODE_TYPES.VariableDeclarator &&
if (node.parent.type === utils_1.AST_NODE_TYPES.VariableDeclarator &&
!node.parent.id.typeAnnotation) {

@@ -180,5 +199,3 @@ const { parent } = node;

fixer.replaceText(node, getTextWithParentheses(node.expression)),
fixer.insertTextAfter(node, ` satisfies ${context
.getSourceCode()
.getText(node.typeAnnotation)}`),
fixer.insertTextAfter(node, ` satisfies ${(0, eslint_utils_1.getSourceCode)(context).getText(node.typeAnnotation)}`),
],

@@ -185,0 +202,0 @@ });

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'consistent-type-definitions',

@@ -50,3 +28,3 @@ meta: {

create(context, [option]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
/**

@@ -57,5 +35,3 @@ * Iterates from the highest parent to the currently traversed node

function isCurrentlyTraversedNodeWithinModuleDeclaration() {
return context
.getAncestors()
.some(node => node.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration &&
return (0, eslint_utils_1.getAncestors)(context).some(node => node.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration &&
node.declare &&

@@ -101,9 +77,7 @@ node.global);

}
if (node.extends) {
node.extends.forEach(heritage => {
const typeIdentifier = sourceCode.getText(heritage);
fixes.push(fixer.insertTextAfter(node.body, ` & ${typeIdentifier}`));
});
}
if (node.parent?.type === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {
node.extends.forEach(heritage => {
const typeIdentifier = sourceCode.getText(heritage);
fixes.push(fixer.insertTextAfter(node.body, ` & ${typeIdentifier}`));
});
if (node.parent.type === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {
fixes.push(fixer.removeRange([node.parent.range[0], node.range[0]]), fixer.insertTextAfter(node.body, `\nexport default ${node.id.name}`));

@@ -110,0 +84,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const typescript_1 = require("typescript");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'consistent-type-exports',

@@ -61,5 +39,5 @@ meta: {

create(context, [{ fixMixedExportsWithInlineTypeSpecifier }]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const sourceExportsMap = {};
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
/**

@@ -75,5 +53,8 @@ * Helper for identifying if an export specifier resolves to a

const symbol = services.getSymbolAtLocation(specifier.exported);
if (!symbol) {
return undefined;
}
const aliasedSymbol = checker.getAliasedSymbol(symbol);
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
if (!aliasedSymbol || aliasedSymbol.escapedName === 'unknown') {
if (aliasedSymbol.escapedName === 'unknown') {
return undefined;

@@ -87,2 +68,3 @@ }

const source = getSourceFromExport(node) ?? 'undefined';
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const sourceExports = (sourceExportsMap[source] ||= {

@@ -157,3 +139,3 @@ source,

// We have both type and value violations.
const allExportNames = report.typeBasedSpecifiers.map(specifier => `${specifier.local.name}`);
const allExportNames = report.typeBasedSpecifiers.map(specifier => specifier.local.name);
if (allExportNames.length === 1) {

@@ -176,3 +158,3 @@ const exportNames = allExportNames[0];

else {
const exportNames = util.formatWordList(allExportNames);
const exportNames = (0, util_1.formatWordList)(allExportNames);
context.report({

@@ -207,8 +189,8 @@ node: report.node,

function* fixExportInsertType(fixer, sourceCode, node) {
const exportToken = util.nullThrows(sourceCode.getFirstToken(node), util.NullThrowsReasons.MissingToken('export', node.type));
const exportToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(node), util_1.NullThrowsReasons.MissingToken('export', node.type));
yield fixer.insertTextAfter(exportToken, ' type');
for (const specifier of node.specifiers) {
if (specifier.exportKind === 'type') {
const kindToken = util.nullThrows(sourceCode.getFirstToken(specifier), util.NullThrowsReasons.MissingToken('export', specifier.type));
const firstTokenAfter = util.nullThrows(sourceCode.getTokenAfter(kindToken, {
const kindToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(specifier), util_1.NullThrowsReasons.MissingToken('export', specifier.type));
const firstTokenAfter = (0, util_1.nullThrows)(sourceCode.getTokenAfter(kindToken, {
includeComments: true,

@@ -230,3 +212,3 @@ }), 'Missing token following the export kind.');

const specifierNames = typeSpecifiers.map(getSpecifierText).join(', ');
const exportToken = util.nullThrows(sourceCode.getFirstToken(node), util.NullThrowsReasons.MissingToken('export', node.type));
const exportToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(node), util_1.NullThrowsReasons.MissingToken('export', node.type));
// Filter the bad exports from the current line.

@@ -236,4 +218,4 @@ const filteredSpecifierNames = valueSpecifiers

.join(', ');
const openToken = util.nullThrows(sourceCode.getFirstToken(node, util.isOpeningBraceToken), util.NullThrowsReasons.MissingToken('{', node.type));
const closeToken = util.nullThrows(sourceCode.getLastToken(node, util.isClosingBraceToken), util.NullThrowsReasons.MissingToken('}', node.type));
const openToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(node, util_1.isOpeningBraceToken), util_1.NullThrowsReasons.MissingToken('{', node.type));
const closeToken = (0, util_1.nullThrows)(sourceCode.getLastToken(node, util_1.isClosingBraceToken), util_1.NullThrowsReasons.MissingToken('}', node.type));
// Remove exports from the current line which we're going to re-insert.

@@ -240,0 +222,0 @@ yield fixer.replaceTextRange([openToken.range[1], closeToken.range[0]], ` ${filteredSpecifierNames} `);

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'consistent-type-imports',

@@ -76,3 +54,3 @@ meta: {

const fixStyle = option.fixStyle ?? 'separate-type-imports';
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const sourceImportsMap = {};

@@ -86,10 +64,11 @@ return {

// sourceImports is the object containing all the specifics for a particular import source, type or value
const sourceImports = sourceImportsMap[source] ??
(sourceImportsMap[source] = {
source,
reportValueImports: [],
typeOnlyNamedImport: null,
valueOnlyNamedImport: null,
valueImport: null, // if only value imports
});
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
sourceImportsMap[source] ??= {
source,
reportValueImports: [], // if there is a mismatch where type importKind but value specifiers
typeOnlyNamedImport: null, // if only type imports
valueOnlyNamedImport: null, // if only value imports with named specifiers
valueImport: null, // if only value imports
};
const sourceImports = sourceImportsMap[source];
if (node.importKind === 'type') {

@@ -123,3 +102,3 @@ if (!sourceImports.typeOnlyNamedImport &&

}
const [variable] = context.getDeclaredVariables(specifier);
const [variable] = (0, eslint_utils_1.getDeclaredVariables)(context, specifier);
if (variable.references.length === 0) {

@@ -135,5 +114,5 @@ unusedSpecifiers.push(specifier);

*/
if (ref.identifier.parent?.type ===
if (ref.identifier.parent.type ===
utils_1.AST_NODE_TYPES.ExportSpecifier ||
ref.identifier.parent?.type ===
ref.identifier.parent.type ===
utils_1.AST_NODE_TYPES.ExportDefaultDeclaration) {

@@ -214,9 +193,17 @@ if (ref.isValueReference && ref.isTypeReference) {

report.node.importKind !== 'type') {
context.report({
node: report.node,
messageId: 'typeOverValue',
*fix(fixer) {
yield* fixToTypeImportDeclaration(fixer, report, sourceImports);
},
});
/** checks if import has type assertions
* ```
* import * as type from 'mod' assert { type: 'json' };
* ```
* https://github.com/typescript-eslint/typescript-eslint/issues/7527
*/
if (report.node.attributes.length === 0) {
context.report({
node: report.node,
messageId: 'typeOverValue',
*fix(fixer) {
yield* fixToTypeImportDeclaration(fixer, report, sourceImports);
},
});
}
}

@@ -231,3 +218,3 @@ else {

const message = (() => {
const typeImports = util.formatWordList(importNames);
const typeImports = (0, util_1.formatWordList)(importNames);
if (importNames.length === 1) {

@@ -335,5 +322,5 @@ if (isTypeImport) {

// import DefType, {Type1, Type2} from 'foo'
const openingBraceToken = util.nullThrows(sourceCode.getTokenBefore(subsetNamedSpecifiers[0], util.isOpeningBraceToken), util.NullThrowsReasons.MissingToken('{', node.type));
const commaToken = util.nullThrows(sourceCode.getTokenBefore(openingBraceToken, util.isCommaToken), util.NullThrowsReasons.MissingToken(',', node.type));
const closingBraceToken = util.nullThrows(sourceCode.getFirstTokenBetween(openingBraceToken, node.source, util.isClosingBraceToken), util.NullThrowsReasons.MissingToken('}', node.type));
const openingBraceToken = (0, util_1.nullThrows)(sourceCode.getTokenBefore(subsetNamedSpecifiers[0], util_1.isOpeningBraceToken), util_1.NullThrowsReasons.MissingToken('{', node.type));
const commaToken = (0, util_1.nullThrows)(sourceCode.getTokenBefore(openingBraceToken, util_1.isCommaToken), util_1.NullThrowsReasons.MissingToken(',', node.type));
const closingBraceToken = (0, util_1.nullThrows)(sourceCode.getFirstTokenBetween(openingBraceToken, node.source, util_1.isClosingBraceToken), util_1.NullThrowsReasons.MissingToken('}', node.type));
// import DefType, {...} from 'foo'

@@ -380,3 +367,3 @@ // ^^^^^^^ remove

textRange[0] = before.range[1];
if (util.isCommaToken(before)) {
if ((0, util_1.isCommaToken)(before)) {
removeRange[0] = before.range[0];

@@ -392,3 +379,3 @@ }

if (isFirst || isLast) {
if (util.isCommaToken(after)) {
if ((0, util_1.isCommaToken)(after)) {
removeRange[1] = after.range[1];

@@ -409,5 +396,5 @@ }

function fixInsertNamedSpecifiersInNamedSpecifierList(fixer, target, insertText) {
const closingBraceToken = util.nullThrows(sourceCode.getFirstTokenBetween(sourceCode.getFirstToken(target), target.source, util.isClosingBraceToken), util.NullThrowsReasons.MissingToken('}', target.type));
const closingBraceToken = (0, util_1.nullThrows)(sourceCode.getFirstTokenBetween(sourceCode.getFirstToken(target), target.source, util_1.isClosingBraceToken), util_1.NullThrowsReasons.MissingToken('}', target.type));
const before = sourceCode.getTokenBefore(closingBraceToken);
if (!util.isCommaToken(before) && !util.isOpeningBraceToken(before)) {
if (!(0, util_1.isCommaToken)(before) && !(0, util_1.isOpeningBraceToken)(before)) {
insertText = `,${insertText}`;

@@ -450,3 +437,6 @@ }

// import * as types from 'foo'
yield* fixInsertTypeSpecifierForImportDeclaration(fixer, node, false);
// checks for presence of import assertions
if (node.attributes.length === 0) {
yield* fixInsertTypeSpecifierForImportDeclaration(fixer, node, false);
}
return;

@@ -519,3 +509,3 @@ }

// import DefType, * as Type from 'foo'
const commaToken = util.nullThrows(sourceCode.getTokenBefore(namespaceSpecifier, util.isCommaToken), util.NullThrowsReasons.MissingToken(',', node.type));
const commaToken = (0, util_1.nullThrows)(sourceCode.getTokenBefore(namespaceSpecifier, util_1.isCommaToken), util_1.NullThrowsReasons.MissingToken(',', node.type));
// import Def, * as Ns from 'foo'

@@ -531,3 +521,3 @@ // ^^^^^^^^^ remove

if (report.typeSpecifiers.length === node.specifiers.length) {
const importToken = util.nullThrows(sourceCode.getFirstToken(node, util.isImportKeyword), util.NullThrowsReasons.MissingToken('import', node.type));
const importToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(node, util_1.isImportKeyword), util_1.NullThrowsReasons.MissingToken('import', node.type));
// import type Type from 'foo'

@@ -538,3 +528,3 @@ // ^^^^ insert

else {
const commaToken = util.nullThrows(sourceCode.getTokenAfter(defaultSpecifier, util.isCommaToken), util.NullThrowsReasons.MissingToken(',', defaultSpecifier.type));
const commaToken = (0, util_1.nullThrows)(sourceCode.getTokenAfter(defaultSpecifier, util_1.isCommaToken), util_1.NullThrowsReasons.MissingToken(',', defaultSpecifier.type));
// import Type , {...} from 'foo'

@@ -546,3 +536,3 @@ // ^^^^^ pick

yield fixer.insertTextBefore(node, `import type ${defaultText} from ${sourceCode.getText(node.source)};\n`);
const afterToken = util.nullThrows(sourceCode.getTokenAfter(commaToken, { includeComments: true }), util.NullThrowsReasons.MissingToken('any token', node.type));
const afterToken = (0, util_1.nullThrows)(sourceCode.getTokenAfter(commaToken, { includeComments: true }), util_1.NullThrowsReasons.MissingToken('any token', node.type));
// import Type , {...} from 'foo'

@@ -563,11 +553,11 @@ // ^^^^^^^ remove

// ^^^^^ insert
const importToken = util.nullThrows(sourceCode.getFirstToken(node, util.isImportKeyword), util.NullThrowsReasons.MissingToken('import', node.type));
const importToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(node, util_1.isImportKeyword), util_1.NullThrowsReasons.MissingToken('import', node.type));
yield fixer.insertTextAfter(importToken, ' type');
if (isDefaultImport) {
// Has default import
const openingBraceToken = sourceCode.getFirstTokenBetween(importToken, node.source, util.isOpeningBraceToken);
const openingBraceToken = sourceCode.getFirstTokenBetween(importToken, node.source, util_1.isOpeningBraceToken);
if (openingBraceToken) {
// Only braces. e.g. import Foo, {} from 'foo'
const commaToken = util.nullThrows(sourceCode.getTokenBefore(openingBraceToken, util.isCommaToken), util.NullThrowsReasons.MissingToken(',', node.type));
const closingBraceToken = util.nullThrows(sourceCode.getFirstTokenBetween(openingBraceToken, node.source, util.isClosingBraceToken), util.NullThrowsReasons.MissingToken('}', node.type));
const commaToken = (0, util_1.nullThrows)(sourceCode.getTokenBefore(openingBraceToken, util_1.isCommaToken), util_1.NullThrowsReasons.MissingToken(',', node.type));
const closingBraceToken = (0, util_1.nullThrows)(sourceCode.getFirstTokenBetween(openingBraceToken, node.source, util_1.isClosingBraceToken), util_1.NullThrowsReasons.MissingToken('}', node.type));
// import type Foo, {} from 'foo'

@@ -644,5 +634,5 @@ // ^^ remove

// ^^^^ remove
const importToken = util.nullThrows(sourceCode.getFirstToken(node, util.isImportKeyword), util.NullThrowsReasons.MissingToken('import', node.type));
const typeToken = util.nullThrows(sourceCode.getFirstTokenBetween(importToken, node.specifiers[0]?.local ?? node.source, util.isTypeKeyword), util.NullThrowsReasons.MissingToken('type', node.type));
const afterToken = util.nullThrows(sourceCode.getTokenAfter(typeToken, { includeComments: true }), util.NullThrowsReasons.MissingToken('any token', node.type));
const importToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(node, util_1.isImportKeyword), util_1.NullThrowsReasons.MissingToken('import', node.type));
const typeToken = (0, util_1.nullThrows)(sourceCode.getFirstTokenBetween(importToken, node.specifiers[0]?.local ?? node.source, util_1.isTypeKeyword), util_1.NullThrowsReasons.MissingToken('type', node.type));
const afterToken = (0, util_1.nullThrows)(sourceCode.getTokenAfter(typeToken, { includeComments: true }), util_1.NullThrowsReasons.MissingToken('any token', node.type));
yield fixer.removeRange([typeToken.range[0], afterToken.range[0]]);

@@ -653,4 +643,4 @@ }

// ^^^^ remove
const typeToken = util.nullThrows(sourceCode.getFirstToken(node, util.isTypeKeyword), util.NullThrowsReasons.MissingToken('type', node.type));
const afterToken = util.nullThrows(sourceCode.getTokenAfter(typeToken, { includeComments: true }), util.NullThrowsReasons.MissingToken('any token', node.type));
const typeToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(node, util_1.isTypeKeyword), util_1.NullThrowsReasons.MissingToken('type', node.type));
const afterToken = (0, util_1.nullThrows)(sourceCode.getTokenAfter(typeToken, { includeComments: true }), util_1.NullThrowsReasons.MissingToken('any token', node.type));
yield fixer.removeRange([typeToken.range[0], afterToken.range[0]]);

@@ -657,0 +647,0 @@ }

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

function isOptionalParam(node) {
return 'optional' in node && node.optional === true;
return 'optional' in node && node.optional;
}

@@ -29,0 +29,0 @@ /**

@@ -26,6 +26,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getEnumTypes = void 0;
exports.getEnumKeyForLiteral = exports.getEnumTypes = exports.getEnumLiterals = void 0;
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util = __importStar(require("../../util"));
const util_1 = require("../../util");
/*

@@ -47,2 +47,17 @@ * If passed an enum member, returns the type of the parent. Otherwise,

/**
* Retrieve only the Enum literals from a type. for example:
* - 123 --> []
* - {} --> []
* - Fruit.Apple --> [Fruit.Apple]
* - Fruit.Apple | Vegetable.Lettuce --> [Fruit.Apple, Vegetable.Lettuce]
* - Fruit.Apple | Vegetable.Lettuce | 123 --> [Fruit.Apple, Vegetable.Lettuce]
* - T extends Fruit --> [Fruit]
*/
function getEnumLiterals(type) {
return tsutils
.unionTypeParts(type)
.filter((subType) => (0, util_1.isTypeFlagSet)(subType, ts.TypeFlags.EnumLiteral));
}
exports.getEnumLiterals = getEnumLiterals;
/**
* A type can have 0 or more enum types. For example:

@@ -57,8 +72,44 @@ * - 123 --> []

function getEnumTypes(typeChecker, type) {
return tsutils
.unionTypeParts(type)
.filter(subType => util.isTypeFlagSet(subType, ts.TypeFlags.EnumLiteral))
.map(type => getBaseEnumType(typeChecker, type));
return getEnumLiterals(type).map(type => getBaseEnumType(typeChecker, type));
}
exports.getEnumTypes = getEnumTypes;
/**
* Returns the enum key that matches the given literal node, or null if none
* match. For example:
* ```ts
* enum Fruit {
* Apple = 'apple',
* Banana = 'banana',
* }
*
* getEnumKeyForLiteral([Fruit.Apple, Fruit.Banana], 'apple') --> 'Fruit.Apple'
* getEnumKeyForLiteral([Fruit.Apple, Fruit.Banana], 'banana') --> 'Fruit.Banana'
* getEnumKeyForLiteral([Fruit.Apple, Fruit.Banana], 'cherry') --> null
* ```
*/
function getEnumKeyForLiteral(enumLiterals, literal) {
for (const enumLiteral of enumLiterals) {
if (enumLiteral.value === literal) {
const { symbol } = enumLiteral;
const memberDeclaration = symbol.valueDeclaration;
const enumDeclaration = memberDeclaration.parent;
const memberNameIdentifier = memberDeclaration.name;
const enumName = enumDeclaration.name.text;
switch (memberNameIdentifier.kind) {
case ts.SyntaxKind.Identifier:
return `${enumName}.${memberNameIdentifier.text}`;
case ts.SyntaxKind.StringLiteral: {
const memberName = memberNameIdentifier.text.replace(/'/g, "\\'");
return `${enumName}['${memberName}']`;
}
case ts.SyntaxKind.ComputedPropertyName:
return `${enumName}[${memberNameIdentifier.expression.getText()}]`;
default:
break;
}
}
}
return null;
}
exports.getEnumKeyForLiteral = getEnumKeyForLiteral;
//# sourceMappingURL=shared.js.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const explicitReturnTypeUtils_1 = require("../util/explicitReturnTypeUtils");
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'explicit-function-return-type',

@@ -96,3 +74,3 @@ meta: {

create(context, [options]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
function isAllowedFunction(node) {

@@ -115,3 +93,3 @@ if (options.allowFunctionsWithoutTypeParameters && !node.typeParameters) {

}
else if (parent) {
else {
switch (parent.type) {

@@ -128,3 +106,3 @@ case utils_1.AST_NODE_TYPES.VariableDeclarator: {

if (parent.key.type === utils_1.AST_NODE_TYPES.Identifier &&
parent.computed === false) {
!parent.computed) {
funcName = parent.key.name;

@@ -142,3 +120,2 @@ }

node.id &&
node.id.type === utils_1.AST_NODE_TYPES.Identifier &&
!!options.allowedNames.includes(node.id.name)) {

@@ -145,0 +122,0 @@ return true;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'explicit-member-accessibility',

@@ -95,3 +73,3 @@ meta: {

create(context, [option]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const baseCheck = option.accessibility ?? 'explicit';

@@ -128,3 +106,3 @@ const overrides = option.overrides ?? {};

}
const { name: methodName } = util.getNameFromMember(methodDefinition, sourceCode);
const { name: methodName } = (0, util_1.getNameFromMember)(methodDefinition, sourceCode);
if (check === 'off' || ignoredMethodNames.has(methodName)) {

@@ -194,3 +172,3 @@ return;

function fix(accessibility, fixer) {
if (node?.decorators.length) {
if (node.decorators.length) {
const lastDecorator = node.decorators[node.decorators.length - 1];

@@ -229,3 +207,3 @@ const nextToken = sourceCode.getTokenAfter(lastDecorator);

const nodeType = 'class property';
const { name: propertyName } = util.getNameFromMember(propertyDefinition, sourceCode);
const { name: propertyName } = (0, util_1.getNameFromMember)(propertyDefinition, sourceCode);
if (propCheck === 'no-public' &&

@@ -232,0 +210,0 @@ propertyDefinition.accessibility === 'public') {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const scope_manager_1 = require("@typescript-eslint/scope-manager");
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const explicitReturnTypeUtils_1 = require("../util/explicitReturnTypeUtils");
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'explicit-module-boundary-types',

@@ -92,3 +70,3 @@ meta: {

create(context, [options]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
// tracks all of the functions we've already checked

@@ -239,6 +217,6 @@ const checkedFunctions = new Set();

// the parent of a return will always be a block statement, so we can skip over it
current = current.parent?.parent;
current = current.parent.parent;
continue;
}
if (!util.isFunction(current) ||
if (!(0, util_1.isFunction)(current) ||
!(0, explicitReturnTypeUtils_1.doesImmediatelyReturnFunctionExpression)(current)) {

@@ -255,3 +233,3 @@ return false;

function followReference(node) {
const scope = context.getScope();
const scope = (0, eslint_utils_1.getScope)(context);
const variable = scope.set.get(node.name);

@@ -340,6 +318,6 @@ /* istanbul ignore if */ if (!variable) {

function checkEmptyBodyFunctionExpression(node) {
const isConstructor = node.parent?.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
const isConstructor = node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
node.parent.kind === 'constructor';
const isSetAccessor = (node.parent?.type === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition ||
node.parent?.type === utils_1.AST_NODE_TYPES.MethodDefinition) &&
const isSetAccessor = (node.parent.type === utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition ||
node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition) &&
node.parent.kind === 'set';

@@ -346,0 +324,0 @@ if (!isConstructor && !isSetAccessor && !node.returnType) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'func-call-spacing',

@@ -79,3 +57,3 @@ meta: {

create(context, [option, config]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const text = sourceCode.getText();

@@ -89,6 +67,6 @@ /**

function checkSpacing(node) {
const isOptionalCall = util.isOptionalCallExpression(node);
const isOptionalCall = (0, util_1.isOptionalCallExpression)(node);
const closingParenToken = sourceCode.getLastToken(node);
const lastCalleeTokenWithoutPossibleParens = sourceCode.getLastToken(node.typeArguments ?? node.callee);
const openingParenToken = sourceCode.getFirstTokenBetween(lastCalleeTokenWithoutPossibleParens, closingParenToken, util.isOpeningParenToken);
const openingParenToken = sourceCode.getFirstTokenBetween(lastCalleeTokenWithoutPossibleParens, closingParenToken, util_1.isOpeningParenToken);
if (!openingParenToken || openingParenToken.range[1] >= node.range[1]) {

@@ -98,3 +76,3 @@ // new expression with no parens...

}
const lastCalleeToken = sourceCode.getTokenBefore(openingParenToken, util.isNotOptionalChainPunctuator);
const lastCalleeToken = sourceCode.getTokenBefore(openingParenToken, util_1.isNotOptionalChainPunctuator);
const textBetweenTokens = text

@@ -104,3 +82,3 @@ .slice(lastCalleeToken.range[1], openingParenToken.range[0])

const hasWhitespace = /\s/u.test(textBetweenTokens);
const hasNewline = hasWhitespace && util.LINEBREAK_MATCHER.test(textBetweenTokens);
const hasNewline = hasWhitespace && util_1.LINEBREAK_MATCHER.test(textBetweenTokens);
if (option === 'never') {

@@ -107,0 +85,0 @@ if (hasWhitespace) {

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

/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");

@@ -102,3 +80,3 @@ const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('indent');

]);
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'indent',

@@ -342,3 +320,3 @@ meta: {

TSMappedType(node) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const squareBracketStart = sourceCode.getTokenBefore(node.typeParameter);

@@ -345,0 +323,0 @@ // transform it to an ObjectExpression

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

const lines_between_class_members_1 = __importDefault(require("./lines-between-class-members"));
const max_params_1 = __importDefault(require("./max-params"));
const member_delimiter_style_1 = __importDefault(require("./member-delimiter-style"));

@@ -95,2 +96,3 @@ const member_ordering_1 = __importDefault(require("./member-ordering"));

const no_unsafe_return_1 = __importDefault(require("./no-unsafe-return"));
const no_unsafe_unary_minus_1 = __importDefault(require("./no-unsafe-unary-minus"));
const no_unused_expressions_1 = __importDefault(require("./no-unused-expressions"));

@@ -101,2 +103,3 @@ const no_unused_vars_1 = __importDefault(require("./no-unused-vars"));

const no_useless_empty_export_1 = __importDefault(require("./no-useless-empty-export"));
const no_useless_template_literals_1 = __importDefault(require("./no-useless-template-literals"));
const no_var_requires_1 = __importDefault(require("./no-var-requires"));

@@ -108,2 +111,3 @@ const non_nullable_type_assertion_style_1 = __importDefault(require("./non-nullable-type-assertion-style"));

const prefer_as_const_1 = __importDefault(require("./prefer-as-const"));
const prefer_destructuring_1 = __importDefault(require("./prefer-destructuring"));
const prefer_enum_initializers_1 = __importDefault(require("./prefer-enum-initializers"));

@@ -174,2 +178,3 @@ const prefer_for_of_1 = __importDefault(require("./prefer-for-of"));

'lines-between-class-members': lines_between_class_members_1.default,
'max-params': max_params_1.default,
'member-delimiter-style': member_delimiter_style_1.default,

@@ -233,2 +238,3 @@ 'member-ordering': member_ordering_1.default,

'no-unsafe-return': no_unsafe_return_1.default,
'no-unsafe-unary-minus': no_unsafe_unary_minus_1.default,
'no-unused-expressions': no_unused_expressions_1.default,

@@ -239,2 +245,3 @@ 'no-unused-vars': no_unused_vars_1.default,

'no-useless-empty-export': no_useless_empty_export_1.default,
'no-useless-template-literals': no_useless_template_literals_1.default,
'no-var-requires': no_var_requires_1.default,

@@ -246,2 +253,3 @@ 'non-nullable-type-assertion-style': non_nullable_type_assertion_style_1.default,

'prefer-as-const': prefer_as_const_1.default,
'prefer-destructuring': prefer_destructuring_1.default,
'prefer-enum-initializers': prefer_enum_initializers_1.default,

@@ -248,0 +256,0 @@ 'prefer-for-of': prefer_for_of_1.default,

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");

@@ -34,12 +12,3 @@ const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('key-spacing');

: baseRule.meta.schema;
/**
* TODO: replace with native .at() once Node 14 stops being supported
*/
function at(arr, position) {
if (position < 0) {
return arr[arr.length + position];
}
return arr[position];
}
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'key-spacing',

@@ -59,3 +28,3 @@ meta: {

create(context, [options]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const baseRules = baseRule.create(context);

@@ -67,3 +36,3 @@ /**

const line = position.line - 1; // position.line is 1-indexed
return util.getStringLength(at(sourceCode.lines, line).slice(0, position.column));
return (0, util_1.getStringLength)(sourceCode.lines.at(line).slice(0, position.column));
}

@@ -75,3 +44,3 @@ /**

function getLastTokenBeforeColon(node) {
const colonToken = sourceCode.getTokenAfter(node, util.isColonToken);
const colonToken = sourceCode.getTokenAfter(node, util_1.isColonToken);
return sourceCode.getTokenBefore(colonToken);

@@ -97,3 +66,3 @@ }

const code = sourceCode.getText(node);
return code.slice(0, sourceCode.getTokenAfter(at(node.parameters, -1), util.isClosingBracketToken).range[1] - node.range[0]);
return code.slice(0, sourceCode.getTokenAfter(node.parameters.at(-1), util_1.isClosingBracketToken).range[1] - node.range[0]);
}

@@ -106,3 +75,3 @@ /**

? node.key
: at(node.parameters, -1)).loc.end;
: node.parameters.at(-1)).loc.end;
}

@@ -136,5 +105,10 @@ function checkBeforeColon(node, expectedWhitespaceBeforeColon, mode) {

const { typeAnnotation } = node;
const colon = typeAnnotation.loc.start.column;
const typeStart = typeAnnotation.typeAnnotation.loc.start.column;
const difference = typeStart - colon - 1 - expectedWhitespaceAfterColon;
const colonToken = sourceCode.getFirstToken(typeAnnotation);
const typeStart = sourceCode.getTokenAfter(colonToken, {
includeComments: true,
}).loc.start.column;
const difference = typeStart -
colonToken.loc.start.column -
1 -
expectedWhitespaceAfterColon;
if (mode === 'strict' ? difference : difference < 0) {

@@ -147,7 +121,7 @@ context.report({

return fixer.removeRange([
typeAnnotation.typeAnnotation.range[0] - difference,
typeAnnotation.typeAnnotation.range[0],
colonToken.range[1],
colonToken.range[1] + difference,
]);
}
return fixer.insertTextBefore(typeAnnotation.typeAnnotation, ' '.repeat(-difference));
return fixer.insertTextAfter(colonToken, ' '.repeat(-difference));
},

@@ -179,3 +153,3 @@ data: {

leadingComments[0].loc.start.line - groupEndLine <= 1 &&
candidateValueStartLine - at(leadingComments, -1).loc.end.line <= 1) {
candidateValueStartLine - leadingComments.at(-1).loc.end.line <= 1) {
for (let i = 1; i < leadingComments.length; i++) {

@@ -313,3 +287,3 @@ if (leadingComments[i].loc.start.line -

for (const node of members) {
let prevAlignedNode = at(currentAlignGroup, -1);
let prevAlignedNode = currentAlignGroup.at(-1);
if (prevAlignedNode !== prevNode) {

@@ -316,0 +290,0 @@ prevAlignedNode = undefined;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");

@@ -34,3 +12,3 @@ const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('keyword-spacing');

: baseRule.meta.schema;
const schema = util.deepMerge(
const schema = (0, util_1.deepMerge)(
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- https://github.com/microsoft/TypeScript/issues/17002

@@ -47,3 +25,3 @@ baseSchema, {

});
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'keyword-spacing',

@@ -63,3 +41,3 @@ meta: {

create(context, [{ after, overrides }]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const baseRules = baseRule.create(context);

@@ -69,3 +47,3 @@ return {

TSAsExpression(node) {
const asToken = util.nullThrows(sourceCode.getTokenAfter(node.expression, token => token.value === 'as'), util.NullThrowsReasons.MissingToken('as', node.type));
const asToken = (0, util_1.nullThrows)(sourceCode.getTokenAfter(node.expression, token => token.value === 'as'), util_1.NullThrowsReasons.MissingToken('as', node.type));
const oldTokenType = asToken.type;

@@ -86,3 +64,3 @@ // as is a contextual keyword, so it's always reported as an Identifier

const punctuatorToken = sourceCode.getTokenAfter(typeToken);
if (node.specifiers?.[0]?.type === utils_1.AST_NODE_TYPES.ImportDefaultSpecifier) {
if (node.specifiers[0]?.type === utils_1.AST_NODE_TYPES.ImportDefaultSpecifier) {
return;

@@ -89,0 +67,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");

@@ -56,3 +34,3 @@ const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('lines-around-comment');

}
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'lines-around-comment',

@@ -158,3 +136,3 @@ meta: {

const customIgnoreRegExp = new RegExp(options.ignorePattern ?? '', 'u');
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const comments = sourceCode.getAllComments();

@@ -174,4 +152,4 @@ const lines = sourceCode.lines;

});
} while (currentToken && util.isCommentToken(currentToken));
if (currentToken && util.isTokenOnSameLine(currentToken, token)) {
} while (currentToken && (0, util_1.isCommentToken)(currentToken));
if (currentToken && (0, util_1.isTokenOnSameLine)(currentToken, token)) {
return true;

@@ -184,4 +162,4 @@ }

});
} while (currentToken && util.isCommentToken(currentToken));
if (currentToken && util.isTokenOnSameLine(token, currentToken)) {
} while (currentToken && (0, util_1.isCommentToken)(currentToken));
if (currentToken && (0, util_1.isTokenOnSameLine)(token, currentToken)) {
return true;

@@ -303,4 +281,4 @@ }

!commentAndEmptyLines.has(prevLineNum) &&
!(util.isCommentToken(previousTokenOrComment) &&
util.isTokenOnSameLine(previousTokenOrComment, token))) {
!((0, util_1.isCommentToken)(previousTokenOrComment) &&
(0, util_1.isTokenOnSameLine)(previousTokenOrComment, token))) {
const lineStart = token.range[0] - token.loc.start.column;

@@ -320,4 +298,4 @@ const range = [lineStart, lineStart];

!commentAndEmptyLines.has(nextLineNum) &&
!(util.isCommentToken(nextTokenOrComment) &&
util.isTokenOnSameLine(token, nextTokenOrComment))) {
!((0, util_1.isCommentToken)(nextTokenOrComment) &&
(0, util_1.isTokenOnSameLine)(token, nextTokenOrComment))) {
context.report({

@@ -372,9 +350,7 @@ node: token,

}
else if (token.type === utils_1.AST_TOKEN_TYPES.Block) {
if (options.beforeBlockComment || options.afterBlockComment) {
checkForEmptyLine(token, {
after: options.afterBlockComment,
before: options.beforeBlockComment,
});
}
else if (options.beforeBlockComment || options.afterBlockComment) {
checkForEmptyLine(token, {
after: options.afterBlockComment,
before: options.beforeBlockComment,
});
}

@@ -381,0 +357,0 @@ });

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('lines-between-class-members');
const schema = Object.values(util.deepMerge({ ...baseRule.meta.schema }, {
const schema = Object.values((0, util_1.deepMerge)({ ...baseRule.meta.schema }, {
1: {

@@ -40,3 +17,3 @@ properties: {

}));
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'lines-between-class-members',

@@ -43,0 +20,0 @@ meta: {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const isLastTokenEndOfLine = (token, line) => {

@@ -86,3 +64,3 @@ const positionInLine = token.loc.start.column;

};
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'member-delimiter-style',

@@ -154,8 +132,8 @@ meta: {

create(context, [options]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
// use the base options as the defaults for the cases
const baseOptions = options;
const overrides = baseOptions.overrides ?? {};
const interfaceOptions = util.deepMerge(baseOptions, overrides.interface);
const typeLiteralOptions = util.deepMerge(baseOptions, overrides.typeLiteral);
const interfaceOptions = (0, util_1.deepMerge)(baseOptions, overrides.interface);
const typeLiteralOptions = (0, util_1.deepMerge)(baseOptions, overrides.typeLiteral);
/**

@@ -191,3 +169,3 @@ * Check the last token in the given member.

const sourceCodeLines = sourceCode.getLines();
const lastTokenLine = sourceCodeLines[lastToken?.loc.start.line - 1];
const lastTokenLine = sourceCodeLines[lastToken.loc.start.line - 1];
const optsSemi = getOption('semi');

@@ -272,3 +250,3 @@ const optsComma = getOption('comma');

members.forEach((member, index) => {
checkLastToken(member, opts ?? {}, index === members.length - 1);
checkLastToken(member, opts, index === members.length - 1);
});

@@ -275,0 +253,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -31,4 +8,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const natural_compare_1 = __importDefault(require("natural-compare"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
const neverConfig = {

@@ -103,2 +81,25 @@ type: 'string',

'constructor',
// Accessors
'public-static-accessor',
'protected-static-accessor',
'private-static-accessor',
'#private-static-accessor',
'public-decorated-accessor',
'protected-decorated-accessor',
'private-decorated-accessor',
'public-instance-accessor',
'protected-instance-accessor',
'private-instance-accessor',
'#private-instance-accessor',
'public-abstract-accessor',
'protected-abstract-accessor',
'public-accessor',
'protected-accessor',
'private-accessor',
'#private-accessor',
'static-accessor',
'instance-accessor',
'abstract-accessor',
'decorated-accessor',
'accessor',
// Getters

@@ -182,2 +183,3 @@ 'public-static-get',

'constructor',
'accessor',
'get',

@@ -196,3 +198,3 @@ 'set',

}
// Only class instance fields, methods, get and set can have decorators attached to them
// Only class instance fields, methods, accessors, get and set can have decorators attached to them
if (accessibility !== '#private' &&

@@ -202,2 +204,3 @@ (type === 'readonly-field' ||

type === 'method' ||
type === 'accessor' ||
type === 'get' ||

@@ -251,2 +254,4 @@ type === 'set')) {

return node.readonly ? 'readonly-field' : 'field';
case utils_1.AST_NODE_TYPES.AccessorProperty:
return 'accessor';
case utils_1.AST_NODE_TYPES.PropertyDefinition:

@@ -272,7 +277,7 @@ return node.value && functionExpressions.includes(node.value.type)

function getMemberRawName(member, sourceCode) {
const { name, type } = util.getNameFromMember(member, sourceCode);
if (type === util.MemberNameType.Quoted) {
const { name, type } = (0, util_1.getNameFromMember)(member, sourceCode);
if (type === util_1.MemberNameType.Quoted) {
return name.slice(1, -1);
}
if (type === util.MemberNameType.Private) {
if (type === util_1.MemberNameType.Private) {
return name.slice(1);

@@ -305,3 +310,3 @@ }

case utils_1.AST_NODE_TYPES.TSIndexSignature:
return util.getNameFromIndexSignature(node);
return (0, util_1.getNameFromIndexSignature)(node);
case utils_1.AST_NODE_TYPES.StaticBlock:

@@ -359,3 +364,3 @@ return 'static block';

}
if ('key' in node && node.key?.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
if ('key' in node && node.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier) {
return '#private';

@@ -462,3 +467,3 @@ }

}
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'member-ordering',

@@ -564,8 +569,8 @@ meta: {

// Find first member which isn't correctly sorted
members.forEach(member => {
for (const member of members) {
const rank = getRank(member, groupOrder, supportsModifiers);
const name = getMemberName(member, context.getSourceCode());
const name = getMemberName(member, (0, eslint_utils_1.getSourceCode)(context));
const rankLastMember = previousRanks[previousRanks.length - 1];
if (rank === -1) {
return;
continue;
}

@@ -593,3 +598,3 @@ // Works for 1st item because x < undefined === false for any x (typeof string)

}
});
}
return isCorrectlySorted ? memberGroups : null;

@@ -610,3 +615,3 @@ }

members.forEach(member => {
const name = getMemberName(member, context.getSourceCode());
const name = getMemberName(member, (0, eslint_utils_1.getSourceCode)(context));
// Note: Not all members have names

@@ -660,3 +665,3 @@ if (name) {

data: {
member: getMemberName(member, context.getSourceCode()),
member: getMemberName(member, (0, eslint_utils_1.getSourceCode)(context)),
optionalOrRequired: optionalityOrder === 'required-first' ? 'required' : 'optional',

@@ -663,0 +668,0 @@ },

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'method-signature-style',

@@ -49,3 +27,3 @@ meta: {

create(context, [mode]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
function getMethodKey(node) {

@@ -67,4 +45,4 @@ let key = sourceCode.getText(node.key);

if (node.params.length > 0) {
const openingParen = util.nullThrows(sourceCode.getTokenBefore(node.params[0], util.isOpeningParenToken), 'Missing opening paren before first parameter');
const closingParen = util.nullThrows(sourceCode.getTokenAfter(node.params[node.params.length - 1], util.isClosingParenToken), 'Missing closing paren after last parameter');
const openingParen = (0, util_1.nullThrows)(sourceCode.getTokenBefore(node.params[0], util_1.isOpeningParenToken), 'Missing opening paren before first parameter');
const closingParen = (0, util_1.nullThrows)(sourceCode.getTokenAfter(node.params[node.params.length - 1], util_1.isClosingParenToken), 'Missing closing paren after last parameter');
params = sourceCode.text.substring(openingParen.range[0], closingParen.range[1]);

@@ -88,3 +66,3 @@ }

if (lastToken &&
(util.isSemicolonToken(lastToken) || util.isCommaToken(lastToken))) {
((0, util_1.isSemicolonToken)(lastToken) || (0, util_1.isCommaToken)(lastToken))) {
return lastToken.value;

@@ -113,5 +91,5 @@ }

const parent = methodNode.parent;
const members = parent?.type === utils_1.AST_NODE_TYPES.TSInterfaceBody
const members = parent.type === utils_1.AST_NODE_TYPES.TSInterfaceBody
? parent.body
: parent?.type === utils_1.AST_NODE_TYPES.TSTypeLiteral
: parent.type === utils_1.AST_NODE_TYPES.TSTypeLiteral
? parent.members

@@ -118,0 +96,0 @@ : [];

@@ -45,5 +45,8 @@ "use strict";

Selectors[Selectors["typeParameter"] = 131072] = "typeParameter";
// other
Selectors[Selectors["import"] = 262144] = "import";
})(Selectors || (exports.Selectors = Selectors = {}));
var MetaSelectors;
(function (MetaSelectors) {
/* eslint-disable @typescript-eslint/prefer-literal-enum-member */
MetaSelectors[MetaSelectors["default"] = -1] = "default";

@@ -55,2 +58,3 @@ MetaSelectors[MetaSelectors["variableLike"] = 7] = "variableLike";

MetaSelectors[MetaSelectors["property"] = 3584] = "property";
/* eslint-enable @typescript-eslint/prefer-literal-enum-member */
})(MetaSelectors || (exports.MetaSelectors = MetaSelectors = {}));

@@ -85,2 +89,6 @@ var Modifiers;

Modifiers[Modifiers["async"] = 16384] = "async";
// default imports
Modifiers[Modifiers["default"] = 32768] = "default";
// namespace imports
Modifiers[Modifiers["namespace"] = 65536] = "namespace";
// make sure TypeModifiers starts at Modifiers + 1 or else sorting won't work

@@ -90,8 +98,8 @@ })(Modifiers || (exports.Modifiers = Modifiers = {}));

(function (TypeModifiers) {
TypeModifiers[TypeModifiers["boolean"] = 32768] = "boolean";
TypeModifiers[TypeModifiers["string"] = 65536] = "string";
TypeModifiers[TypeModifiers["number"] = 131072] = "number";
TypeModifiers[TypeModifiers["function"] = 262144] = "function";
TypeModifiers[TypeModifiers["array"] = 524288] = "array";
TypeModifiers[TypeModifiers["boolean"] = 131072] = "boolean";
TypeModifiers[TypeModifiers["string"] = 262144] = "string";
TypeModifiers[TypeModifiers["number"] = 524288] = "number";
TypeModifiers[TypeModifiers["function"] = 1048576] = "function";
TypeModifiers[TypeModifiers["array"] = 2097152] = "array";
})(TypeModifiers || (exports.TypeModifiers = TypeModifiers = {}));
//# sourceMappingURL=enums.js.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseOptions = void 0;
const util = __importStar(require("../../util"));
const util_1 = require("../../util");
const enums_1 = require("./enums");

@@ -90,5 +67,6 @@ const shared_1 = require("./shared");

.reduce((acc, val) => acc.concat(val), []);
const result = util.getEnumNames(enums_1.Selectors).reduce((acc, k) => {
const result = (0, util_1.getEnumNames)(enums_1.Selectors).reduce((acc, k) => {
acc[k] = (0, validator_1.createValidator)(k, context, normalizedOptions);
return acc;
// eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter
}, {});

@@ -95,0 +73,0 @@ return result;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SCHEMA = void 0;
const util = __importStar(require("../../util"));
const util_1 = require("../../util");
const enums_1 = require("./enums");

@@ -33,11 +10,11 @@ const $DEFS = {

type: 'string',
enum: util.getEnumNames(enums_1.UnderscoreOptions),
enum: (0, util_1.getEnumNames)(enums_1.UnderscoreOptions),
},
predefinedFormats: {
type: 'string',
enum: util.getEnumNames(enums_1.PredefinedFormats),
enum: (0, util_1.getEnumNames)(enums_1.PredefinedFormats),
},
typeModifiers: {
type: 'string',
enum: util.getEnumNames(enums_1.TypeModifiers),
enum: (0, util_1.getEnumNames)(enums_1.TypeModifiers),
},

@@ -167,6 +144,3 @@ // repeated types

type: 'string',
enum: [
...util.getEnumNames(enums_1.MetaSelectors),
...util.getEnumNames(enums_1.Selectors),
],
enum: [...(0, util_1.getEnumNames)(enums_1.MetaSelectors), ...(0, util_1.getEnumNames)(enums_1.Selectors)],
},

@@ -179,3 +153,3 @@ additionalItems: false,

type: 'string',
enum: util.getEnumNames(enums_1.Modifiers),
enum: (0, util_1.getEnumNames)(enums_1.Modifiers),
},

@@ -203,3 +177,3 @@ additionalItems: false,

selectorsSchema(),
...selectorSchema('default', false, util.getEnumNames(enums_1.Modifiers)),
...selectorSchema('default', false, (0, util_1.getEnumNames)(enums_1.Modifiers)),
...selectorSchema('variableLike', false, ['unused', 'async']),

@@ -315,2 +289,3 @@ ...selectorSchema('variable', true, [

...selectorSchema('typeParameter', false, ['unused']),
...selectorSchema('import', false, ['default', 'namespace']),
],

@@ -317,0 +292,0 @@ },

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createValidator = void 0;
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../../util"));
const util_1 = require("../../util");
const enums_1 = require("./enums");

@@ -130,3 +107,3 @@ const format_1 = require("./format");

formats: formats?.map(f => enums_1.PredefinedFormats[f]).join(', '),
regex: custom?.regex?.toString(),
regex: custom?.regex.toString(),
regexMatch: custom?.match === true

@@ -332,3 +309,3 @@ ? 'match'

}
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();

@@ -335,0 +312,0 @@ const type = services

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const scope_manager_1 = require("@typescript-eslint/scope-manager");
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const naming_convention_utils_1 = require("./naming-convention-utils");

@@ -40,2 +18,6 @@ // This essentially mirrors ESLint's `camelcase` rule

{
selector: 'import',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'variable',

@@ -51,3 +33,3 @@ format: ['camelCase', 'UPPER_CASE'],

];
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'naming-convention',

@@ -73,4 +55,3 @@ meta: {

create(contextWithoutDefaults) {
const context = contextWithoutDefaults.options &&
contextWithoutDefaults.options.length > 0
const context = contextWithoutDefaults.options.length > 0
? contextWithoutDefaults

@@ -82,7 +63,4 @@ : // only apply the defaults when the user provides no config

const validators = (0, naming_convention_utils_1.parseOptions)(context);
const compilerOptions = util.getParserServices(context, true).program?.getCompilerOptions() ?? {};
const compilerOptions = (0, util_1.getParserServices)(context, true).program?.getCompilerOptions() ?? {};
function handleMember(validator, node, modifiers) {
if (!validator) {
return;
}
const key = node.key;

@@ -120,4 +98,4 @@ if (requiresQuoting(key, compilerOptions.target)) {

}
const unusedVariables = util.collectUnusedVariables(context);
function isUnused(name, initialScope = context.getScope()) {
const unusedVariables = (0, util_1.collectUnusedVariables)(context);
function isUnused(name, initialScope = (0, eslint_utils_1.getScope)(context)) {
let variable = null;

@@ -141,7 +119,7 @@ let scope = initialScope;

// does not match `const { x: y }`
(id.parent?.type === utils_1.AST_NODE_TYPES.Property && id.parent.shorthand) ||
(id.parent.type === utils_1.AST_NODE_TYPES.Property && id.parent.shorthand) ||
// `const { x = 2 }`
// does not match const `{ x: y = 2 }`
(id.parent?.type === utils_1.AST_NODE_TYPES.AssignmentPattern &&
id.parent.parent?.type === utils_1.AST_NODE_TYPES.Property &&
(id.parent.type === utils_1.AST_NODE_TYPES.AssignmentPattern &&
id.parent.parent.type === utils_1.AST_NODE_TYPES.Property &&
id.parent.parent.shorthand));

@@ -156,10 +134,33 @@ }

function isAsyncVariableIdentifier(id) {
return Boolean(id.parent &&
(('async' in id.parent && id.parent.async) ||
('init' in id.parent &&
id.parent.init &&
'async' in id.parent.init &&
id.parent.init.async)));
return Boolean(('async' in id.parent && id.parent.async) ||
('init' in id.parent &&
id.parent.init &&
'async' in id.parent.init &&
id.parent.init.async));
}
const selectors = {
// #region import
'ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier': {
validator: validators.import,
handler: (node, validator) => {
const modifiers = new Set();
switch (node.type) {
case utils_1.AST_NODE_TYPES.ImportDefaultSpecifier:
modifiers.add(naming_convention_utils_1.Modifiers.default);
break;
case utils_1.AST_NODE_TYPES.ImportNamespaceSpecifier:
modifiers.add(naming_convention_utils_1.Modifiers.namespace);
break;
case utils_1.AST_NODE_TYPES.ImportSpecifier:
// Handle `import { default as Foo }`
if (node.imported.name !== 'default') {
return;
}
modifiers.add(naming_convention_utils_1.Modifiers.default);
break;
}
validator(node.local, modifiers);
},
},
// #endregion
// #region variable

@@ -172,7 +173,7 @@ VariableDeclarator: {

const parent = node.parent;
if (parent?.type === utils_1.AST_NODE_TYPES.VariableDeclaration) {
if (parent.type === utils_1.AST_NODE_TYPES.VariableDeclaration) {
if (parent.kind === 'const') {
baseModifiers.add(naming_convention_utils_1.Modifiers.const);
}
if (isGlobal(context.getScope())) {
if (isGlobal((0, eslint_utils_1.getScope)(context))) {
baseModifiers.add(naming_convention_utils_1.Modifiers.global);

@@ -186,3 +187,3 @@ }

}
if (isExported(parent, id.name, context.getScope())) {
if (isExported(parent, id.name, (0, eslint_utils_1.getScope)(context))) {
modifiers.add(naming_convention_utils_1.Modifiers.exported);

@@ -210,3 +211,3 @@ }

// functions create their own nested scope
const scope = context.getScope().upper;
const scope = (0, eslint_utils_1.getScope)(context).upper;
if (isGlobal(scope)) {

@@ -370,3 +371,3 @@ modifiers.add(naming_convention_utils_1.Modifiers.global);

// classes create their own nested scope
const scope = context.getScope().upper;
const scope = (0, eslint_utils_1.getScope)(context).upper;
if (node.abstract) {

@@ -390,3 +391,3 @@ modifiers.add(naming_convention_utils_1.Modifiers.abstract);

const modifiers = new Set();
const scope = context.getScope();
const scope = (0, eslint_utils_1.getScope)(context);
if (isExported(node, node.id.name, scope)) {

@@ -407,3 +408,3 @@ modifiers.add(naming_convention_utils_1.Modifiers.exported);

const modifiers = new Set();
const scope = context.getScope();
const scope = (0, eslint_utils_1.getScope)(context);
if (isExported(node, node.id.name, scope)) {

@@ -425,3 +426,3 @@ modifiers.add(naming_convention_utils_1.Modifiers.exported);

// enums create their own nested scope
const scope = context.getScope().upper;
const scope = (0, eslint_utils_1.getScope)(context).upper;
if (isExported(node, node.id.name, scope)) {

@@ -442,3 +443,3 @@ modifiers.add(naming_convention_utils_1.Modifiers.exported);

const modifiers = new Set();
const scope = context.getScope();
const scope = (0, eslint_utils_1.getScope)(context);
if (isUnused(node.name.name, scope)) {

@@ -452,4 +453,3 @@ modifiers.add(naming_convention_utils_1.Modifiers.unused);

};
return Object.fromEntries(Object.entries(selectors)
.map(([selector, { validator, handler }]) => {
return Object.fromEntries(Object.entries(selectors).map(([selector, { validator, handler }]) => {
return [

@@ -461,4 +461,3 @@ selector,

];
})
.filter((s) => s != null));
}));
},

@@ -484,4 +483,4 @@ });

const refParent = ref.identifier.parent;
if (refParent?.type === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration ||
refParent?.type === utils_1.AST_NODE_TYPES.ExportSpecifier) {
if (refParent.type === utils_1.AST_NODE_TYPES.ExportDefaultDeclaration ||
refParent.type === utils_1.AST_NODE_TYPES.ExportSpecifier) {
return true;

@@ -505,4 +504,4 @@ }

: `${node.value}`;
return util.requiresQuoting(name, target);
return (0, util_1.requiresQuoting)(name, target);
}
//# sourceMappingURL=naming-convention.js.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-array-constructor',

@@ -54,3 +32,3 @@ meta: {

!node.typeArguments &&
!util.isOptionalCallExpression(node)) {
!(0, util_1.isOptionalCallExpression)(node)) {
context.report({

@@ -63,3 +41,3 @@ node,

}
const fullText = context.getSourceCode().getText(node);
const fullText = (0, eslint_utils_1.getSourceCode)(context).getText(node);
const preambleLength = node.callee.range[1] - node.range[0];

@@ -66,0 +44,0 @@ return fixer.replaceText(node, `[${fullText.slice(preambleLength + 1, -1)}]`);

@@ -27,4 +27,5 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
var Usefulness;

@@ -36,3 +37,3 @@ (function (Usefulness) {

})(Usefulness || (Usefulness = {}));
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-base-to-string',

@@ -70,3 +71,3 @@ meta: {

create(context, [option]) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();

@@ -85,3 +86,3 @@ const ignoredTypeNames = option.ignoredTypeNames ?? [];

certainty,
name: context.getSourceCode().getText(node),
name: (0, eslint_utils_1.getSourceCode)(context).getText(node),
},

@@ -103,3 +104,3 @@ messageId: 'baseToString',

}
if (ignoredTypeNames.includes(util.getTypeName(checker, type))) {
if (ignoredTypeNames.includes((0, util_1.getTypeName)(checker, type))) {
return Usefulness.Always;

@@ -145,6 +146,6 @@ }

const rightType = services.getTypeAtLocation(node.right);
if (util.getTypeName(checker, leftType) === 'string') {
if ((0, util_1.getTypeName)(checker, leftType) === 'string') {
checkExpression(node.right, rightType);
}
else if (util.getTypeName(checker, rightType) === 'string' &&
else if ((0, util_1.getTypeName)(checker, rightType) === 'string' &&
node.left.type !== utils_1.AST_NODE_TYPES.PrivateIdentifier) {

@@ -151,0 +152,0 @@ checkExpression(node.left, leftType);

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-confusing-non-null-assertion',

@@ -49,3 +27,3 @@ meta: {

create(context) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
return {

@@ -63,3 +41,3 @@ 'BinaryExpression, AssignmentExpression'(node) {

if (leftHandFinalToken?.type === utils_1.AST_TOKEN_TYPES.Punctuator &&
leftHandFinalToken?.value === '!' &&
leftHandFinalToken.value === '!' &&
tokenAfterLeft?.value !== ')') {

@@ -66,0 +44,0 @@ if (isLeftHandPrimaryExpression(node.left)) {

@@ -27,6 +27,7 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-confusing-void-expression',

@@ -75,4 +76,4 @@ meta: {

'AwaitExpression, CallExpression, TaggedTemplateExpression'(node) {
const services = util.getParserServices(context);
const type = util.getConstrainedTypeAtLocation(services, node);
const services = (0, util_1.getParserServices)(context);
const type = (0, util_1.getConstrainedTypeAtLocation)(services, node);
if (!tsutils.isTypeFlagSet(type, ts.TypeFlags.VoidLike)) {

@@ -87,3 +88,3 @@ // not a void expression

}
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const wrapVoidFix = (fixer) => {

@@ -110,8 +111,11 @@ const nodeText = sourceCode.getText(node);

fix(fixer) {
if (!canFix(arrowFunction)) {
return null;
}
const arrowBody = arrowFunction.body;
const arrowBodyText = sourceCode.getText(arrowBody);
const newArrowBodyText = `{ ${arrowBodyText}; }`;
if (util.isParenthesized(arrowBody, sourceCode)) {
const bodyOpeningParen = sourceCode.getTokenBefore(arrowBody, util.isOpeningParenToken);
const bodyClosingParen = sourceCode.getTokenAfter(arrowBody, util.isClosingParenToken);
if ((0, util_1.isParenthesized)(arrowBody, sourceCode)) {
const bodyOpeningParen = sourceCode.getTokenBefore(arrowBody, util_1.isOpeningParenToken);
const bodyClosingParen = sourceCode.getTokenAfter(arrowBody, util_1.isClosingParenToken);
return fixer.replaceTextRange([bodyOpeningParen.range[0], bodyClosingParen.range[1]], newArrowBodyText);

@@ -140,2 +144,5 @@ }

fix(fixer) {
if (!canFix(returnStmt)) {
return null;
}
const returnValue = returnStmt.argument;

@@ -197,3 +204,3 @@ const returnValueText = sourceCode.getText(returnValue);

function findInvalidAncestor(node) {
const parent = util.nullThrows(node.parent, util.NullThrowsReasons.MissingParent);
const parent = (0, util_1.nullThrows)(node.parent, util_1.NullThrowsReasons.MissingParent);
if (parent.type === utils_1.AST_NODE_TYPES.SequenceExpression) {

@@ -249,3 +256,3 @@ if (node !== parent.expressions[parent.expressions.length - 1]) {

// the parent must be a block
const block = util.nullThrows(node.parent, util.NullThrowsReasons.MissingParent);
const block = (0, util_1.nullThrows)(node.parent, util_1.NullThrowsReasons.MissingParent);
if (block.type !== utils_1.AST_NODE_TYPES.BlockStatement) {

@@ -256,3 +263,3 @@ // e.g. `if (cond) return;` (not in a block)

// the block's parent must be a function
const blockParent = util.nullThrows(block.parent, util.NullThrowsReasons.MissingParent);
const blockParent = (0, util_1.nullThrows)(block.parent, util_1.NullThrowsReasons.MissingParent);
if (![

@@ -281,7 +288,15 @@ utils_1.AST_NODE_TYPES.FunctionDeclaration,

function isPreventingASI(node, sourceCode) {
const startToken = util.nullThrows(sourceCode.getFirstToken(node), util.NullThrowsReasons.MissingToken('first token', node.type));
const startToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(node), util_1.NullThrowsReasons.MissingToken('first token', node.type));
return ['(', '[', '`'].includes(startToken.value);
}
function canFix(node) {
const services = (0, util_1.getParserServices)(context);
const targetNode = node.type === utils_1.AST_NODE_TYPES.ReturnStatement
? node.argument
: node.body;
const type = (0, util_1.getConstrainedTypeAtLocation)(services, targetNode);
return tsutils.isTypeFlagSet(type, ts.TypeFlags.VoidLike);
}
},
});
//# sourceMappingURL=no-confusing-void-expression.js.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('no-dupe-class-members');
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-dupe-class-members',

@@ -32,0 +9,0 @@ meta: {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-duplicate-enum-values',

@@ -30,0 +7,0 @@ meta: {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const astIgnoreKeys = new Set(['range', 'loc', 'parent']);

@@ -58,3 +36,3 @@ const isSameAstNode = (actualNode, expectedNode) => {

};
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-duplicate-type-constituents',

@@ -94,3 +72,3 @@ meta: {

create(context, [{ ignoreIntersections, ignoreUnions }]) {
const parserServices = util.getParserServices(context);
const parserServices = (0, util_1.getParserServices)(context);
const checker = parserServices.program.getTypeChecker();

@@ -122,3 +100,3 @@ function checkDuplicate(node) {

function reportDuplicate(duplicateConstituent, parentNode) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const beforeTokens = sourceCode.getTokensBefore(duplicateConstituent.duplicated, { filter: token => token.value === '|' || token.value === '&' });

@@ -125,0 +103,0 @@ const beforeUnionOrIntersectionToken = beforeTokens[beforeTokens.length - 1];

@@ -27,5 +27,6 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-dynamic-delete',

@@ -71,3 +72,3 @@ meta: {

function getTokenRange(property) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
return [

@@ -74,0 +75,0 @@ sourceCode.getTokenBefore(property).range[0],

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('no-empty-function');
const schema = util.deepMerge(
const schema = (0, util_1.deepMerge)(
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- https://github.com/microsoft/TypeScript/issues/17002

@@ -59,3 +36,3 @@ Array.isArray(baseRule.meta.schema)

});
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-empty-function',

@@ -91,3 +68,3 @@ meta: {

function isBodyEmpty(node) {
return !node.body || node.body.body.length === 0;
return node.body.body.length === 0;
}

@@ -101,3 +78,3 @@ /**

function hasParameterProperties(node) {
return node.params?.some(param => param.type === utils_1.AST_NODE_TYPES.TSParameterProperty);
return node.params.some(param => param.type === utils_1.AST_NODE_TYPES.TSParameterProperty);
}

@@ -112,3 +89,3 @@ /**

if (isBodyEmpty(node) &&
parent?.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
parent.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
parent.kind === 'constructor') {

@@ -133,3 +110,3 @@ const { accessibility } = parent;

if (isAllowedDecoratedFunctions && isBodyEmpty(node)) {
const decorators = node.parent?.type === utils_1.AST_NODE_TYPES.MethodDefinition
const decorators = node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition
? node.parent.decorators

@@ -144,4 +121,4 @@ : undefined;

isBodyEmpty(node) &&
node.parent?.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
node.parent.override === true);
node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
node.parent.override);
}

@@ -148,0 +125,0 @@ return {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const scope_manager_1 = require("@typescript-eslint/scope-manager");
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-empty-interface',

@@ -63,4 +41,4 @@ meta: {

TSInterfaceDeclaration(node) {
const sourceCode = context.getSourceCode();
const filename = context.getFilename();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const filename = (0, eslint_utils_1.getFilename)(context);
if (node.body.body.length !== 0) {

@@ -71,3 +49,3 @@ // interface contains members --> Nothing to report

const extend = node.extends;
if (!extend || extend.length === 0) {
if (extend.length === 0) {
context.report({

@@ -88,7 +66,7 @@ node: node.id,

};
const scope = context.getScope();
const scope = (0, eslint_utils_1.getScope)(context);
const mergedWithClassDeclaration = scope.set
.get(node.id.name)
?.defs?.some(def => def.node.type === utils_1.AST_NODE_TYPES.ClassDeclaration);
const isInAmbientDeclaration = !!(util.isDefinitionFile(filename) &&
?.defs.some(def => def.node.type === utils_1.AST_NODE_TYPES.ClassDeclaration);
const isInAmbientDeclaration = !!((0, util_1.isDefinitionFile)(filename) &&
scope.type === scope_manager_1.ScopeType.tsModule &&

@@ -95,0 +73,0 @@ scope.block.declare);

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-explicit-any',

@@ -75,11 +52,11 @@ meta: {

return [
utils_1.AST_NODE_TYPES.ArrowFunctionExpression,
utils_1.AST_NODE_TYPES.FunctionDeclaration,
utils_1.AST_NODE_TYPES.FunctionExpression,
utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
utils_1.AST_NODE_TYPES.TSFunctionType,
utils_1.AST_NODE_TYPES.TSConstructorType,
utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration,
utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration,
utils_1.AST_NODE_TYPES.TSMethodSignature,
utils_1.AST_NODE_TYPES.ArrowFunctionExpression, // const x = (...args: any[]) => {};
utils_1.AST_NODE_TYPES.FunctionDeclaration, // function f(...args: any[]) {}
utils_1.AST_NODE_TYPES.FunctionExpression, // const x = function(...args: any[]) {};
utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression, // declare class A { f(...args: any[]): unknown; }
utils_1.AST_NODE_TYPES.TSFunctionType, // type T = (...args: any[]) => unknown;
utils_1.AST_NODE_TYPES.TSConstructorType, // type T = new (...args: any[]) => unknown
utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration, // type T = {(...args: any[]): unknown};
utils_1.AST_NODE_TYPES.TSConstructSignatureDeclaration, // type T = {new (...args: any[]): unknown};
utils_1.AST_NODE_TYPES.TSMethodSignature, // type T = {f(...args: any[]): unknown};
utils_1.AST_NODE_TYPES.TSDeclareFunction, // declare function _8(...args: any[]): unknown;

@@ -116,3 +93,2 @@ ].includes(node.type);

return (node.type === utils_1.AST_NODE_TYPES.TSTypeReference &&
node.typeName !== undefined &&
node.typeName.type === utils_1.AST_NODE_TYPES.Identifier &&

@@ -138,3 +114,3 @@ ['Array', 'ReadonlyArray'].includes(node.typeName.name));

function isGreatGrandparentRestElement(node) {
return (node?.parent?.parent?.parent != null &&
return (node.parent?.parent?.parent != null &&
isNodeRestElementInFunction(node.parent.parent.parent));

@@ -141,0 +117,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-extra-non-null-assertion',

@@ -29,0 +6,0 @@ meta: {

"use strict";
// any is required to work around manipulating the AST in weird ways
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('no-extra-parens');
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-extra-parens',

@@ -47,3 +25,3 @@ meta: {

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

@@ -53,4 +31,4 @@ function binaryExp(node) {

// makes the rule think it should skip the left or right
const isLeftTypeAssertion = util.isTypeAssertion(node.left);
const isRightTypeAssertion = util.isTypeAssertion(node.right);
const isLeftTypeAssertion = (0, util_1.isTypeAssertion)(node.left);
const isRightTypeAssertion = (0, util_1.isTypeAssertion)(node.right);
if (isLeftTypeAssertion && isRightTypeAssertion) {

@@ -81,3 +59,3 @@ return; // ignore

const rule = rules.CallExpression;
if (util.isTypeAssertion(node.callee)) {
if ((0, util_1.isTypeAssertion)(node.callee)) {
// reduces the precedence of the node so the rule thinks it needs to be wrapped

@@ -94,4 +72,4 @@ return rule({

// is there any opening parenthesis in type arguments
sourceCode.getTokenAfter(node.callee, util.isOpeningParenToken) !==
sourceCode.getTokenBefore(node.arguments[0], util.isOpeningParenToken)) {
sourceCode.getTokenAfter(node.callee, util_1.isOpeningParenToken) !==
sourceCode.getTokenBefore(node.arguments[0], util_1.isOpeningParenToken)) {
return rule({

@@ -111,3 +89,3 @@ ...node,

const rule = rules.UnaryExpression;
if (util.isTypeAssertion(node.argument)) {
if ((0, util_1.isTypeAssertion)(node.argument)) {
// reduces the precedence of the node so the rule thinks it needs to be wrapped

@@ -127,3 +105,3 @@ return rule({

ArrowFunctionExpression(node) {
if (!util.isTypeAssertion(node.body)) {
if (!(0, util_1.isTypeAssertion)(node.body)) {
return rules.ArrowFunctionExpression(node);

@@ -134,3 +112,3 @@ }

AwaitExpression(node) {
if (util.isTypeAssertion(node.argument)) {
if ((0, util_1.isTypeAssertion)(node.argument)) {
// reduces the precedence of the node so the rule thinks it needs to be wrapped

@@ -175,3 +153,3 @@ return rules.AwaitExpression({

// reduces the precedence of the node so the rule thinks it needs to be wrapped
if (util.isTypeAssertion(node.test)) {
if ((0, util_1.isTypeAssertion)(node.test)) {
return rules.ConditionalExpression({

@@ -185,3 +163,3 @@ ...node,

}
if (util.isTypeAssertion(node.consequent)) {
if ((0, util_1.isTypeAssertion)(node.consequent)) {
return rules.ConditionalExpression({

@@ -195,3 +173,3 @@ ...node,

}
if (util.isTypeAssertion(node.alternate)) {
if ((0, util_1.isTypeAssertion)(node.alternate)) {
// reduces the precedence of the node so the rule thinks it needs to be wrapped

@@ -212,3 +190,3 @@ return rules.ConditionalExpression({

// make the rule skip the piece by removing it entirely
if (node.init && util.isTypeAssertion(node.init)) {
if (node.init && (0, util_1.isTypeAssertion)(node.init)) {
return rules.ForStatement({

@@ -219,3 +197,3 @@ ...node,

}
if (node.test && util.isTypeAssertion(node.test)) {
if (node.test && (0, util_1.isTypeAssertion)(node.test)) {
return rules.ForStatement({

@@ -226,3 +204,3 @@ ...node,

}
if (node.update && util.isTypeAssertion(node.update)) {
if (node.update && (0, util_1.isTypeAssertion)(node.update)) {
return rules.ForStatement({

@@ -236,3 +214,3 @@ ...node,

'ForStatement > *.init:exit'(node) {
if (!util.isTypeAssertion(node)) {
if (!(0, util_1.isTypeAssertion)(node)) {
return rules['ForStatement > *.init:exit'](node);

@@ -244,3 +222,3 @@ }

MemberExpression(node) {
if (util.isTypeAssertion(node.object)) {
if ((0, util_1.isTypeAssertion)(node.object)) {
// reduces the precedence of the node so the rule thinks it needs to be wrapped

@@ -262,3 +240,3 @@ return rules.MemberExpression({

SpreadElement(node) {
if (!util.isTypeAssertion(node.argument)) {
if (!(0, util_1.isTypeAssertion)(node.argument)) {
return rules.SpreadElement(node);

@@ -268,3 +246,3 @@ }

SwitchCase(node) {
if (node.test && !util.isTypeAssertion(node.test)) {
if (node.test && !(0, util_1.isTypeAssertion)(node.test)) {
return rules.SwitchCase(node);

@@ -275,3 +253,3 @@ }

ThrowStatement(node) {
if (node.argument && !util.isTypeAssertion(node.argument)) {
if (node.argument && !(0, util_1.isTypeAssertion)(node.argument)) {
return rules.ThrowStatement(node);

@@ -286,3 +264,3 @@ }

YieldExpression(node) {
if (node.argument && !util.isTypeAssertion(node.argument)) {
if (node.argument && !(0, util_1.isTypeAssertion)(node.argument)) {
return rules.YieldExpression(node);

@@ -292,5 +270,6 @@ }

};
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (rules.ForInStatement && rules.ForOfStatement) {
overrides.ForInStatement = function (node) {
if (util.isTypeAssertion(node.right)) {
if ((0, util_1.isTypeAssertion)(node.right)) {
// as of 7.20.0 there's no way to skip checking the right of the ForIn

@@ -303,3 +282,3 @@ // so just don't validate it at all

overrides.ForOfStatement = function (node) {
if (util.isTypeAssertion(node.right)) {
if ((0, util_1.isTypeAssertion)(node.right)) {
// makes the rule skip checking of the right

@@ -320,3 +299,3 @@ return rules.ForOfStatement({

overrides['ForInStatement, ForOfStatement'] = function (node) {
if (util.isTypeAssertion(node.right)) {
if ((0, util_1.isTypeAssertion)(node.right)) {
// makes the rule skip checking of the right

@@ -323,0 +302,0 @@ return rules['ForInStatement, ForOfStatement']({

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const util = __importStar(require("../util"));
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('no-extra-semi');
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-extra-semi',

@@ -31,0 +8,0 @@ meta: {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-extraneous-class',

@@ -30,0 +7,0 @@ meta: {

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

const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
const util_1 = require("../util");

@@ -36,3 +35,3 @@ const messageBase = 'Promises must be awaited, end with a call to .catch, or end with a call to .then with a rejection handler.';

const messageRejectionHandler = 'A rejection handler that is not a function will be ignored.';
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-floating-promises',

@@ -79,3 +78,3 @@ meta: {

create(context, [options]) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();

@@ -150,3 +149,3 @@ return {

: ts.SyntaxKind.Unknown;
const nodePrecedence = util.getOperatorPrecedence(node.kind, operator);
const nodePrecedence = (0, util_1.getOperatorPrecedence)(node.kind, operator);
return nodePrecedence > util_1.OperatorPrecedence.Unary;

@@ -158,6 +157,5 @@ }

}
return (node.expression.type === utils_1.AST_NODE_TYPES.CallExpression &&
(node.expression.callee.type ===
utils_1.AST_NODE_TYPES.ArrowFunctionExpression ||
node.expression.callee.type === utils_1.AST_NODE_TYPES.FunctionExpression));
return (node.expression.callee.type ===
utils_1.AST_NODE_TYPES.ArrowFunctionExpression ||
node.expression.callee.type === utils_1.AST_NODE_TYPES.FunctionExpression);
}

@@ -164,0 +162,0 @@ function isValidRejectionHandler(rejectionHandler) {

@@ -27,4 +27,4 @@ "use strict";

const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-for-in-array',

@@ -47,6 +47,6 @@ meta: {

ForInStatement(node) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();
const type = util.getConstrainedTypeAtLocation(services, node.right);
if (util.isTypeArrayTypeOrUnionOfArrayTypes(type, checker) ||
const type = (0, util_1.getConstrainedTypeAtLocation)(services, node.right);
if ((0, util_1.isTypeArrayTypeOrUnionOfArrayTypes)(type, checker) ||
(type.flags & ts.TypeFlags.StringLike) !== 0) {

@@ -53,0 +53,0 @@ context.report({

@@ -27,5 +27,6 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
const FUNCTION_CONSTRUCTOR = 'Function';

@@ -39,3 +40,3 @@ const GLOBAL_CANDIDATES = new Set(['global', 'window', 'globalThis']);

]);
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-implied-eval',

@@ -58,3 +59,3 @@ meta: {

create(context) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();

@@ -119,5 +120,3 @@ function getCalleeName(node) {

function isReferenceToGlobalFunction(calleeName) {
const ref = context
.getScope()
.references.find(ref => ref.identifier.name === calleeName);
const ref = (0, eslint_utils_1.getScope)(context).references.find(ref => ref.identifier.name === calleeName);
// ensure it's the "global" version

@@ -124,0 +123,0 @@ return !ref?.resolved || ref.resolved.defs.length === 0;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-import-type-side-effects',

@@ -43,3 +21,3 @@ meta: {

create(context) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
return {

@@ -64,3 +42,3 @@ 'ImportDeclaration[importKind!="type"]'(node) {

for (const specifier of specifiers) {
const qualifier = util.nullThrows(sourceCode.getFirstToken(specifier, util.isTypeKeyword), util.NullThrowsReasons.MissingToken('type keyword', 'import specifier'));
const qualifier = (0, util_1.nullThrows)(sourceCode.getFirstToken(specifier, util_1.isTypeKeyword), util_1.NullThrowsReasons.MissingToken('type keyword', 'import specifier'));
fixes.push(fixer.removeRange([

@@ -71,3 +49,3 @@ qualifier.range[0],

}
const importKeyword = util.nullThrows(sourceCode.getFirstToken(node, util.isImportKeyword), util.NullThrowsReasons.MissingToken('import keyword', 'import'));
const importKeyword = (0, util_1.nullThrows)(sourceCode.getFirstToken(node, util_1.isImportKeyword), util_1.NullThrowsReasons.MissingToken('import keyword', 'import'));
fixes.push(fixer.insertTextAfter(importKeyword, ' type'));

@@ -74,0 +52,0 @@ return fixes;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-inferrable-types',

@@ -62,3 +40,3 @@ meta: {

create(context, [{ ignoreParameters, ignoreProperties }]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
function isFunctionCall(init, callName) {

@@ -147,3 +125,3 @@ if (init.type === utils_1.AST_NODE_TYPES.ChainExpression) {

function reportInferrableType(node, typeNode, initNode) {
if (!typeNode || !initNode || !typeNode.typeAnnotation) {
if (!typeNode || !initNode) {
return;

@@ -175,9 +153,6 @@ }

function inferrableVariableVisitor(node) {
if (!node.id) {
return;
}
reportInferrableType(node, node.id.typeAnnotation, node.init);
}
function inferrableParameterVisitor(node) {
if (ignoreParameters || !node.params) {
if (ignoreParameters) {
return;

@@ -189,5 +164,3 @@ }

}
if (param.type === utils_1.AST_NODE_TYPES.AssignmentPattern &&
param.left &&
param.right) {
if (param.type === utils_1.AST_NODE_TYPES.AssignmentPattern) {
reportInferrableType(param, param.left.typeAnnotation, param.right);

@@ -194,0 +167,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-invalid-void-type',

@@ -97,4 +75,4 @@ meta: {

/* istanbul ignore next */
if (node.parent?.type !== utils_1.AST_NODE_TYPES.TSTypeParameterInstantiation ||
node.parent.parent?.type !== utils_1.AST_NODE_TYPES.TSTypeReference) {
if (node.parent.type !== utils_1.AST_NODE_TYPES.TSTypeParameterInstantiation ||
node.parent.parent.type !== utils_1.AST_NODE_TYPES.TSTypeReference) {
return;

@@ -104,3 +82,3 @@ }

if (Array.isArray(allowInGenericTypeArguments)) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const fullyQualifiedName = sourceCode

@@ -151,3 +129,3 @@ .getText(node.parent.parent.typeName)

utils_1.AST_NODE_TYPES.TSTypeParameterInstantiation &&
member.typeArguments?.params
member.typeArguments.params
.map(param => param.type)

@@ -154,0 +132,0 @@ .includes(utils_1.AST_NODE_TYPES.TSVoidKeyword)));

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('no-loop-func');
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-loop-func',

@@ -57,3 +35,3 @@ meta: {

}
const references = context.getScope().through;
const references = (0, eslint_utils_1.getScope)(context).through;
const unsafeRefs = references

@@ -188,3 +166,3 @@ .filter(r => !isSafe(loopNode, r))

return (!upperRef.isWrite() ||
(variable?.scope?.variableScope === upperRef.from.variableScope &&
(variable?.scope.variableScope === upperRef.from.variableScope &&
id.range[0] < border));

@@ -191,0 +169,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const util = __importStar(require("../util"));
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.maybeGetESLintCoreRule)('no-loss-of-precision');
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-loss-of-precision',

@@ -31,0 +8,0 @@ meta: {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('no-magic-numbers');
// Extend base schema with additional property to ignore TS numeric literal types
const schema = util.deepMerge(
const schema = (0, util_1.deepMerge)(
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- https://github.com/microsoft/TypeScript/issues/17002

@@ -51,3 +28,3 @@ Array.isArray(baseRule.meta.schema)

});
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-magic-numbers',

@@ -111,3 +88,3 @@ meta: {

let raw = node.raw;
if (node.parent?.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
if (node.parent.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
// the base rule only shows the operator for negative numbers

@@ -136,3 +113,3 @@ // https://github.com/eslint/eslint/blob/9dfc8501fb1956c90dc11e6377b4cb38a6bea65d/lib/rules/no-magic-numbers.js#L126

function getLiteralParent(node) {
if (node.parent?.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
if (node.parent.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
['-', '+'].includes(node.parent.operator)) {

@@ -139,0 +116,0 @@ return node.parent.parent;

@@ -27,6 +27,7 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-meaningless-void-operator',

@@ -63,3 +64,3 @@ meta: {

const checker = services.program.getTypeChecker();
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
return {

@@ -66,0 +67,0 @@ 'UnaryExpression[operator="void"]'(node) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-misused-new',

@@ -30,0 +7,0 @@ meta: {

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

const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
function parseChecksVoidReturn(checksVoidReturn) {

@@ -54,3 +54,3 @@ switch (checksVoidReturn) {

}
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-misused-promises',

@@ -112,3 +112,3 @@ meta: {

create(context, [{ checksConditionals, checksVoidReturn, checksSpreads }]) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();

@@ -450,3 +450,3 @@ const checkedNodes = new Set();

// 'param: MaybeVoidFunction'
type = util.getTypeArguments(type, checker)[0];
type = checker.getTypeArguments(type)[0];
for (let i = index; i < node.arguments.length; i++) {

@@ -459,3 +459,3 @@ checkThenableOrVoidArgument(checker, node, type, i, thenableReturnIndices, voidReturnIndices);

// add the index of the second tuple parameter to 'voidReturnIndices'
const typeArgs = util.getTypeArguments(type, checker);
const typeArgs = checker.getTypeArguments(type);
for (let i = index; i < node.arguments.length && i - index < typeArgs.length; i++) {

@@ -462,0 +462,0 @@ checkThenableOrVoidArgument(checker, node, typeArgs[i - index], i, thenableReturnIndices, voidReturnIndices);

@@ -28,5 +28,6 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
var AllowedType;

@@ -38,3 +39,3 @@ (function (AllowedType) {

})(AllowedType || (AllowedType = {}));
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-mixed-enums',

@@ -55,3 +56,3 @@ meta: {

create(context) {
const parserServices = util.getParserServices(context);
const parserServices = (0, util_1.getParserServices)(context);
const typeChecker = parserServices.program.getTypeChecker();

@@ -64,3 +65,3 @@ function collectNodeDefinitions(node) {

};
let scope = context.getScope();
let scope = (0, eslint_utils_1.getScope)(context);
for (const definition of scope.upper?.set.get(name)?.defs ?? []) {

@@ -75,3 +76,3 @@ if (definition.node.type === utils_1.AST_NODE_TYPES.TSEnumDeclaration &&

while (scope) {
scope.set.get(name)?.defs?.forEach(definition => {
scope.set.get(name)?.defs.forEach(definition => {
if (definition.type === scope_manager_1.DefinitionType.ImportBinding) {

@@ -185,4 +186,3 @@ found.imports.push(definition.node);

}
if (currentType !== desiredType &&
(currentType !== undefined || desiredType === AllowedType.String)) {
if (currentType !== desiredType) {
context.report({

@@ -189,0 +189,0 @@ messageId: 'mixed',

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-namespace',

@@ -63,6 +41,5 @@ meta: {

create(context, [{ allowDeclarations, allowDefinitionFiles }]) {
const filename = context.getFilename();
const filename = (0, eslint_utils_1.getFilename)(context);
function isDeclaration(node) {
if (node.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration &&
node.declare === true) {
if (node.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration && node.declare) {
return true;

@@ -75,3 +52,3 @@ }

if (node.parent.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration ||
(allowDefinitionFiles && util.isDefinitionFile(filename)) ||
(allowDefinitionFiles && (0, util_1.isDefinitionFile)(filename)) ||
(allowDeclarations && isDeclaration(node))) {

@@ -78,0 +55,0 @@ return;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const scope_manager_1 = require("@typescript-eslint/scope-manager");
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
function hasAssignmentBeforeNode(variable, node) {

@@ -38,5 +16,5 @@ return (variable.references.some(ref => ref.isWrite() && ref.identifier.range[1] < node.range[1]) ||

const variableDeclarator = definition.node;
return (variableDeclarator.definite === true || variableDeclarator.init != null);
return variableDeclarator.definite || variableDeclarator.init != null;
}
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-non-null-asserted-nullish-coalescing',

@@ -61,3 +39,3 @@ meta: {

if (node.expression.type === utils_1.TSESTree.AST_NODE_TYPES.Identifier) {
const scope = context.getScope();
const scope = (0, eslint_utils_1.getScope)(context);
const identifier = node.expression;

@@ -69,3 +47,3 @@ const variable = utils_1.ASTUtils.findVariable(scope, identifier.name);

}
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
context.report({

@@ -91,3 +69,3 @@ node,

fix(fixer) {
const exclamationMark = util.nullThrows(sourceCode.getLastToken(node, utils_1.ASTUtils.isNonNullAssertionPunctuator), util.NullThrowsReasons.MissingToken('!', 'Non-null Assertion'));
const exclamationMark = (0, util_1.nullThrows)(sourceCode.getLastToken(node, utils_1.ASTUtils.isNonNullAssertionPunctuator), util_1.NullThrowsReasons.MissingToken('!', 'Non-null Assertion'));
return fixer.remove(exclamationMark);

@@ -94,0 +72,0 @@ },

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-non-null-asserted-optional-chain',

@@ -29,0 +6,0 @@ meta: {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-non-null-assertion',

@@ -45,3 +23,3 @@ meta: {

create(context) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
return {

@@ -52,3 +30,3 @@ TSNonNullExpression(node) {

return (fixer) => {
const operator = sourceCode.getTokenAfter(node.expression, util.isNonNullAssertionPunctuator);
const operator = sourceCode.getTokenAfter(node.expression, util_1.isNonNullAssertionPunctuator);
if (operator) {

@@ -62,3 +40,3 @@ return fixer.replaceText(operator, replacement);

return (fixer) => {
const operator = sourceCode.getTokenAfter(node.expression, util.isNonNullAssertionPunctuator);
const operator = sourceCode.getTokenAfter(node.expression, util_1.isNonNullAssertionPunctuator);
if (operator) {

@@ -70,3 +48,3 @@ return fixer.remove(operator);

}
if (node.parent?.type === utils_1.AST_NODE_TYPES.MemberExpression &&
if (node.parent.type === utils_1.AST_NODE_TYPES.MemberExpression &&
node.parent.object === node) {

@@ -106,3 +84,3 @@ if (!node.parent.optional) {

}
else if (node.parent?.type === utils_1.AST_NODE_TYPES.CallExpression &&
else if (node.parent.type === utils_1.AST_NODE_TYPES.CallExpression &&
node.parent.callee === node) {

@@ -109,0 +87,0 @@ if (!node.parent.optional) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const scope_manager_1 = require("@typescript-eslint/scope-manager");
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-redeclare',

@@ -64,3 +42,3 @@ meta: {

create(context, [options]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const CLASS_DECLARATION_MERGE_NODES = new Set([

@@ -80,3 +58,3 @@ utils_1.AST_NODE_TYPES.TSInterfaceDeclaration,

function* iterateDeclarations(variable) {
if (options?.builtinGlobals &&
if (options.builtinGlobals &&
'eslintImplicitGlobalSetting' in variable &&

@@ -93,3 +71,3 @@ (variable.eslintImplicitGlobalSetting === 'readonly' ||

node: comment,
loc: util.getNameLocationInGlobalDirectiveComment(sourceCode, comment, variable.name),
loc: (0, util_1.getNameLocationInGlobalDirectiveComment)(sourceCode, comment, variable.name),
};

@@ -194,3 +172,3 @@ }

function checkForBlock(node) {
const scope = context.getScope();
const scope = (0, eslint_utils_1.getScope)(context);
/*

@@ -206,3 +184,3 @@ * In ES5, some node type such as `BlockStatement` doesn't have that scope.

Program() {
const scope = context.getScope();
const scope = (0, eslint_utils_1.getScope)(context);
findVariablesInScope(scope);

@@ -209,0 +187,0 @@ // Node.js or ES modules has a special scope.

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

const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
const literalToPrimitiveTypeFlags = {

@@ -85,3 +85,3 @@ [ts.TypeFlags.BigIntLiteral]: ts.TypeFlags.BigInt,

}
if (util.isTypeBigIntLiteralType(type)) {
if ((0, util_1.isTypeBigIntLiteralType)(type)) {
return `${type.value.negative ? '-' : ''}${type.value.base10Value}n`;

@@ -93,15 +93,15 @@ }

}
if (util.isTypeAnyType(type)) {
if ((0, util_1.isTypeAnyType)(type)) {
return 'any';
}
if (util.isTypeNeverType(type)) {
if ((0, util_1.isTypeNeverType)(type)) {
return 'never';
}
if (util.isTypeUnknownType(type)) {
if ((0, util_1.isTypeUnknownType)(type)) {
return 'unknown';
}
if (util.isTypeTemplateLiteralType(type)) {
if ((0, util_1.isTypeTemplateLiteralType)(type)) {
return 'template literal type';
}
if (util.isTypeBigIntLiteralType(type)) {
if ((0, util_1.isTypeBigIntLiteralType)(type)) {
return `${type.value.negative ? '-' : ''}${type.value.base10Value}n`;

@@ -149,5 +149,4 @@ }

function isNodeInsideReturnType(node) {
return !!(node.parent?.type === utils_1.AST_NODE_TYPES.TSTypeAnnotation &&
(util.isFunctionType(node.parent.parent) ||
util.isFunction(node.parent.parent)));
return !!(node.parent.type === utils_1.AST_NODE_TYPES.TSTypeAnnotation &&
((0, util_1.isFunctionType)(node.parent.parent) || (0, util_1.isFunction)(node.parent.parent)));
}

@@ -165,3 +164,3 @@ /**

}
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-redundant-type-constituents',

@@ -185,3 +184,3 @@ meta: {

create(context) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const typesCache = new Map();

@@ -363,3 +362,3 @@ function getTypeNodeTypePartFlags(typeNode) {

for (const [typeNode, typeFlagsWithText] of overriddenTypeNodes) {
const grouped = util.arrayGroupByToMap(typeFlagsWithText, pair => pair.primitiveTypeFlag);
const grouped = (0, util_1.arrayGroupByToMap)(typeFlagsWithText, pair => pair.primitiveTypeFlag);
for (const [primitiveTypeFlag, pairs] of grouped) {

@@ -366,0 +365,0 @@ context.report({

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-require-imports',

@@ -44,3 +22,3 @@ meta: {

'CallExpression[callee.name="require"]'(node) {
const variable = utils_1.ASTUtils.findVariable(context.getScope(), 'require');
const variable = utils_1.ASTUtils.findVariable((0, eslint_utils_1.getScope)(context), 'require');
// ignore non-global require usage as it's something user-land custom instead

@@ -47,0 +25,0 @@ // of the commonjs standard

@@ -171,20 +171,45 @@ "use strict";

}
return {
ImportDeclaration(node) {
if (node.importKind === 'type' ||
function checkImportNode(node) {
if (node.importKind === 'type' ||
(node.specifiers.length > 0 &&
node.specifiers.every(specifier => specifier.type === utils_1.AST_NODE_TYPES.ImportSpecifier &&
specifier.importKind === 'type')) {
const importSource = node.source.value.trim();
if (!isAllowedTypeImportPath(importSource) &&
!isAllowedTypeImportPattern(importSource)) {
return rules.ImportDeclaration(node);
}
}
else {
specifier.importKind === 'type'))) {
const importSource = node.source.value.trim();
if (!isAllowedTypeImportPath(importSource) &&
!isAllowedTypeImportPattern(importSource)) {
return rules.ImportDeclaration(node);
}
}
else {
return rules.ImportDeclaration(node);
}
}
return {
TSImportEqualsDeclaration(node) {
if (node.moduleReference.type ===
utils_1.AST_NODE_TYPES.TSExternalModuleReference &&
node.moduleReference.expression.type === utils_1.AST_NODE_TYPES.Literal &&
typeof node.moduleReference.expression.value === 'string') {
const synthesizedImport = {
...node,
type: utils_1.AST_NODE_TYPES.ImportDeclaration,
source: node.moduleReference.expression,
assertions: [],
attributes: [],
specifiers: [
{
...node.id,
type: utils_1.AST_NODE_TYPES.ImportDefaultSpecifier,
local: node.id,
},
],
};
return checkImportNode(synthesizedImport);
}
},
ImportDeclaration: checkImportNode,
'ExportNamedDeclaration[source]'(node) {
if (node.exportKind === 'type' ||
node.specifiers.every(specifier => specifier.exportKind === 'type')) {
(node.specifiers.length > 0 &&
node.specifiers.every(specifier => specifier.exportKind === 'type'))) {
const importSource = node.source.value.trim();

@@ -191,0 +216,0 @@ if (!isAllowedTypeImportPath(importSource) &&

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const scope_manager_1 = require("@typescript-eslint/scope-manager");
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const allowedFunctionVariableDefTypes = new Set([

@@ -34,3 +12,3 @@ utils_1.AST_NODE_TYPES.TSCallSignatureDeclaration,

]);
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-shadow',

@@ -117,3 +95,3 @@ meta: {

}
const [firstDefinition] = shadowed.defs;
const firstDefinition = shadowed.defs.at(0);
const isShadowedValue = !('isValueVariable' in shadowed) ||

@@ -150,17 +128,16 @@ !firstDefinition ||

const typeParameter = variable.identifiers[0].parent;
if (typeParameter?.type !== utils_1.AST_NODE_TYPES.TSTypeParameter) {
if (typeParameter.type !== utils_1.AST_NODE_TYPES.TSTypeParameter) {
return false;
}
const typeParameterDecl = typeParameter.parent;
if (typeParameterDecl?.type !== utils_1.AST_NODE_TYPES.TSTypeParameterDeclaration) {
if (typeParameterDecl.type !== utils_1.AST_NODE_TYPES.TSTypeParameterDeclaration) {
return false;
}
const functionExpr = typeParameterDecl.parent;
if (!functionExpr ||
(functionExpr.type !== utils_1.AST_NODE_TYPES.FunctionExpression &&
functionExpr.type !== utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression)) {
if (functionExpr.type !== utils_1.AST_NODE_TYPES.FunctionExpression &&
functionExpr.type !== utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression) {
return false;
}
const methodDefinition = functionExpr.parent;
if (methodDefinition?.type !== utils_1.AST_NODE_TYPES.MethodDefinition) {
if (methodDefinition.type !== utils_1.AST_NODE_TYPES.MethodDefinition) {
return false;

@@ -170,3 +147,3 @@ }

}
function isGenericOfClassDecl(variable) {
function isGenericOfClass(variable) {
if (!('isTypeVariable' in variable)) {

@@ -183,14 +160,15 @@ // this shouldn't happen...

const typeParameter = variable.identifiers[0].parent;
if (typeParameter?.type !== utils_1.AST_NODE_TYPES.TSTypeParameter) {
if (typeParameter.type !== utils_1.AST_NODE_TYPES.TSTypeParameter) {
return false;
}
const typeParameterDecl = typeParameter.parent;
if (typeParameterDecl?.type !== utils_1.AST_NODE_TYPES.TSTypeParameterDeclaration) {
if (typeParameterDecl.type !== utils_1.AST_NODE_TYPES.TSTypeParameterDeclaration) {
return false;
}
const classDecl = typeParameterDecl.parent;
return classDecl?.type === utils_1.AST_NODE_TYPES.ClassDeclaration;
return (classDecl.type === utils_1.AST_NODE_TYPES.ClassDeclaration ||
classDecl.type === utils_1.AST_NODE_TYPES.ClassExpression);
}
function isGenericOfAStaticMethodShadow(variable, shadowed) {
return (isGenericOfStaticMethod(variable) && isGenericOfClassDecl(shadowed));
return isGenericOfStaticMethod(variable) && isGenericOfClass(shadowed);
}

@@ -202,3 +180,2 @@ function isImportDeclaration(definition) {

return (scope.type === scope_manager_1.ScopeType.tsModule &&
scope.block.type === utils_1.AST_NODE_TYPES.TSModuleDeclaration &&
scope.block.id.type === utils_1.AST_NODE_TYPES.Literal &&

@@ -214,3 +191,3 @@ scope.block.id.value === name);

secondDefinition.node.type === utils_1.AST_NODE_TYPES.TSInterfaceDeclaration &&
secondDefinition.node.parent?.type ===
secondDefinition.node.parent.type ===
utils_1.AST_NODE_TYPES.ExportNamedDeclaration);

@@ -224,3 +201,3 @@ }

function isAllowed(variable) {
return options.allow.indexOf(variable.name) !== -1;
return options.allow.includes(variable.name);
}

@@ -294,3 +271,3 @@ /**

function isInitPatternNode(variable, shadowedVariable) {
const outerDef = shadowedVariable.defs[0];
const outerDef = shadowedVariable.defs.at(0);
if (!outerDef) {

@@ -319,4 +296,4 @@ return false;

}
if ((node.parent?.parent?.type === utils_1.AST_NODE_TYPES.ForInStatement ||
node.parent?.parent?.type === utils_1.AST_NODE_TYPES.ForOfStatement) &&
if ((node.parent.parent?.type === utils_1.AST_NODE_TYPES.ForInStatement ||
node.parent.parent?.type === utils_1.AST_NODE_TYPES.ForOfStatement) &&
isInRange(node.parent.parent.right, location)) {

@@ -359,6 +336,6 @@ return true;

const outerScope = scopeVar.scope;
const outerDef = scopeVar.defs[0];
const outerDef = scopeVar.defs.at(0);
const outer = outerDef?.parent?.range;
const innerScope = variable.scope;
const innerDef = variable.defs[0];
const innerDef = variable.defs.at(0);
const inner = innerDef?.name.range;

@@ -380,3 +357,3 @@ return !!(outer &&

function getNameRange(variable) {
const def = variable.defs[0];
const def = variable.defs.at(0);
return def?.name.range;

@@ -391,3 +368,3 @@ }

function isInTdz(variable, scopeVar) {
const outerDef = scopeVar.defs[0];
const outerDef = scopeVar.defs.at(0);
const inner = getNameRange(variable);

@@ -409,3 +386,3 @@ const outer = getNameRange(scopeVar);

function getDeclaredLocation(variable) {
const identifier = variable.identifiers[0];
const identifier = variable.identifiers.at(0);
if (identifier) {

@@ -508,3 +485,3 @@ return {

'Program:exit'() {
const globalScope = context.getScope();
const globalScope = (0, eslint_utils_1.getScope)(context);
const stack = globalScope.childScopes.slice();

@@ -511,0 +488,0 @@ while (stack.length) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-this-alias',

@@ -30,0 +7,0 @@ meta: {

@@ -28,4 +28,4 @@ "use strict";

const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-throw-literal',

@@ -66,3 +66,3 @@ meta: {

create(context, [options]) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();

@@ -108,6 +108,6 @@ function isErrorLike(type) {

}
if (options.allowThrowingAny && util.isTypeAnyType(type)) {
if (options.allowThrowingAny && (0, util_1.isTypeAnyType)(type)) {
return;
}
if (options.allowThrowingUnknown && util.isTypeUnknownType(type)) {
if (options.allowThrowingUnknown && (0, util_1.isTypeUnknownType)(type)) {
return;

@@ -114,0 +114,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-type-alias',

@@ -30,0 +7,0 @@ meta: {

@@ -27,6 +27,7 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-unnecessary-boolean-literal-compare',

@@ -72,4 +73,4 @@ meta: {

create(context, [options]) {
const services = util.getParserServices(context);
const sourceCode = context.getSourceCode();
const services = (0, util_1.getParserServices)(context);
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
function getBooleanComparison(node) {

@@ -173,3 +174,3 @@ const comparison = deconstructComparison(node);

// 3. negated - is expression negated
const isUnaryNegation = node.parent != null && nodeIsUnaryNegation(node.parent);
const isUnaryNegation = nodeIsUnaryNegation(node.parent);
const shouldNegate = comparison.negated !== comparison.literalBooleanInComparison;

@@ -182,3 +183,3 @@ const mutatedNode = isUnaryNegation ? node.parent : node;

// if the expression `exp` is not a strong precedence node, wrap it in parentheses
if (!util.isStrongPrecedenceNode(comparison.expression)) {
if (!(0, util_1.isStrongPrecedenceNode)(comparison.expression)) {
yield fixer.insertTextBefore(mutatedNode, '(');

@@ -185,0 +186,0 @@ yield fixer.insertTextAfter(mutatedNode, ')');

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

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));

@@ -38,2 +39,5 @@ const ts = __importStar(require("typescript"));

.unionTypeParts(type)
// Intersections like `string & {}` can also be possibly falsy,
// requiring us to look into the intersection.
.flatMap(type => tsutils.intersectionTypeParts(type))
// PossiblyFalsy flag includes literal values, so exclude ones that

@@ -43,3 +47,9 @@ // are definitely truthy

.some(type => (0, util_1.isTypeFlagSet)(type, ts.TypeFlags.PossiblyFalsy));
const isPossiblyTruthy = (type) => tsutils.unionTypeParts(type).some(type => !tsutils.isFalsyType(type));
const isPossiblyTruthy = (type) => tsutils
.unionTypeParts(type)
.map(type => tsutils.intersectionTypeParts(type))
.some(intersectionParts =>
// It is possible to define intersections that are always falsy,
// like `"" & { __brand: string }`.
intersectionParts.every(type => !tsutils.isFalsyType(type)));
// Nullish utilities

@@ -105,3 +115,3 @@ const nullishFlag = ts.TypeFlags.Undefined | ts.TypeFlags.Null;

const checker = services.program.getTypeChecker();
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const compilerOptions = services.program.getCompilerOptions();

@@ -328,5 +338,4 @@ const isStrictNullChecks = tsutils.isStrictCompilerOptionEnabled(compilerOptions, 'strictNullChecks');

// Inline defined functions
if ((callback.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression ||
callback.type === utils_1.AST_NODE_TYPES.FunctionExpression) &&
callback.body) {
if (callback.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression ||
callback.type === utils_1.AST_NODE_TYPES.FunctionExpression) {
// Two special cases, where we can directly check the node that's returned:

@@ -404,6 +413,5 @@ // () => something

const typeName = (0, util_1.getTypeName)(checker, propertyType);
return !!((typeName === 'string' &&
checker.getIndexInfoOfType(objType, ts.IndexKind.String)) ||
(typeName === 'number' &&
checker.getIndexInfoOfType(objType, ts.IndexKind.Number)));
return !!checker
.getIndexInfosOfType(objType)
.find(info => (0, util_1.getTypeName)(checker, info.keyType) === typeName);
}

@@ -410,0 +418,0 @@ // Checks whether a member expression is nullable or not regardless of it's previous node.

@@ -27,6 +27,7 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-unnecessary-qualifier',

@@ -49,6 +50,6 @@ meta: {

let currentFailedNamespaceExpression = null;
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const esTreeNodeToTSNodeMap = services.esTreeNodeToTSNodeMap;
const checker = services.program.getTypeChecker();
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
function tryGetAliasedSymbol(symbol, checker) {

@@ -126,3 +127,5 @@ return tsutils.isSymbolFlagSet(symbol, ts.SymbolFlags.Alias)

return {
TSModuleDeclaration: enterDeclaration,
'TSModuleDeclaration > TSModuleBlock'(node) {
enterDeclaration(node.parent);
},
TSEnumDeclaration: enterDeclaration,

@@ -129,0 +132,0 @@ 'ExportNamedDeclaration[declaration.type="TSModuleDeclaration"]': enterDeclaration,

@@ -28,5 +28,4 @@ "use strict";

const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-unnecessary-type-arguments',

@@ -48,9 +47,9 @@ meta: {

create(context) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();
function getTypeForComparison(type) {
if (util.isTypeReferenceType(type)) {
if ((0, util_1.isTypeReferenceType)(type)) {
return {
type: type.target,
typeArguments: util.getTypeArguments(type, checker),
typeArguments: checker.getTypeArguments(type),
};

@@ -67,3 +66,3 @@ }

const arg = esParameters.params[i];
const param = typeParameters[i];
const param = typeParameters.at(i);
if (!param?.default) {

@@ -70,0 +69,0 @@ return;

@@ -27,6 +27,7 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-unnecessary-type-assertion',

@@ -63,4 +64,4 @@ meta: {

create(context, [options]) {
const sourceCode = context.getSourceCode();
const services = util.getParserServices(context);
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();

@@ -99,3 +100,3 @@ const compilerOptions = services.program.getCompilerOptions();

function isPossiblyUsedBeforeAssigned(node) {
const declaration = util.getDeclaration(services, node);
const declaration = (0, util_1.getDeclaration)(services, node);
if (!declaration) {

@@ -117,3 +118,3 @@ // don't know what the declaration is for some reason, so just assume the worst

const declarationType = checker.getTypeFromTypeNode(declaration.type);
const type = util.getConstrainedTypeAtLocation(services, node);
const type = (0, util_1.getConstrainedTypeAtLocation)(services, node);
if (declarationType === type) {

@@ -137,3 +138,3 @@ // possibly used before assigned, so just skip it

TSNonNullExpression(node) {
if (node.parent?.type === utils_1.AST_NODE_TYPES.AssignmentExpression &&
if (node.parent.type === utils_1.AST_NODE_TYPES.AssignmentExpression &&
node.parent.operator === '=') {

@@ -159,4 +160,4 @@ if (node.parent.left === node) {

const originalNode = services.esTreeNodeToTSNodeMap.get(node);
const type = util.getConstrainedTypeAtLocation(services, node.expression);
if (!util.isNullableType(type)) {
const type = (0, util_1.getConstrainedTypeAtLocation)(services, node.expression);
if (!(0, util_1.isNullableType)(type)) {
if (isPossiblyUsedBeforeAssigned(node.expression)) {

@@ -179,10 +180,10 @@ return;

// so figure out if the variable is used in a place that accepts nullable types
const contextualType = util.getContextualType(checker, originalNode);
const contextualType = (0, util_1.getContextualType)(checker, originalNode);
if (contextualType) {
// in strict mode you can't assign null to undefined, so we have to make sure that
// the two types share a nullable type
const typeIncludesUndefined = util.isTypeFlagSet(type, ts.TypeFlags.Undefined);
const typeIncludesNull = util.isTypeFlagSet(type, ts.TypeFlags.Null);
const contextualTypeIncludesUndefined = util.isTypeFlagSet(contextualType, ts.TypeFlags.Undefined);
const contextualTypeIncludesNull = util.isTypeFlagSet(contextualType, ts.TypeFlags.Null);
const typeIncludesUndefined = (0, util_1.isTypeFlagSet)(type, ts.TypeFlags.Undefined);
const typeIncludesNull = (0, util_1.isTypeFlagSet)(type, ts.TypeFlags.Null);
const contextualTypeIncludesUndefined = (0, util_1.isTypeFlagSet)(contextualType, ts.TypeFlags.Undefined);
const contextualTypeIncludesNull = (0, util_1.isTypeFlagSet)(contextualType, ts.TypeFlags.Null);
// make sure that the parent accepts the same types

@@ -217,3 +218,3 @@ // i.e. assigning `string | null | undefined` to `string | undefined` is invalid

const castType = services.getTypeAtLocation(node);
if (tsutils.isTypeFlagSet(castType, ts.TypeFlags.Literal) ||
if ((0, util_1.isTypeFlagSet)(castType, ts.TypeFlags.Literal) ||
(tsutils.isObjectType(castType) &&

@@ -220,0 +221,0 @@ (tsutils.isObjectFlagSet(castType, ts.ObjectFlags.Tuple) ||

@@ -27,6 +27,7 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const path_1 = require("path");
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-unnecessary-type-constraint',

@@ -66,4 +67,4 @@ meta: {

}
const requiresGenericDeclarationDisambiguation = checkRequiresGenericDeclarationDisambiguation(context.getFilename());
const source = context.getSourceCode();
const requiresGenericDeclarationDisambiguation = checkRequiresGenericDeclarationDisambiguation((0, eslint_utils_1.getFilename)(context));
const source = (0, eslint_utils_1.getSourceCode)(context);
const checkNode = (node, inArrowFunction) => {

@@ -70,0 +71,0 @@ const constraint = unnecessaryConstraints.get(node.constraint.type);

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

const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
class FunctionSignature {

@@ -47,3 +47,3 @@ static create(checker, tsNode) {

restType = {
type: util.getTypeArguments(type, checker)[0],
type: checker.getTypeArguments(type)[0],
kind: 0 /* RestTypeKind.Array */,

@@ -55,3 +55,3 @@ index: i,

restType = {
typeArguments: util.getTypeArguments(type, checker),
typeArguments: checker.getTypeArguments(type),
kind: 1 /* RestTypeKind.Tuple */,

@@ -114,3 +114,3 @@ index: i,

}
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-unsafe-argument',

@@ -134,3 +134,3 @@ meta: {

create(context) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();

@@ -143,3 +143,3 @@ return {

// ignore any-typed calls as these are caught by no-unsafe-call
if (util.isTypeAnyType(services.getTypeAtLocation(node.callee))) {
if ((0, util_1.isTypeAnyType)(services.getTypeAtLocation(node.callee))) {
return;

@@ -157,3 +157,3 @@ }

const spreadArgType = services.getTypeAtLocation(argument.argument);
if (util.isTypeAnyType(spreadArgType)) {
if ((0, util_1.isTypeAnyType)(spreadArgType)) {
// foo(...any)

@@ -165,3 +165,3 @@ context.report({

}
else if (util.isTypeAnyArrayType(spreadArgType, checker)) {
else if ((0, util_1.isTypeAnyArrayType)(spreadArgType, checker)) {
// foo(...any[])

@@ -176,3 +176,3 @@ // TODO - we could break down the spread and compare the array type against each argument

// foo(...[tuple1, tuple2])
const spreadTypeArguments = util.getTypeArguments(spreadArgType, checker);
const spreadTypeArguments = checker.getTypeArguments(spreadArgType);
for (const tupleType of spreadTypeArguments) {

@@ -183,3 +183,3 @@ const parameterType = signature.getNextParameterType();

}
const result = util.isUnsafeAssignment(tupleType, parameterType, checker,
const result = (0, util_1.isUnsafeAssignment)(tupleType, parameterType, checker,
// we can't pass the individual tuple members in here as this will most likely be a spread variable

@@ -218,3 +218,3 @@ // not a spread array

const argumentType = services.getTypeAtLocation(argument);
const result = util.isUnsafeAssignment(argumentType, parameterType, checker, argument);
const result = (0, util_1.isUnsafeAssignment)(argumentType, parameterType, checker, argument);
if (result) {

@@ -221,0 +221,0 @@ context.report({

@@ -28,5 +28,4 @@ "use strict";

const tsutils = __importStar(require("ts-api-utils"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-unsafe-assignment',

@@ -55,3 +54,3 @@ meta: {

create(context) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();

@@ -73,3 +72,3 @@ const compilerOptions = services.program.getCompilerOptions();

// const [x] = ([] as any[]);
if (util.isTypeAnyArrayType(senderType, checker)) {
if ((0, util_1.isTypeAnyArrayType)(senderType, checker)) {
context.report({

@@ -84,3 +83,3 @@ node: receiverNode,

}
const tupleElements = util.getTypeArguments(senderType, checker);
const tupleElements = checker.getTypeArguments(senderType);
// tuple with any

@@ -103,3 +102,3 @@ // const [x] = [1 as any];

// check for the any type first so we can handle [[[x]]] = [any]
if (util.isTypeAnyType(senderType)) {
if ((0, util_1.isTypeAnyType)(senderType)) {
context.report({

@@ -145,3 +144,3 @@ node: receiverElement,

let key;
if (receiverProperty.computed === false) {
if (!receiverProperty.computed) {
key =

@@ -168,3 +167,3 @@ receiverProperty.key.type === utils_1.AST_NODE_TYPES.Identifier

// check for the any type first so we can handle {x: {y: z}} = {x: any}
if (util.isTypeAnyType(senderType)) {
if ((0, util_1.isTypeAnyType)(senderType)) {
context.report({

@@ -189,9 +188,9 @@ node: receiverProperty.value,

const receiverType = comparisonType === 2 /* ComparisonType.Contextual */
? util.getContextualType(checker, receiverTsNode) ??
? (0, util_1.getContextualType)(checker, receiverTsNode) ??
services.getTypeAtLocation(receiverNode)
: services.getTypeAtLocation(receiverNode);
const senderType = services.getTypeAtLocation(senderNode);
if (util.isTypeAnyType(senderType)) {
if ((0, util_1.isTypeAnyType)(senderType)) {
// handle cases when we assign any ==> unknown.
if (util.isTypeUnknownType(receiverType)) {
if ((0, util_1.isTypeUnknownType)(receiverType)) {
return false;

@@ -204,3 +203,3 @@ }

if (thisExpression &&
util.isTypeAnyType(util.getConstrainedTypeAtLocation(services, thisExpression))) {
(0, util_1.isTypeAnyType)((0, util_1.getConstrainedTypeAtLocation)(services, thisExpression))) {
messageId = 'anyAssignmentThis';

@@ -218,3 +217,3 @@ }

}
const result = util.isUnsafeAssignment(senderType, receiverType, checker, senderNode);
const result = (0, util_1.isUnsafeAssignment)(senderType, receiverType, checker, senderNode);
if (!result) {

@@ -243,3 +242,3 @@ return false;

'VariableDeclarator[init != null]'(node) {
const init = util.nullThrows(node.init, util.NullThrowsReasons.MissingToken(node.type, 'init'));
const init = (0, util_1.nullThrows)(node.init, util_1.NullThrowsReasons.MissingToken(node.type, 'init'));
let didReport = checkAssignment(node.id, init, node, getComparisonType(node.id.typeAnnotation));

@@ -276,4 +275,3 @@ if (!didReport) {

const restType = services.getTypeAtLocation(node.argument);
if (util.isTypeAnyType(restType) ||
util.isTypeAnyArrayType(restType, checker)) {
if ((0, util_1.isTypeAnyType)(restType) || (0, util_1.isTypeAnyArrayType)(restType, checker)) {
context.report({

@@ -286,3 +284,3 @@ node: node,

'JSXAttribute[value != null]'(node) {
const value = util.nullThrows(node.value, util.NullThrowsReasons.MissingToken(node.type, 'value'));
const value = (0, util_1.nullThrows)(node.value, util_1.NullThrowsReasons.MissingToken(node.type, 'value'));
if (value.type !== utils_1.AST_NODE_TYPES.JSXExpressionContainer ||

@@ -289,0 +287,0 @@ value.expression.type === utils_1.AST_NODE_TYPES.JSXEmptyExpression) {

@@ -27,5 +27,4 @@ "use strict";

const tsutils = __importStar(require("ts-api-utils"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-unsafe-call',

@@ -52,8 +51,8 @@ meta: {

create(context) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const compilerOptions = services.program.getCompilerOptions();
const isNoImplicitThis = tsutils.isStrictCompilerOptionEnabled(compilerOptions, 'noImplicitThis');
function checkCall(node, reportingNode, messageId) {
const type = util.getConstrainedTypeAtLocation(services, node);
if (util.isTypeAnyType(type)) {
const type = (0, util_1.getConstrainedTypeAtLocation)(services, node);
if ((0, util_1.isTypeAnyType)(type)) {
if (!isNoImplicitThis) {

@@ -63,3 +62,3 @@ // `this()` or `this.foo()` or `this.foo[bar]()`

if (thisExpression &&
util.isTypeAnyType(util.getConstrainedTypeAtLocation(services, thisExpression))) {
(0, util_1.isTypeAnyType)((0, util_1.getConstrainedTypeAtLocation)(services, thisExpression))) {
messageId = 'unsafeCallThis';

@@ -66,0 +65,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-unsafe-declaration-merging',

@@ -65,3 +43,3 @@ meta: {

// but we want the outer scope within which merged variables will sit
const currentScope = context.getScope().upper;
const currentScope = (0, eslint_utils_1.getScope)(context).upper;
if (currentScope == null) {

@@ -74,3 +52,3 @@ return;

TSInterfaceDeclaration(node) {
checkUnsafeDeclaration(context.getScope(), node.id, utils_1.AST_NODE_TYPES.ClassDeclaration);
checkUnsafeDeclaration((0, eslint_utils_1.getScope)(context), node.id, utils_1.AST_NODE_TYPES.ClassDeclaration);
},

@@ -77,0 +55,0 @@ };

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

const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
const shared_1 = require("./enum-utils/shared");

@@ -45,4 +45,4 @@ /**

function getEnumValueType(type) {
return util.isTypeFlagSet(type, ts.TypeFlags.EnumLike)
? util.isTypeFlagSet(type, ts.TypeFlags.NumberLiteral)
return tsutils.isTypeFlagSet(type, ts.TypeFlags.EnumLike)
? tsutils.isTypeFlagSet(type, ts.TypeFlags.NumberLiteral)
? ts.TypeFlags.Number

@@ -52,5 +52,6 @@ : ts.TypeFlags.String

}
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-unsafe-enum-comparison',
meta: {
hasSuggestions: true,
type: 'suggestion',

@@ -63,3 +64,5 @@ docs: {

messages: {
mismatched: 'The two values in this comparison do not have a shared enum type.',
mismatchedCase: 'The case statement does not have a shared enum type with the switch predicate.',
mismatchedCondition: 'The two values in this comparison do not have a shared enum type.',
replaceValueWithEnum: 'Replace with an enum value comparison.',
},

@@ -70,48 +73,94 @@ schema: [],

create(context) {
const parserServices = util.getParserServices(context);
const parserServices = (0, util_1.getParserServices)(context);
const typeChecker = parserServices.program.getTypeChecker();
function getTypeFromNode(node) {
return typeChecker.getTypeAtLocation(parserServices.esTreeNodeToTSNodeMap.get(node));
function isMismatchedComparison(leftType, rightType) {
// Allow comparisons that don't have anything to do with enums:
//
// ```ts
// 1 === 2;
// ```
const leftEnumTypes = (0, shared_1.getEnumTypes)(typeChecker, leftType);
const rightEnumTypes = new Set((0, shared_1.getEnumTypes)(typeChecker, rightType));
if (leftEnumTypes.length === 0 && rightEnumTypes.size === 0) {
return false;
}
// Allow comparisons that share an enum type:
//
// ```ts
// Fruit.Apple === Fruit.Banana;
// ```
for (const leftEnumType of leftEnumTypes) {
if (rightEnumTypes.has(leftEnumType)) {
return false;
}
}
const leftTypeParts = tsutils.unionTypeParts(leftType);
const rightTypeParts = tsutils.unionTypeParts(rightType);
// If a type exists in both sides, we consider this comparison safe:
//
// ```ts
// declare const fruit: Fruit.Apple | 0;
// fruit === 0;
// ```
for (const leftTypePart of leftTypeParts) {
if (rightTypeParts.includes(leftTypePart)) {
return false;
}
}
return (typeViolates(leftTypeParts, rightType) ||
typeViolates(rightTypeParts, leftType));
}
return {
'BinaryExpression[operator=/^[<>!=]?={0,2}$/]'(node) {
const left = getTypeFromNode(node.left);
const right = getTypeFromNode(node.right);
// Allow comparisons that don't have anything to do with enums:
//
// ```ts
// 1 === 2;
// ```
const leftEnumTypes = (0, shared_1.getEnumTypes)(typeChecker, left);
const rightEnumTypes = new Set((0, shared_1.getEnumTypes)(typeChecker, right));
if (leftEnumTypes.length === 0 && rightEnumTypes.size === 0) {
const leftType = parserServices.getTypeAtLocation(node.left);
const rightType = parserServices.getTypeAtLocation(node.right);
if (isMismatchedComparison(leftType, rightType)) {
context.report({
messageId: 'mismatchedCondition',
node,
suggest: [
{
messageId: 'replaceValueWithEnum',
fix(fixer) {
// Replace the right side with an enum key if possible:
//
// ```ts
// Fruit.Apple === 'apple'; // Fruit.Apple === Fruit.Apple
// ```
const leftEnumKey = (0, shared_1.getEnumKeyForLiteral)((0, shared_1.getEnumLiterals)(leftType), (0, util_1.getStaticValue)(node.right)?.value);
if (leftEnumKey) {
return fixer.replaceText(node.right, leftEnumKey);
}
// Replace the left side with an enum key if possible:
//
// ```ts
// declare const fruit: Fruit;
// 'apple' === Fruit.Apple; // Fruit.Apple === Fruit.Apple
// ```
const rightEnumKey = (0, shared_1.getEnumKeyForLiteral)((0, shared_1.getEnumLiterals)(rightType), (0, util_1.getStaticValue)(node.left)?.value);
if (rightEnumKey) {
return fixer.replaceText(node.left, rightEnumKey);
}
return null;
},
},
],
});
}
},
SwitchCase(node) {
// Ignore `default` cases.
if (node.test == null) {
return;
}
// Allow comparisons that share an enum type:
//
// ```ts
// Fruit.Apple === Fruit.Banana;
// ```
for (const leftEnumType of leftEnumTypes) {
if (rightEnumTypes.has(leftEnumType)) {
return;
}
}
const leftTypeParts = tsutils.unionTypeParts(left);
const rightTypeParts = tsutils.unionTypeParts(right);
// If a type exists in both sides, we consider this comparison safe:
//
// ```ts
// declare const fruit: Fruit.Apple | 0;
// fruit === 0;
// ```
for (const leftTypePart of leftTypeParts) {
if (rightTypeParts.includes(leftTypePart)) {
return;
}
}
if (typeViolates(leftTypeParts, right) ||
typeViolates(rightTypeParts, left)) {
const { parent } = node;
/**
* @see https://github.com/typescript-eslint/typescript-eslint/issues/6225
*/
const switchStatement = parent;
const leftType = parserServices.getTypeAtLocation(switchStatement.discriminant);
const rightType = parserServices.getTypeAtLocation(node.test);
if (isMismatchedComparison(leftType, rightType)) {
context.report({
messageId: 'mismatched',
messageId: 'mismatchedCase',
node,

@@ -118,0 +167,0 @@ });

@@ -27,6 +27,6 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-unsafe-member-access',

@@ -52,6 +52,6 @@ meta: {

create(context) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const compilerOptions = services.program.getCompilerOptions();
const isNoImplicitThis = tsutils.isStrictCompilerOptionEnabled(compilerOptions, 'noImplicitThis');
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const stateCache = new Map();

@@ -73,3 +73,3 @@ function checkMemberExpression(node) {

const type = services.getTypeAtLocation(node.object);
const state = util.isTypeAnyType(type) ? 1 /* State.Unsafe */ : 2 /* State.Safe */;
const state = (0, util_1.isTypeAnyType)(type) ? 1 /* State.Unsafe */ : 2 /* State.Safe */;
stateCache.set(node, state);

@@ -83,3 +83,3 @@ if (state === 1 /* State.Unsafe */) {

if (thisExpression &&
util.isTypeAnyType(util.getConstrainedTypeAtLocation(services, thisExpression))) {
(0, util_1.isTypeAnyType)((0, util_1.getConstrainedTypeAtLocation)(services, thisExpression))) {
messageId = 'unsafeThisMemberExpression';

@@ -89,3 +89,3 @@ }

context.report({
node,
node: node.property,
messageId,

@@ -114,3 +114,3 @@ data: {

const type = services.getTypeAtLocation(node);
if (util.isTypeAnyType(type)) {
if ((0, util_1.isTypeAnyType)(type)) {
const propertyName = sourceCode.getText(node);

@@ -117,0 +117,0 @@ context.report({

@@ -29,5 +29,4 @@ "use strict";

const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-unsafe-return',

@@ -53,3 +52,3 @@ meta: {

create(context) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();

@@ -74,3 +73,3 @@ const compilerOptions = services.program.getCompilerOptions();

const tsNode = services.esTreeNodeToTSNodeMap.get(returnNode);
const anyType = util.isAnyOrAnyArrayTypeDiscriminated(tsNode, checker);
const anyType = (0, util_1.isAnyOrAnyArrayTypeDiscriminated)(tsNode, checker);
const functionNode = getParentFunctionNode(returnNode);

@@ -81,3 +80,3 @@ /* istanbul ignore if */ if (!functionNode) {

// function has an explicit return type, so ensure it's a safe return
const returnNodeType = util.getConstrainedTypeAtLocation(services, returnNode);
const returnNodeType = (0, util_1.getConstrainedTypeAtLocation)(services, returnNode);
const functionTSNode = services.esTreeNodeToTSNodeMap.get(functionNode);

@@ -90,3 +89,3 @@ // function expressions will not have their return type modified based on receiver typing

ts.isArrowFunction(functionTSNode)
? util.getContextualType(checker, functionTSNode)
? (0, util_1.getContextualType)(checker, functionTSNode)
: services.getTypeAtLocation(functionNode);

@@ -100,3 +99,4 @@ if (!functionType) {

for (const signature of functionType.getCallSignatures()) {
if (returnNodeType === signature.getReturnType()) {
if (returnNodeType === signature.getReturnType() ||
(0, util_1.isTypeFlagSet)(signature.getReturnType(), ts.TypeFlags.Any | ts.TypeFlags.Unknown)) {
return;

@@ -106,3 +106,3 @@ }

}
if (anyType !== util.AnyType.Safe) {
if (anyType !== util_1.AnyType.Safe) {
// Allow cases when the declared return type of the function is either unknown or unknown[]

@@ -112,8 +112,8 @@ // and the function is returning any or any[].

const functionReturnType = signature.getReturnType();
if (anyType === util.AnyType.Any &&
util.isTypeUnknownType(functionReturnType)) {
if (anyType === util_1.AnyType.Any &&
(0, util_1.isTypeUnknownType)(functionReturnType)) {
return;
}
if (anyType === util.AnyType.AnyArray &&
util.isTypeUnknownArrayType(functionReturnType, checker)) {
if (anyType === util_1.AnyType.AnyArray &&
(0, util_1.isTypeUnknownArrayType)(functionReturnType, checker)) {
return;

@@ -127,3 +127,3 @@ }

if (thisExpression &&
util.isTypeAnyType(util.getConstrainedTypeAtLocation(services, thisExpression))) {
(0, util_1.isTypeAnyType)((0, util_1.getConstrainedTypeAtLocation)(services, thisExpression))) {
messageId = 'unsafeReturnThis';

@@ -137,3 +137,3 @@ }

data: {
type: anyType === util.AnyType.Any ? 'any' : 'any[]',
type: anyType === util_1.AnyType.Any ? 'any' : 'any[]',
},

@@ -144,3 +144,3 @@ });

const functionReturnType = signature.getReturnType();
const result = util.isUnsafeAssignment(returnNodeType, functionReturnType, checker, returnNode);
const result = (0, util_1.isUnsafeAssignment)(returnNodeType, functionReturnType, checker, returnNode);
if (!result) {

@@ -147,0 +147,0 @@ return;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('no-unused-expressions');
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-unused-expressions',

@@ -68,2 +45,10 @@ meta: {

}
if (node.expression.type ===
utils_1.TSESTree.AST_NODE_TYPES.TSInstantiationExpression) {
rules.ExpressionStatement({
...node,
expression: node.expression.expression,
});
return;
}
rules.ExpressionStatement(node);

@@ -70,0 +55,0 @@ },

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const scope_manager_1 = require("@typescript-eslint/scope-manager");
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-unused-vars',

@@ -87,4 +65,4 @@ meta: {

create(context, [firstOption]) {
const filename = context.getFilename();
const sourceCode = context.getSourceCode();
const filename = (0, eslint_utils_1.getFilename)(context);
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const MODULE_DECL_CACHE = new Map();

@@ -98,26 +76,23 @@ const options = (() => {

};
if (firstOption) {
if (typeof firstOption === 'string') {
options.vars = firstOption;
if (typeof firstOption === 'string') {
options.vars = firstOption;
}
else {
options.vars = firstOption.vars ?? options.vars;
options.args = firstOption.args ?? options.args;
options.ignoreRestSiblings =
firstOption.ignoreRestSiblings ?? options.ignoreRestSiblings;
options.caughtErrors = firstOption.caughtErrors ?? options.caughtErrors;
if (firstOption.varsIgnorePattern) {
options.varsIgnorePattern = new RegExp(firstOption.varsIgnorePattern, 'u');
}
else {
options.vars = firstOption.vars ?? options.vars;
options.args = firstOption.args ?? options.args;
options.ignoreRestSiblings =
firstOption.ignoreRestSiblings ?? options.ignoreRestSiblings;
options.caughtErrors =
firstOption.caughtErrors ?? options.caughtErrors;
if (firstOption.varsIgnorePattern) {
options.varsIgnorePattern = new RegExp(firstOption.varsIgnorePattern, 'u');
}
if (firstOption.argsIgnorePattern) {
options.argsIgnorePattern = new RegExp(firstOption.argsIgnorePattern, 'u');
}
if (firstOption.caughtErrorsIgnorePattern) {
options.caughtErrorsIgnorePattern = new RegExp(firstOption.caughtErrorsIgnorePattern, 'u');
}
if (firstOption.destructuredArrayIgnorePattern) {
options.destructuredArrayIgnorePattern = new RegExp(firstOption.destructuredArrayIgnorePattern, 'u');
}
if (firstOption.argsIgnorePattern) {
options.argsIgnorePattern = new RegExp(firstOption.argsIgnorePattern, 'u');
}
if (firstOption.caughtErrorsIgnorePattern) {
options.caughtErrorsIgnorePattern = new RegExp(firstOption.caughtErrorsIgnorePattern, 'u');
}
if (firstOption.destructuredArrayIgnorePattern) {
options.destructuredArrayIgnorePattern = new RegExp(firstOption.destructuredArrayIgnorePattern, 'u');
}
}

@@ -134,3 +109,3 @@ return options;

return (node.type === utils_1.AST_NODE_TYPES.Property &&
node.parent?.type === utils_1.AST_NODE_TYPES.ObjectPattern &&
node.parent.type === utils_1.AST_NODE_TYPES.ObjectPattern &&
node.parent.properties[node.parent.properties.length - 1].type ===

@@ -159,3 +134,3 @@ utils_1.AST_NODE_TYPES.RestElement);

const def = variable.defs[0];
const params = context.getDeclaredVariables(def.node);
const params = (0, eslint_utils_1.getDeclaredVariables)(context, def.node);
const posteriorParams = params.slice(params.indexOf(variable) + 1);

@@ -165,3 +140,3 @@ // If any used parameters occur after this parameter, do not report.

}
const unusedVariablesOriginal = util.collectUnusedVariables(context);
const unusedVariablesOriginal = (0, util_1.collectUnusedVariables)(context);
const unusedVariablesReturn = [];

@@ -180,5 +155,5 @@ for (const variable of unusedVariablesOriginal) {

}
const refUsedInArrayPatterns = variable.references.some(ref => ref.identifier.parent?.type === utils_1.AST_NODE_TYPES.ArrayPattern);
const refUsedInArrayPatterns = variable.references.some(ref => ref.identifier.parent.type === utils_1.AST_NODE_TYPES.ArrayPattern);
// skip elements of array destructuring patterns
if ((def.name.parent?.type === utils_1.AST_NODE_TYPES.ArrayPattern ||
if ((def.name.parent.type === utils_1.AST_NODE_TYPES.ArrayPattern ||
refUsedInArrayPatterns) &&

@@ -212,3 +187,3 @@ 'name' in def.name &&

if (options.args === 'after-used' &&
util.isFunction(def.name.parent) &&
(0, util_1.isFunction)(def.name.parent) &&
!isAfterLastUsedArg(variable)) {

@@ -240,3 +215,3 @@ continue;

[ambientDeclarationSelector(utils_1.AST_NODE_TYPES.Program, true)](node) {
if (!util.isDefinitionFile(filename)) {
if (!(0, util_1.isDefinitionFile)(filename)) {
return;

@@ -250,3 +225,3 @@ }

if (node.id.type === utils_1.AST_NODE_TYPES.Identifier) {
let scope = context.getScope();
let scope = (0, eslint_utils_1.getScope)(context);
if (scope.upper) {

@@ -267,3 +242,3 @@ scope = scope.upper;

[ambientDeclarationSelector('TSModuleDeclaration[declare = true] > TSModuleBlock', false)](node) {
const moduleDecl = util.nullThrows(node.parent?.parent, util.NullThrowsReasons.MissingParent);
const moduleDecl = (0, util_1.nullThrows)(node.parent.parent, util_1.NullThrowsReasons.MissingParent);
// declared ambient modules with an `export =` statement will only export that one thing

@@ -286,3 +261,3 @@ // all other statements are not automatically exported in this case

function getDefinedMessageData(unusedVar) {
const defType = unusedVar?.defs[0]?.type;
const defType = unusedVar.defs[0]?.type;
let type;

@@ -321,6 +296,6 @@ let pattern;

function getAssignedMessageData(unusedVar) {
const def = unusedVar.defs[0];
const def = unusedVar.defs.at(0);
let additional = '';
if (options.destructuredArrayIgnorePattern &&
def?.name.parent?.type === utils_1.AST_NODE_TYPES.ArrayPattern) {
def?.name.parent.type === utils_1.AST_NODE_TYPES.ArrayPattern) {
additional = `. Allowed unused elements of array destructuring patterns must match ${options.destructuredArrayIgnorePattern.toString()}`;

@@ -359,3 +334,3 @@ }

node: programNode,
loc: util.getNameLocationInGlobalDirectiveComment(sourceCode, directiveComment, unusedVar.name),
loc: (0, util_1.getNameLocationInGlobalDirectiveComment)(sourceCode, directiveComment, unusedVar.name),
messageId: 'unusedVar',

@@ -373,3 +348,3 @@ data: getDefinedMessageData(unusedVar),

}
if (node.body && node.body.type === utils_1.AST_NODE_TYPES.TSModuleBlock) {
if (node.body) {
for (const statement of node.body.body) {

@@ -424,3 +399,3 @@ if (statement.type === utils_1.AST_NODE_TYPES.TSExportAssignment) {

}
let scope = context.getScope();
let scope = (0, eslint_utils_1.getScope)(context);
const shouldUseUpperScope = [

@@ -427,0 +402,0 @@ utils_1.AST_NODE_TYPES.TSModuleDeclaration,

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const scope_manager_1 = require("@typescript-eslint/scope-manager");
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const SENTINEL_TYPE = /^(?:(?:Function|Class)(?:Declaration|Expression)|ArrowFunctionExpression|CatchClause|ImportDeclaration|ExportNamedDeclaration)$/;

@@ -101,3 +79,3 @@ /**

const { identifier } = reference;
return (identifier.parent?.type === utils_1.AST_NODE_TYPES.ExportSpecifier &&
return (identifier.parent.type === utils_1.AST_NODE_TYPES.ExportSpecifier &&
identifier.parent.local === identifier);

@@ -138,6 +116,3 @@ }

function isClassRefInClassDecorator(variable, reference) {
if (variable.defs[0].type !== scope_manager_1.DefinitionType.ClassName) {
return false;
}
if (!variable.defs[0].node.decorators ||
if (variable.defs[0].type !== scope_manager_1.DefinitionType.ClassName ||
variable.defs[0].node.decorators.length === 0) {

@@ -175,5 +150,4 @@ return false;

}
if (node.parent?.parent &&
(node.parent.parent.type === utils_1.AST_NODE_TYPES.ForInStatement ||
node.parent.parent.type === utils_1.AST_NODE_TYPES.ForOfStatement) &&
if ((node.parent.parent?.type === utils_1.AST_NODE_TYPES.ForInStatement ||
node.parent.parent?.type === utils_1.AST_NODE_TYPES.ForOfStatement) &&
isInRange(node.parent.parent.right, location)) {

@@ -196,3 +170,3 @@ return true;

}
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-use-before-define',

@@ -322,3 +296,3 @@ meta: {

Program() {
findVariablesInScope(context.getScope());
findVariablesInScope((0, eslint_utils_1.getScope)(context));
},

@@ -325,0 +299,0 @@ };

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");

@@ -55,3 +32,3 @@ const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('no-useless-constructor');

}
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-useless-constructor',

@@ -74,4 +51,3 @@ meta: {

MethodDefinition(node) {
if (node.value?.type === utils_1.AST_NODE_TYPES.FunctionExpression &&
node.value.body &&
if (node.value.type === utils_1.AST_NODE_TYPES.FunctionExpression &&
checkAccessibility(node) &&

@@ -78,0 +54,0 @@ checkParams(node)) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
function isEmptyExport(node) {

@@ -42,3 +20,3 @@ return (node.type === utils_1.AST_NODE_TYPES.ExportNamedDeclaration &&

]);
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'no-useless-empty-export',

@@ -59,2 +37,8 @@ meta: {

create(context) {
// In a definition file, export {} is necessary to make the module properly
// encapsulated, even when there are other exports
// https://github.com/typescript-eslint/typescript-eslint/issues/4975
if ((0, util_1.isDefinitionFile)((0, eslint_utils_1.getFilename)(context))) {
return {};
}
function checkNode(node) {

@@ -64,10 +48,7 @@ if (!Array.isArray(node.body)) {

}
let emptyExport;
const emptyExports = [];
let foundOtherExport = false;
for (const statement of node.body) {
if (isEmptyExport(statement)) {
emptyExport = statement;
if (foundOtherExport) {
break;
}
emptyExports.push(statement);
}

@@ -78,8 +59,10 @@ else if (exportOrImportNodeTypes.has(statement.type)) {

}
if (emptyExport && foundOtherExport) {
context.report({
fix: fixer => fixer.remove(emptyExport),
messageId: 'uselessExport',
node: emptyExport,
});
if (foundOtherExport) {
for (const emptyExport of emptyExports) {
context.report({
fix: fixer => fixer.remove(emptyExport),
messageId: 'uselessExport',
node: emptyExport,
});
}
}

@@ -86,0 +69,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'no-var-requires',

@@ -45,15 +23,14 @@ meta: {

'CallExpression[callee.name="require"]'(node) {
const parent = node.parent?.type === utils_1.AST_NODE_TYPES.ChainExpression
const parent = node.parent.type === utils_1.AST_NODE_TYPES.ChainExpression
? node.parent.parent
: node.parent;
if (parent &&
[
utils_1.AST_NODE_TYPES.CallExpression,
utils_1.AST_NODE_TYPES.MemberExpression,
utils_1.AST_NODE_TYPES.NewExpression,
utils_1.AST_NODE_TYPES.TSAsExpression,
utils_1.AST_NODE_TYPES.TSTypeAssertion,
utils_1.AST_NODE_TYPES.VariableDeclarator,
].includes(parent.type)) {
const variable = utils_1.ASTUtils.findVariable(context.getScope(), 'require');
if ([
utils_1.AST_NODE_TYPES.CallExpression,
utils_1.AST_NODE_TYPES.MemberExpression,
utils_1.AST_NODE_TYPES.NewExpression,
utils_1.AST_NODE_TYPES.TSAsExpression,
utils_1.AST_NODE_TYPES.TSTypeAssertion,
utils_1.AST_NODE_TYPES.VariableDeclarator,
].includes(parent.type)) {
const variable = utils_1.ASTUtils.findVariable((0, eslint_utils_1.getScope)(context), 'require');
if (!variable?.identifiers.length) {

@@ -60,0 +37,0 @@ context.report({

@@ -27,6 +27,7 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'non-nullable-type-assertion-style',

@@ -48,4 +49,4 @@ meta: {

create(context) {
const services = util.getParserServices(context);
const sourceCode = context.getSourceCode();
const services = (0, util_1.getParserServices)(context);
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const getTypesIfNotLoose = (node) => {

@@ -111,3 +112,3 @@ const type = services.getTypeAtLocation(node);

const expressionSourceCode = sourceCode.getText(node.expression);
const higherPrecedenceThanUnary = util.getOperatorPrecedence(services.esTreeNodeToTSNodeMap.get(node.expression).kind, ts.SyntaxKind.Unknown) > util.OperatorPrecedence.Unary;
const higherPrecedenceThanUnary = (0, util_1.getOperatorPrecedence)(services.esTreeNodeToTSNodeMap.get(node.expression).kind, ts.SyntaxKind.Unknown) > util_1.OperatorPrecedence.Unary;
context.report({

@@ -114,0 +115,0 @@ fix(fixer) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");

@@ -22,3 +23,3 @@ const getESLintCoreRule_1 = require("../util/getESLintCoreRule");

const spaced = firstOption === 'always';
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
/**

@@ -48,5 +49,5 @@ * Determines whether an option is set, relative to the spacing option.

function reportNoBeginningSpace(node, token) {
const nextToken = context
.getSourceCode()
.getTokenAfter(token, { includeComments: true });
const nextToken = (0, eslint_utils_1.getSourceCode)(context).getTokenAfter(token, {
includeComments: true,
});
context.report({

@@ -70,5 +71,5 @@ node,

function reportNoEndingSpace(node, token) {
const previousToken = context
.getSourceCode()
.getTokenBefore(token, { includeComments: true });
const previousToken = (0, eslint_utils_1.getSourceCode)(context).getTokenBefore(token, {
includeComments: true,
});
context.report({

@@ -75,0 +76,0 @@ node,

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const LT = `[${Array.from(new Set(['\r\n', '\r', '\n', '\u2028', '\u2029'])).join('')}]`;

@@ -94,5 +72,3 @@ const PADDING_LINE_SEQUENCE = new RegExp(String.raw `^(\s*?${LT})\s*${LT}(\s*;?)$`, 'u');

function skipChainExpression(node) {
return node && node.type === utils_1.AST_NODE_TYPES.ChainExpression
? node.expression
: node;
return node.type === utils_1.AST_NODE_TYPES.ChainExpression ? node.expression : node;
}

@@ -116,3 +92,3 @@ /**

}
return util.isFunction(node);
return (0, util_1.isFunction)(node);
}

@@ -130,5 +106,5 @@ }

if (node.type === utils_1.AST_NODE_TYPES.VariableDeclaration) {
const declaration = node.declarations[0];
const declaration = node.declarations.at(0);
if (declaration?.init) {
let call = declaration?.init;
let call = declaration.init;
while (call.type === utils_1.AST_NODE_TYPES.MemberExpression) {

@@ -167,4 +143,4 @@ call = call.object;

// Checks the last token is a closing brace of blocks.
const lastToken = sourceCode.getLastToken(node, util.isNotSemicolonToken);
const belongingNode = lastToken && util.isClosingBraceToken(lastToken)
const lastToken = sourceCode.getLastToken(node, util_1.isNotSemicolonToken);
const belongingNode = lastToken && (0, util_1.isClosingBraceToken)(lastToken)
? sourceCode.getNodeByRangeIndex(lastToken.range[0])

@@ -184,8 +160,8 @@ : null;

return (node.type === utils_1.AST_NODE_TYPES.ExpressionStatement &&
(node.parent?.type === utils_1.AST_NODE_TYPES.Program ||
(node.parent?.type === utils_1.AST_NODE_TYPES.BlockStatement &&
util.isFunction(node.parent.parent))) &&
(node.parent.type === utils_1.AST_NODE_TYPES.Program ||
(node.parent.type === utils_1.AST_NODE_TYPES.BlockStatement &&
(0, util_1.isFunction)(node.parent.parent))) &&
node.expression.type === utils_1.AST_NODE_TYPES.Literal &&
typeof node.expression.value === 'string' &&
!util.isParenthesized(node.expression, sourceCode));
!(0, util_1.isParenthesized)(node.expression, sourceCode));
}

@@ -270,3 +246,3 @@ /**

prevToken.range[0] >= node.range[0] &&
util.isSemicolonToken(semiToken) &&
(0, util_1.isSemicolonToken)(semiToken) &&
semiToken.loc.start.line !== prevToken.loc.end.line &&

@@ -324,4 +300,3 @@ semiToken.loc.end.line === nextToken.loc.start.line;

const end = nextToken.range[0];
const text = context
.getSourceCode()
const text = (0, eslint_utils_1.getSourceCode)(context)
.text.slice(start, end)

@@ -354,3 +329,3 @@ .replace(PADDING_LINE_SEQUENCE, replacerToRemovePaddingLines);

fix(fixer) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
let prevToken = getActualLastToken(prevNode, sourceCode);

@@ -380,3 +355,3 @@ const nextToken = sourceCode.getFirstTokenBetween(prevToken, nextNode, {

filter(token) {
if (util.isTokenOnSameLine(prevToken, token)) {
if ((0, util_1.isTokenOnSameLine)(prevToken, token)) {
prevToken = token;

@@ -388,3 +363,3 @@ return false;

}) || nextNode;
const insertText = util.isTokenOnSameLine(prevToken, nextToken)
const insertText = (0, util_1.isTokenOnSameLine)(prevToken, nextToken)
? '\n\n'

@@ -472,3 +447,3 @@ : '\n';

//------------------------------------------------------------------------------
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'padding-line-between-statements',

@@ -529,5 +504,5 @@ meta: {

create(context) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
// eslint-disable-next-line no-restricted-syntax -- We need all raw options.
const configureList = context.options || [];
const configureList = context.options;
let scopeInfo = null;

@@ -534,0 +509,0 @@ /**

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'parameter-properties',

@@ -129,3 +107,3 @@ meta: {

}
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
function typeAnnotationsMatch(classProperty, constructorParameter) {

@@ -132,0 +110,0 @@ if (!classProperty.typeAnnotation ||

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'prefer-as-const',

@@ -30,0 +7,0 @@ meta: {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'prefer-enum-initializers',

@@ -43,3 +21,3 @@ meta: {

create(context) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
function TSEnumDeclaration(node) {

@@ -46,0 +24,0 @@ const { members } = node;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'prefer-for-of',

@@ -130,3 +108,3 @@ meta: {

parent.value === node &&
parent.parent?.type === utils_1.AST_NODE_TYPES.ObjectExpression &&
parent.parent.type === utils_1.AST_NODE_TYPES.ObjectExpression &&
isAssignee(parent.parent)) {

@@ -138,3 +116,3 @@ return true;

function isIndexOnlyUsedWithArray(body, indexVar, arrayExpression) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const arrayText = sourceCode.getText(arrayExpression);

@@ -145,4 +123,3 @@ return indexVar.references.every(reference => {

return (!contains(body, id) ||
(node !== undefined &&
node.type === utils_1.AST_NODE_TYPES.MemberExpression &&
(node.type === utils_1.AST_NODE_TYPES.MemberExpression &&
node.object.type !== utils_1.AST_NODE_TYPES.ThisExpression &&

@@ -170,3 +147,3 @@ node.property === id &&

}
const [indexVar] = context.getDeclaredVariables(node.init);
const [indexVar] = (0, eslint_utils_1.getDeclaredVariables)(context, node.init);
if (isIncrement(node.update, indexName) &&

@@ -173,0 +150,0 @@ isIndexOnlyUsedWithArray(node.body, indexVar, arrayExpression)) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.phrases = void 0;
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.phrases = {

@@ -33,3 +11,3 @@ [utils_1.AST_NODE_TYPES.TSTypeLiteral]: 'Type literal',

};
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'prefer-function-type',

@@ -51,3 +29,3 @@ meta: {

create(context) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
/**

@@ -58,3 +36,3 @@ * Checks if there the interface has exactly one supertype that isn't named 'Function'

function hasOneSupertype(node) {
if (!node.extends || node.extends.length === 0) {
if (node.extends.length === 0) {
return false;

@@ -61,0 +39,0 @@ }

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

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const ts = __importStar(require("typescript"));

@@ -49,3 +50,3 @@ const util_1 = require("../util");

create(context) {
const globalScope = context.getScope();
const globalScope = (0, eslint_utils_1.getScope)(context);
const services = (0, util_1.getParserServices)(context);

@@ -142,3 +143,3 @@ const checker = services.program.getTypeChecker();

const callNode = node.parent;
const compareNode = (callNode.parent?.type === utils_1.AST_NODE_TYPES.ChainExpression
const compareNode = (callNode.parent.type === utils_1.AST_NODE_TYPES.ChainExpression
? callNode.parent.parent

@@ -145,0 +146,0 @@ : callNode.parent);

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'prefer-namespace-keyword',

@@ -44,7 +22,7 @@ meta: {

create(context) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
return {
TSModuleDeclaration(node) {
// Do nothing if the name is a string.
if (!node.id || node.id.type === utils_1.AST_NODE_TYPES.Literal) {
if (node.id.type === utils_1.AST_NODE_TYPES.Literal) {
return;

@@ -51,0 +29,0 @@ }

@@ -27,6 +27,7 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'prefer-nullish-coalescing',

@@ -100,5 +101,5 @@ meta: {

create(context, [{ allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing, ignoreConditionalTests, ignoreMixedLogicalExpressions, ignorePrimitives, ignoreTernaryTests, },]) {
const parserServices = util.getParserServices(context);
const parserServices = (0, util_1.getParserServices)(context);
const compilerOptions = parserServices.program.getCompilerOptions();
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const checker = parserServices.program.getTypeChecker();

@@ -178,14 +179,14 @@ const isStrictNullChecks = tsutils.isStrictCompilerOptionEnabled(compilerOptions, 'strictNullChecks');

for (const testNode of nodesInsideTestExpression) {
if (util.isNullLiteral(testNode)) {
if ((0, util_1.isNullLiteral)(testNode)) {
hasNullCheck = true;
}
else if (util.isUndefinedIdentifier(testNode)) {
else if ((0, util_1.isUndefinedIdentifier)(testNode)) {
hasUndefinedCheck = true;
}
else if ((operator === '!==' || operator === '!=') &&
util.isNodeEqual(testNode, node.consequent)) {
(0, util_1.isNodeEqual)(testNode, node.consequent)) {
identifier = testNode;
}
else if ((operator === '===' || operator === '==') &&
util.isNodeEqual(testNode, node.alternate)) {
(0, util_1.isNodeEqual)(testNode, node.alternate)) {
identifier = testNode;

@@ -211,3 +212,3 @@ }

const type = checker.getTypeAtLocation(tsNode);
const flags = util.getTypeFlags(type);
const flags = (0, util_1.getTypeFlags)(type);
if (flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) {

@@ -246,3 +247,3 @@ return false;

const type = checker.getTypeAtLocation(tsNode.left);
const isNullish = util.isNullableType(type, { allowUndefined: true });
const isNullish = (0, util_1.isNullableType)(type, { allowUndefined: true });
if (!isNullish) {

@@ -275,9 +276,9 @@ return;

}
const barBarOperator = util.nullThrows(sourceCode.getTokenAfter(node.left, token => token.type === utils_1.AST_TOKEN_TYPES.Punctuator &&
token.value === node.operator), util.NullThrowsReasons.MissingToken('operator', node.type));
const barBarOperator = (0, util_1.nullThrows)(sourceCode.getTokenAfter(node.left, token => token.type === utils_1.AST_TOKEN_TYPES.Punctuator &&
token.value === node.operator), util_1.NullThrowsReasons.MissingToken('operator', node.type));
function* fix(fixer) {
if (node.parent && util.isLogicalOrOperator(node.parent)) {
if ((0, util_1.isLogicalOrOperator)(node.parent)) {
// '&&' and '??' operations cannot be mixed without parentheses (e.g. a && b ?? c)
if (node.left.type === utils_1.AST_NODE_TYPES.LogicalExpression &&
!util.isLogicalOrOperator(node.left.left)) {
!(0, util_1.isLogicalOrOperator)(node.left.left)) {
yield fixer.insertTextBefore(node.left.right, '(');

@@ -342,3 +343,3 @@ }

seen.add(current);
if (current && current.type === utils_1.AST_NODE_TYPES.LogicalExpression) {
if (current.type === utils_1.AST_NODE_TYPES.LogicalExpression) {
if (current.operator === '&&') {

@@ -345,0 +346,0 @@ return true;

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

const ts = __importStar(require("typescript"));
const util = __importStar(require("../../util"));
const util_1 = require("../../util");
const compareNodes_1 = require("./compareNodes");

@@ -37,3 +37,3 @@ function includesType(parserServices, node, typeFlagIn) {

for (const type of types) {
if (util.isTypeFlagSet(type, typeFlag)) {
if ((0, util_1.isTypeFlagSet)(type, typeFlag)) {
return true;

@@ -231,4 +231,4 @@ }

}
if (part.precedence !== util.OperatorPrecedence.Invalid &&
part.precedence < util.OperatorPrecedence.Member) {
if (part.precedence !== util_1.OperatorPrecedence.Invalid &&
part.precedence < util_1.OperatorPrecedence.Member) {
str += `(${part.text})`;

@@ -280,4 +280,4 @@ }

const argumentsText = (() => {
const closingParenToken = util.nullThrows(sourceCode.getLastToken(node), util.NullThrowsReasons.MissingToken('closing parenthesis', node.type));
const openingParenToken = util.nullThrows(sourceCode.getFirstTokenBetween(node.typeArguments ?? node.callee, closingParenToken, util.isOpeningParenToken), util.NullThrowsReasons.MissingToken('opening parenthesis', node.type));
const closingParenToken = (0, util_1.nullThrows)(sourceCode.getLastToken(node), util_1.NullThrowsReasons.MissingToken('closing parenthesis', node.type));
const openingParenToken = (0, util_1.nullThrows)(sourceCode.getFirstTokenBetween(node.typeArguments ?? node.callee, closingParenToken, util_1.isOpeningParenToken), util_1.NullThrowsReasons.MissingToken('opening parenthesis', node.type));
return sourceCode.text.substring(openingParenToken.range[0], closingParenToken.range[1]);

@@ -297,3 +297,3 @@ })();

// no precedence for this
precedence: util.OperatorPrecedence.Invalid,
precedence: util_1.OperatorPrecedence.Invalid,
requiresDot: false,

@@ -313,4 +313,4 @@ text: typeArgumentsText + argumentsText,

? // computed is already wrapped in [] so no need to wrap in () as well
util.OperatorPrecedence.Invalid
: util.getOperatorPrecedenceForNode(node.property),
util_1.OperatorPrecedence.Invalid
: (0, util_1.getOperatorPrecedenceForNode)(node.property),
requiresDot: !node.computed,

@@ -328,3 +328,3 @@ text: node.computed ? `[${propertyText}]` : propertyText,

optional: false,
precedence: util.getOperatorPrecedenceForNode(node),
precedence: (0, util_1.getOperatorPrecedenceForNode)(node),
requiresDot: false,

@@ -410,3 +410,3 @@ text: sourceCode.getText(node),

}
else if (comparisonResult === "Equal" /* NodeComparisonResult.Equal */) {
else {
// purposely don't push this case because the node is a no-op and if

@@ -413,0 +413,0 @@ // we consider it then we might report on things like

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

const ts = __importStar(require("typescript"));
const util = __importStar(require("../../util"));
const util_1 = require("../../util");
const NULLISH_FLAGS = ts.TypeFlags.Null | ts.TypeFlags.Undefined;

@@ -58,3 +58,3 @@ function isValidFalseBooleanCheckType(node, operator, checkType, parserServices, options) {

if (options.requireNullish === true) {
return types.some(t => util.isTypeFlagSet(t, NULLISH_FLAGS));
return types.some(t => (0, util_1.isTypeFlagSet)(t, NULLISH_FLAGS));
}

@@ -80,3 +80,3 @@ let allowedFlags = NULLISH_FLAGS | ts.TypeFlags.Object;

}
return types.every(t => util.isTypeFlagSet(t, allowedFlags));
return types.every(t => (0, util_1.isTypeFlagSet)(t, allowedFlags));
}

@@ -83,0 +83,0 @@ function gatherLogicalOperands(node, parserServices, options) {

@@ -27,7 +27,8 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
const analyzeChain_1 = require("./prefer-optional-chain-utils/analyzeChain");
const gatherLogicalOperands_1 = require("./prefer-optional-chain-utils/gatherLogicalOperands");
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'prefer-optional-chain',

@@ -101,4 +102,4 @@ meta: {

create(context, [options]) {
const sourceCode = context.getSourceCode();
const parserServices = util.getParserServices(context);
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const parserServices = (0, util_1.getParserServices)(context);
const seenLogicals = new Set();

@@ -114,3 +115,2 @@ return {

if (!isRightNodeAnEmptyObjectLiteral ||
!parentNode ||
parentNode.type !== utils_1.AST_NODE_TYPES.MemberExpression ||

@@ -127,4 +127,4 @@ parentNode.optional) {

: ts.SyntaxKind.Unknown;
const leftPrecedence = util.getOperatorPrecedence(leftTsNode.kind, operator);
return leftPrecedence < util.OperatorPrecedence.LeftHandSide;
const leftPrecedence = (0, util_1.getOperatorPrecedence)(leftTsNode.kind, operator);
return leftPrecedence < util_1.OperatorPrecedence.LeftHandSide;
}

@@ -131,0 +131,0 @@ context.report({

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'prefer-readonly-parameter-types',

@@ -41,3 +18,3 @@ meta: {

properties: {
allow: util.readonlynessOptionsSchema.properties.allow,
allow: util_1.readonlynessOptionsSchema.properties.allow,
checkParameterProperties: {

@@ -49,3 +26,3 @@ type: 'boolean',

},
treatMethodsAsReadonly: util.readonlynessOptionsSchema.properties.treatMethodsAsReadonly,
treatMethodsAsReadonly: util_1.readonlynessOptionsSchema.properties.treatMethodsAsReadonly,
},

@@ -60,10 +37,10 @@ },

{
allow: util.readonlynessOptionsDefaults.allow,
allow: util_1.readonlynessOptionsDefaults.allow,
checkParameterProperties: true,
ignoreInferredTypes: false,
treatMethodsAsReadonly: util.readonlynessOptionsDefaults.treatMethodsAsReadonly,
treatMethodsAsReadonly: util_1.readonlynessOptionsDefaults.treatMethodsAsReadonly,
},
],
create(context, [{ allow, checkParameterProperties, ignoreInferredTypes, treatMethodsAsReadonly, },]) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
return {

@@ -93,3 +70,3 @@ [[

const type = services.getTypeAtLocation(actualParam);
const isReadOnly = util.isTypeReadonly(services.program, type, {
const isReadOnly = (0, util_1.isTypeReadonly)(services.program, type, {
treatMethodsAsReadonly: treatMethodsAsReadonly,

@@ -96,0 +73,0 @@ allow,

@@ -27,5 +27,5 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
const util_1 = require("../util");

@@ -38,3 +38,3 @@ const functionScopeBoundaries = [

].join(', ');
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'prefer-readonly',

@@ -65,3 +65,3 @@ meta: {

create(context, [{ onlyInlineLambdas }]) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();

@@ -145,3 +145,3 @@ const classScopeStack = [];

const finalizedClassScope = classScopeStack.pop();
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
for (const violatingNode of finalizedClassScope.finalizeUnmodifiedPrivateNonReadonlys()) {

@@ -209,3 +209,4 @@ const { esNode, nameNode } = getEsNodesFromViolatingNode(violatingNode);

addDeclaredVariable(node) {
if (!tsutils.isModifierFlagSet(node, ts.ModifierFlags.Private) ||
if (!(tsutils.isModifierFlagSet(node, ts.ModifierFlags.Private) ||
node.name.kind === ts.SyntaxKind.PrivateIdentifier) ||
tsutils.isModifierFlagSet(node, ts.ModifierFlags.Readonly) ||

@@ -212,0 +213,0 @@ ts.isComputedPropertyName(node.name)) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const getMemberExpressionName = (member) => {

@@ -38,3 +16,3 @@ if (!member.computed) {

};
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'prefer-reduce-type-parameter',

@@ -56,3 +34,3 @@ meta: {

create(context) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();

@@ -65,8 +43,7 @@ return {

const [, secondArg] = callee.parent.arguments;
if (callee.parent.arguments.length < 2 ||
!util.isTypeAssertion(secondArg)) {
if (callee.parent.arguments.length < 2 || !(0, util_1.isTypeAssertion)(secondArg)) {
return;
}
// Get the symbol of the `reduce` method.
const calleeObjType = util.getConstrainedTypeAtLocation(services, callee.object);
const calleeObjType = (0, util_1.getConstrainedTypeAtLocation)(services, callee.object);
// Check the owner type of the `reduce` method.

@@ -89,5 +66,3 @@ if (checker.isArrayType(calleeObjType)) {

if (!callee.parent.typeArguments) {
fixes.push(fixer.insertTextAfter(callee, `<${context
.getSourceCode()
.getText(secondArg.typeAnnotation)}>`));
fixes.push(fixer.insertTextAfter(callee, `<${(0, eslint_utils_1.getSourceCode)(context).getText(secondArg.typeAnnotation)}>`));
}

@@ -94,0 +69,0 @@ return fixes;

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

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));

@@ -53,6 +54,6 @@ const util_1 = require("../util");

create(context) {
const globalScope = context.getScope();
const globalScope = (0, eslint_utils_1.getScope)(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
/**

@@ -87,5 +88,4 @@ * Check if a given node type is a string.

node.type === utils_1.AST_NODE_TYPES.NewExpression) {
const [, flags] = node.arguments;
return (flags &&
flags.type === utils_1.AST_NODE_TYPES.Literal &&
const flags = node.arguments.at(1);
return !!(flags?.type === utils_1.AST_NODE_TYPES.Literal &&
typeof flags.value === 'string' &&

@@ -92,0 +92,0 @@ flags.value.includes('g'));

@@ -65,6 +65,4 @@ "use strict";

function isThisSpecifiedInParameters(originalFunc) {
const firstArg = originalFunc.params[0];
return (firstArg &&
firstArg.type === utils_1.AST_NODE_TYPES.Identifier &&
firstArg.name === 'this');
const firstArg = originalFunc.params.at(0);
return !!(firstArg?.type === utils_1.AST_NODE_TYPES.Identifier && firstArg.name === 'this');
}

@@ -71,0 +69,0 @@ function isFunctionReturningThis(originalFunc, originalClass) {

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

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");

@@ -27,4 +28,4 @@ const EQ_OPERATORS = /^[=!]=/;

create(context) {
const globalScope = context.getScope();
const sourceCode = context.getSourceCode();
const globalScope = (0, eslint_utils_1.getScope)(context);
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const services = (0, util_1.getParserServices)(context);

@@ -122,15 +123,13 @@ const checker = services.program.getTypeChecker();

/**
* Check if a given node is a negative index expression
*
* E.g. `s.slice(- <expr>)`, `s.substring(s.length - <expr>)`
*
* @param node The node to check.
* @param expectedIndexedNode The node which is expected as the receiver of index expression.
* Returns true if `node` is `-substring.length` or
* `parentString.length - substring.length`
*/
function isNegativeIndexExpression(node, expectedIndexedNode) {
function isLengthAheadOfEnd(node, substring, parentString) {
return ((node.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
node.operator === '-') ||
node.operator === '-' &&
isLengthExpression(node.argument, substring)) ||
(node.type === utils_1.AST_NODE_TYPES.BinaryExpression &&
node.operator === '-' &&
isLengthExpression(node.left, expectedIndexedNode)));
isLengthExpression(node.left, parentString) &&
isLengthExpression(node.right, substring)));
}

@@ -283,3 +282,3 @@ /**

let indexNode = null;
if (parentNode?.type === utils_1.AST_NODE_TYPES.CallExpression) {
if (parentNode.type === utils_1.AST_NODE_TYPES.CallExpression) {
if (parentNode.arguments.length === 1) {

@@ -412,10 +411,30 @@ indexNode = parentNode.arguments[0];

}
const isEndsWith = (callNode.arguments.length === 1 ||
(callNode.arguments.length === 2 &&
isLengthExpression(callNode.arguments[1], node.object))) &&
isNegativeIndexExpression(callNode.arguments[0], node.object);
const isStartsWith = !isEndsWith &&
callNode.arguments.length === 2 &&
let isEndsWith = false;
let isStartsWith = false;
if (callNode.arguments.length === 1) {
if (
// foo.slice(-bar.length) === bar
// foo.slice(foo.length - bar.length) === bar
isLengthAheadOfEnd(callNode.arguments[0], parentNode.right, node.object)) {
isEndsWith = true;
}
}
else if (callNode.arguments.length === 2) {
if (
// foo.slice(0, bar.length) === bar
isNumber(callNode.arguments[0], 0) &&
!isNegativeIndexExpression(callNode.arguments[1], node.object);
isLengthExpression(callNode.arguments[1], parentNode.right)) {
isStartsWith = true;
}
else if (
// foo.slice(foo.length - bar.length, foo.length) === bar
// foo.slice(foo.length - bar.length, 0) === bar
// foo.slice(-bar.length, foo.length) === bar
// foo.slice(-bar.length, 0) === bar
(isLengthExpression(callNode.arguments[1], node.object) ||
isNumber(callNode.arguments[1], 0)) &&
isLengthAheadOfEnd(callNode.arguments[0], parentNode.right, node.object)) {
isEndsWith = true;
}
}
if (!isStartsWith && !isEndsWith) {

@@ -422,0 +441,0 @@ return;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'prefer-ts-expect-error',

@@ -46,3 +24,3 @@ meta: {

const tsIgnoreRegExpMultiLine = /^\s*(?:\/|\*)*\s*@ts-ignore/;
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
function isLineComment(comment) {

@@ -49,0 +27,0 @@ return comment.type === utils_1.AST_TOKEN_TYPES.Line;

@@ -27,5 +27,6 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'promise-function-async',

@@ -89,5 +90,5 @@ meta: {

]);
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
function validateNode(node) {

@@ -99,3 +100,3 @@ const signatures = services.getTypeAtLocation(node).getCallSignatures();

const returnType = checker.getReturnTypeOfSignature(signatures[0]);
if (!util.containsAllTypesByName(returnType, allowAny, allAllowedPromiseNames,
if (!(0, util_1.containsAllTypesByName)(returnType, allowAny, allAllowedPromiseNames,
// If no return type is explicitly set, we check if any parts of the return type match a Promise (instead of requiring all to match).

@@ -116,3 +117,3 @@ node.returnType == null)) {

}
if (util.isTypeFlagSet(returnType, ts.TypeFlags.Any | ts.TypeFlags.Unknown)) {
if ((0, util_1.isTypeFlagSet)(returnType, ts.TypeFlags.Any | ts.TypeFlags.Unknown)) {
// Report without auto fixer because the return type is unknown

@@ -122,3 +123,3 @@ return context.report({

node,
loc: util.getFunctionHeadLoc(node, sourceCode),
loc: (0, util_1.getFunctionHeadLoc)(node, sourceCode),
});

@@ -129,3 +130,3 @@ }

node,
loc: util.getFunctionHeadLoc(node, sourceCode),
loc: (0, util_1.getFunctionHeadLoc)(node, sourceCode),
fix: fixer => {

@@ -132,0 +133,0 @@ if (node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition ||

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('quotes');
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'quotes',

@@ -54,3 +31,3 @@ meta: {

const parent = node.parent;
switch (parent?.type) {
switch (parent.type) {
case utils_1.AST_NODE_TYPES.TSAbstractMethodDefinition:

@@ -57,0 +34,0 @@ case utils_1.AST_NODE_TYPES.TSMethodSignature:

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'require-array-sort-compare',

@@ -37,3 +14,3 @@ defaultOptions: [

docs: {
description: 'Require `Array#sort` calls to always provide a `compareFunction`',
description: 'Require `Array#sort` and `Array#toSorted` calls to always provide a `compareFunction`',
requiresTypeChecking: true,

@@ -58,3 +35,3 @@ },

create(context, [options]) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();

@@ -68,17 +45,19 @@ /**

if (checker.isArrayType(type) || checker.isTupleType(type)) {
const typeArgs = util.getTypeArguments(type, checker);
return typeArgs.every(arg => util.getTypeName(checker, arg) === 'string');
const typeArgs = checker.getTypeArguments(type);
return typeArgs.every(arg => (0, util_1.getTypeName)(checker, arg) === 'string');
}
return false;
}
function checkSortArgument(callee) {
const calleeObjType = (0, util_1.getConstrainedTypeAtLocation)(services, callee.object);
if (options.ignoreStringArrays && isStringArrayNode(callee.object)) {
return;
}
if ((0, util_1.isTypeArrayTypeOrUnionOfArrayTypes)(calleeObjType, checker)) {
context.report({ node: callee.parent, messageId: 'requireCompare' });
}
}
return {
"CallExpression[arguments.length=0] > MemberExpression[property.name='sort'][computed=false]"(callee) {
const calleeObjType = util.getConstrainedTypeAtLocation(services, callee.object);
if (options.ignoreStringArrays && isStringArrayNode(callee.object)) {
return;
}
if (util.isTypeArrayTypeOrUnionOfArrayTypes(calleeObjType, checker)) {
context.report({ node: callee.parent, messageId: 'requireCompare' });
}
},
"CallExpression[arguments.length=0] > MemberExpression[property.name='sort'][computed=false]": checkSortArgument,
"CallExpression[arguments.length=0] > MemberExpression[property.name='toSorted'][computed=false]": checkSortArgument,
};

@@ -85,0 +64,0 @@ },

@@ -27,5 +27,6 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'require-await',

@@ -47,5 +48,5 @@ meta: {

create(context) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
let scopeInfo = null;

@@ -82,3 +83,3 @@ /**

data: {
name: util.upperCaseFirst(util.getFunctionNameWithKind(node)),
name: (0, util_1.upperCaseFirst)((0, util_1.getFunctionNameWithKind)(node)),
},

@@ -106,6 +107,8 @@ });

/**
* mark `scopeInfo.isAsyncYield` to `true` if its a generator
* function and the delegate is `true`
* Mark `scopeInfo.isAsyncYield` to `true` if it
* 1) delegates async generator function
* or
* 2) yields thenable type
*/
function markAsHasDelegateGen(node) {
function visitYieldExpression(node) {
if (!scopeInfo?.isGen || !node.argument) {

@@ -115,6 +118,12 @@ return;

if (node.argument.type === utils_1.AST_NODE_TYPES.Literal) {
// making this `false` as for literals we don't need to check the definition
// ignoring this as for literals we don't need to check the definition
// eg : async function* run() { yield* 1 }
scopeInfo.isAsyncYield ||= false;
return;
}
if (!node.delegate) {
if (isThenableType(services.esTreeNodeToTSNodeMap.get(node.argument))) {
scopeInfo.isAsyncYield = true;
}
return;
}
const type = services.getTypeAtLocation(node.argument);

@@ -138,4 +147,5 @@ const typesToCheck = expandUnionOrIntersectionType(type);

AwaitExpression: markAsHasAwait,
'VariableDeclaration[kind = "await using"]': markAsHasAwait,
'ForOfStatement[await = true]': markAsHasAwait,
'YieldExpression[delegate = true]': markAsHasDelegateGen,
YieldExpression: visitYieldExpression,
// check body-less async arrow function.

@@ -145,3 +155,3 @@ // ignore `async () => await foo` because it's obviously correct

const expression = services.esTreeNodeToTSNodeMap.get(node);
if (expression && isThenableType(expression)) {
if (isThenableType(expression)) {
markAsHasAwait();

@@ -164,3 +174,3 @@ }

function isEmptyFunction(node) {
return (node.body?.type === utils_1.AST_NODE_TYPES.BlockStatement &&
return (node.body.type === utils_1.AST_NODE_TYPES.BlockStatement &&
node.body.body.length === 0);

@@ -173,5 +183,5 @@ }

function getOpeningParenOfParams(node, sourceCode) {
return util.nullThrows(node.id
? sourceCode.getTokenAfter(node.id, util.isOpeningParenToken)
: sourceCode.getFirstToken(node, util.isOpeningParenToken), util.NullThrowsReasons.MissingToken('(', node.type));
return (0, util_1.nullThrows)(node.id
? sourceCode.getTokenAfter(node.id, util_1.isOpeningParenToken)
: sourceCode.getFirstToken(node, util_1.isOpeningParenToken), util_1.NullThrowsReasons.MissingToken('(', node.type));
}

@@ -183,7 +193,7 @@ // https://github.com/eslint/eslint/blob/03a69dbe86d5b5768a310105416ae726822e3c1c/lib/rules/utils/ast-utils.js#L1220-L1242

function getFunctionHeadLoc(node, sourceCode) {
const parent = util.nullThrows(node.parent, util.NullThrowsReasons.MissingParent);
const parent = (0, util_1.nullThrows)(node.parent, util_1.NullThrowsReasons.MissingParent);
let start = null;
let end = null;
if (node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression) {
const arrowToken = util.nullThrows(sourceCode.getTokenBefore(node.body, util.isArrowToken), util.NullThrowsReasons.MissingToken('=>', node.type));
const arrowToken = (0, util_1.nullThrows)(sourceCode.getTokenBefore(node.body, util_1.isArrowToken), util_1.NullThrowsReasons.MissingToken('=>', node.type));
start = arrowToken.loc.start;

@@ -190,0 +200,0 @@ end = arrowToken.loc.end;

@@ -28,4 +28,4 @@ "use strict";

const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'restrict-plus-operands',

@@ -88,3 +88,3 @@ meta: {

create(context, [{ allowAny, allowBoolean, allowNullish, allowNumberAndString, allowRegExp, skipCompoundAssignments, },]) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const typeChecker = services.program.getTypeChecker();

@@ -104,3 +104,3 @@ const stringLikes = [

function getTypeConstrained(node) {
return typeChecker.getBaseTypeOfLiteralType(util.getConstrainedTypeAtLocation(services, node));
return typeChecker.getBaseTypeOfLiteralType((0, util_1.getConstrainedTypeAtLocation)(services, node));
}

@@ -128,3 +128,3 @@ function checkPlusOperands(node) {

(!allowNullish &&
util.isTypeFlagSet(baseType, ts.TypeFlags.Null | ts.TypeFlags.Undefined))) {
(0, util_1.isTypeFlagSet)(baseType, ts.TypeFlags.Null | ts.TypeFlags.Undefined))) {
context.report({

@@ -143,7 +143,7 @@ data: {

for (const subBaseType of tsutils.unionTypeParts(baseType)) {
const typeName = util.getTypeName(typeChecker, subBaseType);
const typeName = (0, util_1.getTypeName)(typeChecker, subBaseType);
if (typeName === 'RegExp'
? !allowRegExp ||
tsutils.isTypeFlagSet(otherType, ts.TypeFlags.NumberLike)
: (!allowAny && util.isTypeAnyType(subBaseType)) ||
: (!allowAny && (0, util_1.isTypeAnyType)(subBaseType)) ||
isDeeplyObjectType(subBaseType)) {

@@ -150,0 +150,0 @@ context.report({

@@ -28,4 +28,4 @@ "use strict";

const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'restrict-template-expressions',

@@ -85,27 +85,27 @@ meta: {

create(context, [options]) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();
function isUnderlyingTypePrimitive(type) {
if (util.isTypeFlagSet(type, ts.TypeFlags.StringLike)) {
if ((0, util_1.isTypeFlagSet)(type, ts.TypeFlags.StringLike)) {
return true;
}
if (options.allowNumber &&
util.isTypeFlagSet(type, ts.TypeFlags.NumberLike | ts.TypeFlags.BigIntLike)) {
(0, util_1.isTypeFlagSet)(type, ts.TypeFlags.NumberLike | ts.TypeFlags.BigIntLike)) {
return true;
}
if (options.allowBoolean &&
util.isTypeFlagSet(type, ts.TypeFlags.BooleanLike)) {
(0, util_1.isTypeFlagSet)(type, ts.TypeFlags.BooleanLike)) {
return true;
}
if (options.allowAny && util.isTypeAnyType(type)) {
if (options.allowAny && (0, util_1.isTypeAnyType)(type)) {
return true;
}
if (options.allowRegExp && util.getTypeName(checker, type) === 'RegExp') {
if (options.allowRegExp && (0, util_1.getTypeName)(checker, type) === 'RegExp') {
return true;
}
if (options.allowNullish &&
util.isTypeFlagSet(type, ts.TypeFlags.Null | ts.TypeFlags.Undefined)) {
(0, util_1.isTypeFlagSet)(type, ts.TypeFlags.Null | ts.TypeFlags.Undefined)) {
return true;
}
if (options.allowNever && util.isTypeNeverType(type)) {
if (options.allowNever && (0, util_1.isTypeNeverType)(type)) {
return true;

@@ -122,3 +122,3 @@ }

for (const expression of node.expressions) {
const expressionType = util.getConstrainedTypeAtLocation(services, expression);
const expressionType = (0, util_1.getConstrainedTypeAtLocation)(services, expression);
if (!isInnerUnionOrIntersectionConformingTo(expressionType, isUnderlyingTypePrimitive)) {

@@ -125,0 +125,0 @@ context.report({

@@ -27,7 +27,8 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
const util_1 = require("../util");
const getOperatorPrecedence_1 = require("../util/getOperatorPrecedence");
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'return-await',

@@ -57,5 +58,5 @@ meta: {

create(context, [option]) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const scopeInfoStack = [];

@@ -116,6 +117,6 @@ function enterFunction(node) {

// Should always be an await node; but let's be safe.
/* istanbul ignore if */ if (!util.isAwaitExpression(node)) {
/* istanbul ignore if */ if (!(0, util_1.isAwaitExpression)(node)) {
return null;
}
const awaitToken = sourceCode.getFirstToken(node, util.isAwaitKeyword);
const awaitToken = sourceCode.getFirstToken(node, util_1.isAwaitKeyword);
// Should always be the case; but let's be safe.

@@ -169,3 +170,3 @@ /* istanbul ignore if */ if (!awaitToken) {

// any/unknown could be thenable; do not auto-fix
const useAutoFix = !(util.isTypeAnyType(type) || util.isTypeUnknownType(type));
const useAutoFix = !((0, util_1.isTypeAnyType)(type) || (0, util_1.isTypeUnknownType)(type));
const fix = (fixer) => removeAwait(fixer, node);

@@ -259,3 +260,3 @@ context.report({

ReturnStatement(node) {
const scopeInfo = scopeInfoStack[scopeInfoStack.length - 1];
const scopeInfo = scopeInfoStack.at(-1);
if (!scopeInfo?.hasAsync || !node.argument) {

@@ -262,0 +263,0 @@ return;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('semi');
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'semi',

@@ -32,0 +9,0 @@ meta: {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");

@@ -108,3 +85,3 @@ var Group;

}
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'sort-type-constituents',

@@ -169,3 +146,3 @@ meta: {

create(context, [{ checkIntersections, checkUnions, groupOrder }]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const collator = new Intl.Collator('en', {

@@ -205,3 +182,3 @@ sensitivity: 'base',

};
if (node.parent?.type === utils_1.AST_NODE_TYPES.TSTypeAliasDeclaration) {
if (node.parent.type === utils_1.AST_NODE_TYPES.TSTypeAliasDeclaration) {
messageId = 'notSortedNamed';

@@ -208,0 +185,0 @@ data.name = node.parent.id.name;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('space-before-blocks');
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'space-before-blocks',

@@ -51,3 +29,3 @@ meta: {

const rules = baseRule.create(context);
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
let requireSpace = true;

@@ -62,3 +40,3 @@ if (typeof config === 'object') {

const precedingToken = sourceCode.getTokenBefore(node);
if (precedingToken && util.isTokenOnSameLine(precedingToken, node)) {
if (precedingToken && (0, util_1.isTokenOnSameLine)(precedingToken, node)) {
// eslint-disable-next-line deprecation/deprecation -- TODO - switch once our min ESLint version is 6.7.0

@@ -65,0 +43,0 @@ const hasSpace = sourceCode.isSpaceBetweenTokens(precedingToken, node);

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'space-before-function-paren',

@@ -72,3 +50,3 @@ meta: {

create(context, [firstOption]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const baseConfig = typeof firstOption === 'string' ? firstOption : 'always';

@@ -100,3 +78,3 @@ const overrideConfig = typeof firstOption === 'object' ? firstOption : {};

if (node.async &&
util.isOpeningParenToken(sourceCode.getFirstToken(node, { skip: 1 }))) {
(0, util_1.isOpeningParenToken)(sourceCode.getFirstToken(node, { skip: 1 }))) {
return overrideConfig.asyncArrow ?? baseConfig;

@@ -131,3 +109,3 @@ }

else {
rightToken = sourceCode.getFirstToken(node, util.isOpeningParenToken);
rightToken = sourceCode.getFirstToken(node, util_1.isOpeningParenToken);
leftToken = sourceCode.getTokenBefore(rightToken);

@@ -134,0 +112,0 @@ }

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('space-infix-ops');
const UNIONS = ['|', '&'];
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'space-infix-ops',

@@ -55,3 +33,3 @@ meta: {

const rules = baseRule.create(context);
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
function report(operator) {

@@ -119,3 +97,3 @@ context.report({

const skipFunctionParenthesis = type.type === utils_1.TSESTree.AST_NODE_TYPES.TSFunctionType
? util.isNotOpeningParenToken
? util_1.isNotOpeningParenToken
: 0;

@@ -122,0 +100,0 @@ const operator = sourceCode.getTokenBefore(type, skipFunctionParenthesis);

@@ -27,6 +27,7 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'strict-boolean-expressions',

@@ -111,6 +112,6 @@ meta: {

create(context, [options]) {
const services = util.getParserServices(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();
const compilerOptions = services.program.getCompilerOptions();
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const isStrictNullChecks = tsutils.isStrictCompilerOptionEnabled(compilerOptions, 'strictNullChecks');

@@ -198,3 +199,3 @@ if (!isStrictNullChecks &&

function checkNode(node) {
const type = util.getConstrainedTypeAtLocation(services, node);
const type = (0, util_1.getConstrainedTypeAtLocation)(services, node);
const types = inspectVariantTypes(tsutils.unionTypeParts(type));

@@ -234,3 +235,3 @@ const is = (...wantedTypes) => types.size === wantedTypes.length &&

messageId: 'conditionFixDefaultFalse',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -243,3 +244,3 @@ node,

messageId: 'conditionFixCompareFalse',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -262,3 +263,3 @@ node: node.parent,

messageId: 'conditionFixDefaultFalse',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -271,3 +272,3 @@ node,

messageId: 'conditionFixCompareTrue',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -300,3 +301,3 @@ node,

messageId: 'conditionFixCompareStringLength',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -310,3 +311,3 @@ node: node.parent,

messageId: 'conditionFixCompareEmptyString',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -320,3 +321,3 @@ node: node.parent,

messageId: 'conditionFixCastBoolean',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -339,3 +340,3 @@ node: node.parent,

messageId: 'conditionFixCompareStringLength',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -348,3 +349,3 @@ node,

messageId: 'conditionFixCompareEmptyString',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -357,3 +358,3 @@ node,

messageId: 'conditionFixCastBoolean',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -381,3 +382,3 @@ node,

messageId: 'conditionFixCompareNullish',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -391,3 +392,3 @@ node: node.parent,

messageId: 'conditionFixDefaultEmptyString',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -400,3 +401,3 @@ node,

messageId: 'conditionFixCastBoolean',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -419,3 +420,3 @@ node: node.parent,

messageId: 'conditionFixCompareNullish',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -428,3 +429,3 @@ node,

messageId: 'conditionFixDefaultEmptyString',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -437,3 +438,3 @@ node,

messageId: 'conditionFixCastBoolean',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -459,3 +460,3 @@ node,

messageId: 'conditionErrorNumber',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -473,3 +474,3 @@ node: node.parent,

messageId: 'conditionErrorNumber',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -490,3 +491,3 @@ node,

messageId: 'conditionFixCompareZero',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -502,3 +503,3 @@ node: node.parent,

messageId: 'conditionFixCompareNaN',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -512,3 +513,3 @@ node: node.parent,

messageId: 'conditionFixCastBoolean',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -531,3 +532,3 @@ node: node.parent,

messageId: 'conditionFixCompareZero',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -540,3 +541,3 @@ node,

messageId: 'conditionFixCompareNaN',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -549,3 +550,3 @@ node,

messageId: 'conditionFixCastBoolean',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -573,3 +574,3 @@ node,

messageId: 'conditionFixCompareNullish',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -583,3 +584,3 @@ node: node.parent,

messageId: 'conditionFixDefaultZero',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -592,3 +593,3 @@ node,

messageId: 'conditionFixCastBoolean',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -611,3 +612,3 @@ node: node.parent,

messageId: 'conditionFixCompareNullish',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -620,3 +621,3 @@ node,

messageId: 'conditionFixDefaultZero',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -629,3 +630,3 @@ node,

messageId: 'conditionFixCastBoolean',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -659,3 +660,3 @@ node,

messageId: 'conditionFixCompareNullish',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -678,3 +679,3 @@ node: node.parent,

messageId: 'conditionFixCompareNullish',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -706,3 +707,3 @@ node,

messageId: 'conditionErrorNullableEnum',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -719,3 +720,3 @@ node: node.parent,

messageId: 'conditionErrorNullableEnum',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -739,3 +740,3 @@ node,

messageId: 'conditionFixCastBoolean',
fix: util.getWrappingFixer({
fix: (0, util_1.getWrappingFixer)({
sourceCode,

@@ -809,3 +810,3 @@ node,

}
if (types.some(type => util.isTypeFlagSet(type, ts.TypeFlags.TypeParameter |
if (types.some(type => tsutils.isTypeFlagSet(type, ts.TypeFlags.TypeParameter |
ts.TypeFlags.Any |

@@ -835,5 +836,5 @@ ts.TypeFlags.Unknown))) {

}
const objectType = util.getConstrainedTypeAtLocation(services, node.object);
return util.isTypeArrayTypeOrUnionOfArrayTypes(objectType, typeChecker);
const objectType = (0, util_1.getConstrainedTypeAtLocation)(services, node.object);
return (0, util_1.isTypeArrayTypeOrUnionOfArrayTypes)(objectType, typeChecker);
}
//# sourceMappingURL=strict-boolean-expressions.js.map

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

Object.defineProperty(exports, "__esModule", { value: true });
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));

@@ -35,7 +36,18 @@ const ts = __importStar(require("typescript"));

docs: {
description: 'Require switch-case statements to be exhaustive with union type',
description: 'Require switch-case statements to be exhaustive',
requiresTypeChecking: true,
},
hasSuggestions: true,
schema: [],
schema: [
{
type: 'object',
additionalProperties: false,
properties: {
requireDefaultForNonUnion: {
description: `If 'true', require a 'default' clause for switches on non-union types.`,
type: 'boolean',
},
},
},
],
messages: {

@@ -46,9 +58,10 @@ switchIsNotExhaustive: 'Switch is not exhaustive. Cases not matched: {{missingBranches}}',

},
defaultOptions: [],
create(context) {
const sourceCode = context.getSourceCode();
defaultOptions: [{ requireDefaultForNonUnion: false }],
create(context, [{ requireDefaultForNonUnion }]) {
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const services = (0, util_1.getParserServices)(context);
const checker = services.program.getTypeChecker();
const compilerOptions = services.program.getCompilerOptions();
function fixSwitch(fixer, node, missingBranchTypes, symbolName) {
function fixSwitch(fixer, node, missingBranchTypes, // null means default branch
symbolName) {
const lastCase = node.cases.length > 0 ? node.cases[node.cases.length - 1] : null;

@@ -62,2 +75,6 @@ const caseIndent = lastCase

for (const missingBranchType of missingBranchTypes) {
if (missingBranchType == null) {
missingCases.push(`default: { throw new Error('default case') }`);
continue;
}
// While running this rule on checker.ts of TypeScript project

@@ -81,6 +98,11 @@ // the fix introduced a compiler error due to:

(0, util_1.requiresQuoting)(missingBranchName.toString(), compilerOptions.target)) {
caseTest = `${symbolName}['${missingBranchName}']`;
const escapedBranchName = missingBranchName
.replace(/'/g, "\\'")
.replace(/\n/g, '\\n')
.replace(/\r/g, '\\r');
caseTest = `${symbolName}['${escapedBranchName}']`;
}
const errorMessage = `Not implemented yet: ${caseTest} case`;
missingCases.push(`case ${caseTest}: { throw new Error('${errorMessage}') }`);
const escapedErrorMessage = errorMessage.replace(/'/g, "\\'");
missingCases.push(`case ${caseTest}: { throw new Error('${escapedErrorMessage}') }`);
}

@@ -136,2 +158,22 @@ const fixString = missingCases

}
else if (requireDefaultForNonUnion) {
const hasDefault = node.cases.some(switchCase => switchCase.test == null);
if (!hasDefault) {
context.report({
node: node.discriminant,
messageId: 'switchIsNotExhaustive',
data: {
missingBranches: 'default',
},
suggest: [
{
messageId: 'addMissingCases',
fix(fixer) {
return fixSwitch(fixer, node, [null]);
},
},
],
});
}
}
}

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

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'triple-slash-reference',

@@ -69,3 +47,3 @@ meta: {

let programNode;
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const references = [];

@@ -72,0 +50,0 @@ function hasMatchingReference(source) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const util = __importStar(require("../util"));
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");

@@ -37,3 +14,3 @@ function createRules(options) {

...globals,
...override?.colon,
...override.colon,
};

@@ -43,3 +20,3 @@ const arrow = {

...globals,
...override?.arrow,
...override.arrow,
};

@@ -49,6 +26,6 @@ return {

arrow: arrow,
variable: { ...colon, ...override?.variable },
property: { ...colon, ...override?.property },
parameter: { ...colon, ...override?.parameter },
returnType: { ...colon, ...override?.returnType },
variable: { ...colon, ...override.variable },
property: { ...colon, ...override.property },
parameter: { ...colon, ...override.parameter },
returnType: { ...colon, ...override.returnType },
};

@@ -67,3 +44,3 @@ }

function getRules(rules, node) {
const scope = node?.parent?.parent;
const scope = node.parent.parent;
if ((0, util_1.isTSFunctionType)(scope) || (0, util_1.isTSConstructorType)(scope)) {

@@ -83,3 +60,3 @@ return rules.arrow;

}
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'type-annotation-spacing',

@@ -139,3 +116,3 @@ meta: {

const punctuators = [':', '=>'];
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
const ruleSet = createRules(options);

@@ -142,0 +119,0 @@ /**

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'typedef',

@@ -108,4 +85,3 @@ meta: {

// Check TS parameter property with default value like `constructor(private param: string = 'something') {}`
if (annotationNode &&
annotationNode.type === utils_1.AST_NODE_TYPES.AssignmentPattern) {
if (annotationNode.type === utils_1.AST_NODE_TYPES.AssignmentPattern) {
annotationNode = annotationNode.left;

@@ -118,3 +94,3 @@ }

}
if (annotationNode !== undefined && !annotationNode.typeAnnotation) {
if (!annotationNode.typeAnnotation) {
report(param, getNodeName(param));

@@ -144,3 +120,3 @@ }

ArrayPattern(node) {
if (node.parent?.type === utils_1.AST_NODE_TYPES.RestElement &&
if (node.parent.type === utils_1.AST_NODE_TYPES.RestElement &&
node.parent.typeAnnotation) {

@@ -152,3 +128,3 @@ return;

!isAncestorHasTypeAnnotation(node) &&
node.parent?.type !== utils_1.AST_NODE_TYPES.AssignmentExpression) {
node.parent.type !== utils_1.AST_NODE_TYPES.AssignmentExpression) {
report(node);

@@ -155,0 +131,0 @@ }

@@ -27,5 +27,5 @@ "use strict";

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const tsutils = __importStar(require("ts-api-utils"));
const ts = __importStar(require("typescript"));
const util = __importStar(require("../util"));
const util_1 = require("../util");

@@ -81,3 +81,3 @@ /**

'Object',
'String',
'String', // eslint-disable-line @typescript-eslint/internal/prefer-ast-types-enum
'RegExp',

@@ -122,3 +122,3 @@ 'Symbol',

const BASE_MESSAGE = 'Avoid referencing unbound methods which may cause unintentional scoping of `this`.';
exports.default = util.createRule({
exports.default = (0, util_1.createRule)({
name: 'unbound-method',

@@ -157,4 +157,4 @@ meta: {

create(context, [{ ignoreStatic }]) {
const services = util.getParserServices(context);
const currentSourceFile = services.program.getSourceFile(context.getFilename());
const services = (0, util_1.getParserServices)(context);
const currentSourceFile = services.program.getSourceFile((0, eslint_utils_1.getFilename)(context));
function checkMethodAndReport(node, symbol) {

@@ -199,3 +199,3 @@ if (!symbol) {

if (notImported &&
util.isIdentifier(initNode) &&
(0, util_1.isIdentifier)(initNode) &&
nativelyBoundMembers.includes(`${initNode.name}.${property.key.name}`)) {

@@ -227,8 +227,7 @@ return;

const decl = valueDeclaration;
const firstParam = decl.parameters[0];
const firstParam = decl.parameters.at(0);
const firstParamIsThis = firstParam?.name.kind === ts.SyntaxKind.Identifier &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
firstParam?.name.escapedText === 'this';
const thisArgIsVoid = firstParamIsThis &&
firstParam?.type?.kind === ts.SyntaxKind.VoidKeyword;
firstParam.name.escapedText === 'this';
const thisArgIsVoid = firstParamIsThis && firstParam.type?.kind === ts.SyntaxKind.VoidKeyword;
return {

@@ -235,0 +234,0 @@ dangerous: !thisArgIsVoid &&

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("@typescript-eslint/utils");
const util = __importStar(require("../util"));
exports.default = util.createRule({
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
const util_1 = require("../util");
exports.default = (0, util_1.createRule)({
name: 'unified-signatures',

@@ -61,3 +39,3 @@ meta: {

create(context, [{ ignoreDifferentlyNamedParameters }]) {
const sourceCode = context.getSourceCode();
const sourceCode = (0, eslint_utils_1.getSourceCode)(context);
//----------------------------------------------------------------------

@@ -157,3 +135,3 @@ // Helpers

// If one uses a type parameter (from outside) and the other doesn't, they shouldn't be joined.
util.arraysAreEqual(aTypeParams, bTypeParams, typeParametersAreEqual) &&
(0, util_1.arraysAreEqual)(aTypeParams, bTypeParams, typeParametersAreEqual) &&
signatureUsesTypeParameter(a, isTypeParameter) ===

@@ -169,3 +147,3 @@ signatureUsesTypeParameter(b, isTypeParameter));

// If remaining arrays are equal, the signatures differ by just one parameter type
if (!util.arraysAreEqual(types1.slice(index + 1), types2.slice(index + 1), parametersAreEqual)) {
if (!(0, util_1.arraysAreEqual)(types1.slice(index + 1), types2.slice(index + 1), parametersAreEqual)) {
return undefined;

@@ -255,4 +233,3 @@ }

function isTSParameterProperty(node) {
return (node.type ===
utils_1.AST_NODE_TYPES.TSParameterProperty);
return node.type === utils_1.AST_NODE_TYPES.TSParameterProperty;
}

@@ -336,3 +313,3 @@ function parametersAreEqual(a, b) {

function addOverload(signature, key, containingNode) {
key = key ?? getOverloadKey(signature);
key ??= getOverloadKey(signature);
if (currentScope &&

@@ -339,0 +316,0 @@ (containingNode || signature).parent === currentScope.parent) {

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

const utils_1 = require("@typescript-eslint/utils");
const eslint_utils_1 = require("@typescript-eslint/utils/eslint-utils");
class UnusedVarsVisitor extends scope_manager_1.Visitor {

@@ -42,6 +43,6 @@ // readonly #unusedVariables = new Set<TSESLint.Scope.Variable>();

this.TSMethodSignature = this.visitFunctionTypeSignature;
__classPrivateFieldSet(this, _UnusedVarsVisitor_scopeManager, utils_1.ESLintUtils.nullThrows(context.getSourceCode().scopeManager, 'Missing required scope manager'), "f");
__classPrivateFieldSet(this, _UnusedVarsVisitor_scopeManager, utils_1.ESLintUtils.nullThrows((0, eslint_utils_1.getSourceCode)(context).scopeManager, 'Missing required scope manager'), "f");
}
static collectUnusedVariables(context) {
const program = context.getSourceCode().ast;
const program = (0, eslint_utils_1.getSourceCode)(context).ast;
const cached = this.RESULTS_CACHE.get(program);

@@ -180,3 +181,3 @@ if (cached) {

if (node.left.type === utils_1.AST_NODE_TYPES.VariableDeclaration) {
const variable = __classPrivateFieldGet(this, _UnusedVarsVisitor_scopeManager, "f").getDeclaredVariables(node.left)[0];
const variable = __classPrivateFieldGet(this, _UnusedVarsVisitor_scopeManager, "f").getDeclaredVariables(node.left).at(0);
if (!variable) {

@@ -230,3 +231,3 @@ return;

// -- global augmentation can be in any file, and they do not need exports
if (node.global === true) {
if (node.global) {
this.markVariableAsUsed('global', node.parent);

@@ -327,2 +328,3 @@ }

}
const LOGICAL_ASSIGNMENT_OPERATORS = new Set(['&&=', '||=', '??=']);
/**

@@ -528,2 +530,3 @@ * Determines if the variable is used.

((parent.type === utils_1.AST_NODE_TYPES.AssignmentExpression &&
!LOGICAL_ASSIGNMENT_OPERATORS.has(parent.operator) &&
grandparent.type === utils_1.AST_NODE_TYPES.ExpressionStatement &&

@@ -530,0 +533,0 @@ parent.left === id) ||

@@ -28,2 +28,32 @@ "use strict";

* ```
* foo(() => 1)
* ```
*/
function isFunctionArgument(parent, callee) {
return (parent.type === utils_1.AST_NODE_TYPES.CallExpression &&
// make sure this isn't an IIFE
parent.callee !== callee);
}
/**
* Checks if a node is type-constrained in JSX
* ```
* <Foo x={() => {}} />
* <Bar>{() => {}}</Bar>
* <Baz {...props} />
* ```
*/
function isTypedJSX(node) {
return (node.type === utils_1.AST_NODE_TYPES.JSXExpressionContainer ||
node.type === utils_1.AST_NODE_TYPES.JSXSpreadAttribute);
}
function isTypedParent(parent, callee) {
return ((0, astUtils_1.isTypeAssertion)(parent) ||
isVariableDeclaratorWithTypeAnnotation(parent) ||
isPropertyDefinitionWithTypeAnnotation(parent) ||
isFunctionArgument(parent, callee) ||
isTypedJSX(parent));
}
/**
* Checks if a node belongs to:
* ```
* new Foo(() => {})

@@ -49,16 +79,8 @@ * ^^^^^^^^

}
const objectExpr = property.parent; // this shouldn't happen, checking just in case
/* istanbul ignore if */ if (!objectExpr ||
objectExpr.type !== utils_1.AST_NODE_TYPES.ObjectExpression) {
const objectExpr = property.parent;
if (objectExpr.type !== utils_1.AST_NODE_TYPES.ObjectExpression) {
return false;
}
const parent = objectExpr.parent; // this shouldn't happen, checking just in case
/* istanbul ignore if */ if (!parent) {
return false;
}
return ((0, astUtils_1.isTypeAssertion)(parent) ||
isPropertyDefinitionWithTypeAnnotation(parent) ||
isVariableDeclaratorWithTypeAnnotation(parent) ||
isFunctionArgument(parent) ||
isPropertyOfObjectWithType(parent));
const parent = objectExpr.parent;
return isTypedParent(parent) || isPropertyOfObjectWithType(parent);
}

@@ -77,6 +99,2 @@ /**

function doesImmediatelyReturnFunctionExpression({ body, }) {
// Should always have a body; really checking just in case
/* istanbul ignore if */ if (!body) {
return false;
}
// Check if body is a block with a single statement

@@ -98,13 +116,2 @@ if (body.type === utils_1.AST_NODE_TYPES.BlockStatement && body.body.length === 1) {

/**
* Checks if a node belongs to:
* ```
* foo(() => 1)
* ```
*/
function isFunctionArgument(parent, callee) {
return (parent.type === utils_1.AST_NODE_TYPES.CallExpression &&
// make sure this isn't an IIFE
parent.callee !== callee);
}
/**
* Checks if a function belongs to:

@@ -137,7 +144,4 @@ * ```

}
return ((0, astUtils_1.isTypeAssertion)(parent) ||
isVariableDeclaratorWithTypeAnnotation(parent) ||
isPropertyDefinitionWithTypeAnnotation(parent) ||
return (isTypedParent(parent, node) ||
isPropertyOfObjectWithType(parent) ||
isFunctionArgument(parent, node) ||
isConstructorArgument(parent));

@@ -205,8 +209,8 @@ }

let ancestor = node.parent;
if (ancestor?.type === utils_1.AST_NODE_TYPES.Property) {
if (ancestor.type === utils_1.AST_NODE_TYPES.Property) {
ancestor = ancestor.value;
}
// if the ancestor is not a return, then this function was not returned at all, so we can exit early
const isReturnStatement = ancestor?.type === utils_1.AST_NODE_TYPES.ReturnStatement;
const isBodylessArrow = ancestor?.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression &&
const isReturnStatement = ancestor.type === utils_1.AST_NODE_TYPES.ReturnStatement;
const isBodylessArrow = ancestor.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression &&
ancestor.body.type !== utils_1.AST_NODE_TYPES.BlockStatement;

@@ -232,2 +236,7 @@ if (!isReturnStatement && !isBodylessArrow) {

break;
case utils_1.AST_NODE_TYPES.PropertyDefinition:
if (ancestor.typeAnnotation) {
return true;
}
break;
}

@@ -234,0 +243,0 @@ ancestor = ancestor.parent;

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

case typescript_1.SyntaxKind.AsExpression:
case typescript_1.SyntaxKind.SatisfiesExpression:
return OperatorPrecedence.Relational;

@@ -317,0 +318,0 @@ case typescript_1.SyntaxKind.ThisKeyword:

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

function getThisExpression(node) {
while (node) {
while (true) {
if (node.type === utils_1.AST_NODE_TYPES.CallExpression) {

@@ -9,0 +9,0 @@ node = node.callee;

@@ -15,6 +15,9 @@ "use strict";

let code = sourceCode.getText(innerNode);
// check the inner expression's precedence
if (!isStrongPrecedenceNode(innerNode)) {
// the code we are adding might have stronger precedence than our wrapped node
// let's wrap our node in parens in case it has a weaker precedence than the code we are wrapping it in
/**
* Wrap our node in parens to prevent the following cases:
* - It has a weaker precedence than the code we are wrapping it in
* - It's gotten mistaken as block statement instead of object expression
*/
if (!isStrongPrecedenceNode(innerNode) ||
isObjectExpressionInOneLineReturn(node, innerNode)) {
code = `(${code})`;

@@ -48,2 +51,4 @@ }

innerNode.type === utils_1.AST_NODE_TYPES.Identifier ||
innerNode.type === utils_1.AST_NODE_TYPES.TSTypeReference ||
innerNode.type === utils_1.AST_NODE_TYPES.TSTypeOperator ||
innerNode.type === utils_1.AST_NODE_TYPES.ArrayExpression ||

@@ -54,3 +59,4 @@ innerNode.type === utils_1.AST_NODE_TYPES.ObjectExpression ||

innerNode.type === utils_1.AST_NODE_TYPES.NewExpression ||
innerNode.type === utils_1.AST_NODE_TYPES.TaggedTemplateExpression);
innerNode.type === utils_1.AST_NODE_TYPES.TaggedTemplateExpression ||
innerNode.type === utils_1.AST_NODE_TYPES.TSInstantiationExpression);
}

@@ -144,2 +150,10 @@ exports.isStrongPrecedenceNode = isStrongPrecedenceNode;

}
/**
* Checks if a node's parent is arrow function expression and a inner node is object expression
*/
function isObjectExpressionInOneLineReturn(node, innerNode) {
return (node.parent?.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression &&
node.parent.body === node &&
innerNode.type === utils_1.AST_NODE_TYPES.ObjectExpression);
}
//# sourceMappingURL=getWrappingFixer.js.map

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

function formatWordList(words) {
if (!words?.length) {
if (!words.length) {
return '';

@@ -157,0 +157,0 @@ }

@@ -93,2 +93,8 @@ ---

If you don't care about the general structure of the code, then you will not need this rule.
It can sometimes be useful to place overload signatures alongside other meaningful parts of a type.
For example, if each of a function's overloads corresponds to a different property, you might wish to put each overloads next to its corresponding property.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
## Related To
- [`unified-signatures`](./unified-signatures.md)

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

```ts
```ts option='{ "default": "array" }'
const x: Array<string> = ['a', 'b'];

@@ -33,3 +33,3 @@ const y: ReadonlyArray<string> = ['a', 'b'];

```ts
```ts option='{ "default": "array" }'
const x: string[] = ['a', 'b'];

@@ -47,3 +47,3 @@ const y: readonly string[] = ['a', 'b'];

```ts
```ts option='{ "default": "generic" }'
const x: string[] = ['a', 'b'];

@@ -55,3 +55,3 @@ const y: readonly string[] = ['a', 'b'];

```ts
```ts option='{ "default": "generic" }'
const x: Array<string> = ['a', 'b'];

@@ -70,3 +70,3 @@ const y: ReadonlyArray<string> = ['a', 'b'];

```ts
```ts option='{ "default": "array-simple" }'
const a: (string | number)[] = ['a', 'b'];

@@ -82,3 +82,3 @@ const b: { prop: string }[] = [{ prop: 'a' }];

```ts
```ts option='{ "default": "array-simple" }'
const a: Array<string | number> = ['a', 'b'];

@@ -110,1 +110,9 @@ const b: Array<{ prop: string }> = [{ prop: 'a' }];

| `generic` | `generic` | `Array<number>` | `Array<Foo & Bar>` | `ReadonlyArray<number>` | `ReadonlyArray<Foo & Bar>` |
## When Not To Use It
This rule is purely a stylistic rule for maintaining consistency in your project.
You can turn it off if you don't want to keep a consistent style for array types.
However, keep in mind that inconsistent style can harm readability in a project.
We recommend picking a single option for this rule that works best for your project.

@@ -40,2 +40,4 @@ ---

If you want to allow code to `await` non-Promise values.
This is generally not preferred, but can sometimes be useful for visual consistency.
For example, if your framework is in transition from one style of asynchronous code to another, it may be useful to include `await`s unnecessarily.
This is generally not preferred but can sometimes be useful for visual consistency.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -36,3 +36,3 @@ ---

```ts
```ts option='{ "ts-ignore": true }'
if (false) {

@@ -52,3 +52,3 @@ // @ts-ignore: Unreachable code error

```ts
```ts option='{ "ts-ignore": true }'
if (false) {

@@ -70,3 +70,3 @@ // Compiler warns about unreachable code error

```ts
```ts option='{ "ts-expect-error": "allow-with-description" }'
if (false) {

@@ -84,3 +84,3 @@ // @ts-expect-error

```ts
```ts option='{ "ts-expect-error": "allow-with-description" }'
if (false) {

@@ -108,3 +108,4 @@ // @ts-expect-error: Unreachable code error

```ts
<!-- prettier-ignore -->
```ts option='{ "ts-expect-error": { "descriptionFormat": "^: TS\\\\d+ because .+$" } }'
// @ts-expect-error: the library definition is wrong

@@ -116,3 +117,4 @@ const a = doSomething('hello');

```ts
<!-- prettier-ignore -->
```ts option='{ "ts-expect-error": { "descriptionFormat": "^: TS\\\\d+ because .+$" } }'
// @ts-expect-error: TS1234 because the library definition is wrong

@@ -132,3 +134,3 @@ const a = doSomething('hello');

```ts
```ts option='{ "ts-expect-error": "allow-with-description", "minimumDescriptionLength": 10 }'
if (false) {

@@ -142,3 +144,3 @@ // @ts-expect-error: TODO

```ts
```ts option='{ "ts-expect-error": "allow-with-description", "minimumDescriptionLength": 10 }'
if (false) {

@@ -152,3 +154,4 @@ // @ts-expect-error The rationale for this override is described in issue #1337 on GitLab

If you want to use all of the TypeScript directives.
If your project or its dependencies were not architected with strong type safety in mind, it can be difficult to always adhere to proper TypeScript semantics.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -155,0 +158,0 @@ ## Further Reading

@@ -39,2 +39,2 @@ ---

If you are still using TSLint.
If you are still using TSLint alongside ESLint.

@@ -78,59 +78,3 @@ ---

```ts
const defaultTypes = {
String: {
message: 'Use string instead',
fixWith: 'string',
},
Boolean: {
message: 'Use boolean instead',
fixWith: 'boolean',
},
Number: {
message: 'Use number instead',
fixWith: 'number',
},
Symbol: {
message: 'Use symbol instead',
fixWith: 'symbol',
},
BigInt: {
message: 'Use bigint instead',
fixWith: 'bigint',
},
Function: {
message: [
'The `Function` type accepts any function-like value.',
'It provides no type safety when calling the function, which can be a common source of bugs.',
'It also accepts things like class declarations, which will throw at runtime as they will not be called with `new`.',
'If you are expecting the function to accept certain arguments, you should explicitly define the function shape.',
].join('\n'),
},
// object typing
Object: {
message: [
'The `Object` type actually means "any non-nullish value", so it is marginally better than `unknown`.',
'- If you want a type meaning "any object", you probably want `object` instead.',
'- If you want a type meaning "any value", you probably want `unknown` instead.',
'- If you really want a type meaning "any non-nullish value", you probably want `NonNullable<unknown>` instead.',
].join('\n'),
suggest: ['object', 'unknown', 'NonNullable<unknown>'],
},
'{}': {
message: [
'`{}` actually means "any non-nullish value".',
'- If you want a type meaning "any object", you probably want `object` instead.',
'- If you want a type meaning "any value", you probably want `unknown` instead.',
'- If you want a type meaning "empty object", you probably want `Record<string, never>` instead.',
'- If you really want a type meaning "any non-nullish value", you probably want `NonNullable<unknown>` instead.',
].join('\n'),
suggest: [
'object',
'unknown',
'Record<string, never>',
'NonNullable<unknown>',
],
},
};
```
<!-- Inject default options -->

@@ -185,1 +129,6 @@ </details>

```
## When Not To Use It
If your project is a rare one that intentionally deals with the class equivalents of primitives, it might not be worthwhile to enable the default `ban-types` options.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -8,4 +8,7 @@ :::danger Deprecated

<!--
This doc file has been left on purpose because `camelcase` is a core ESLint rule.
This exists to help direct people to the replacement rule.
This doc file has been left on purpose because `camelcase` is a core ESLint
rule. This exists to help direct people to the replacement rule.
Note that there is no actual way to get to this page in the normal navigation,
so end-users will only be able to get to this page from the search bar.
-->

@@ -34,5 +34,3 @@ ---

```ts
/* eslint @typescript-eslint/class-literal-property-style: ["error", "fields"] */
```ts option='"fields"'
class Mx {

@@ -51,5 +49,3 @@ public static get myField1() {

```ts
/* eslint @typescript-eslint/class-literal-property-style: ["error", "fields"] */
```ts option='"fields"'
class Mx {

@@ -81,5 +77,3 @@ public readonly myField1 = 1;

```ts
/* eslint @typescript-eslint/class-literal-property-style: ["error", "getters"] */
```ts option='"getters"'
class Mx {

@@ -94,5 +88,3 @@ readonly myField1 = 1;

```ts
/* eslint @typescript-eslint/class-literal-property-style: ["error", "getters"] */
```ts option='"getters"'
class Mx {

@@ -117,3 +109,2 @@ // no readonly modifier

When you have no strong preference, or do not wish to enforce a particular style
for how literal values are exposed by your classes.
When you have no strong preference, or do not wish to enforce a particular style for how literal values are exposed by your classes.

@@ -19,3 +19,3 @@ ---

ignoreOverrideMethods?: boolean;
ignoreClassesThatImplementAnInterface?: boolean;
ignoreClassesThatImplementAnInterface?: boolean | 'public-fields';
}

@@ -36,3 +36,3 @@

```ts
```ts option='{ "ignoreOverrideMethods": true }' showPlaygroundButton
class X {

@@ -46,8 +46,29 @@ override method() {}

Makes the rule ignore all class members that are defined within a class that `implements` a type.
Makes the rule ignore class members that are defined within a class that `implements` a type.
If specified, it can be either:
- `true`: Ignore all classes that implement an interface
- `'public-fields'`: Ignore only the public fields of classes that implement an interface
It's important to note that this option does not only apply to members defined in the interface as that would require type information.
#### `true`
Example of a correct code when `ignoreClassesThatImplementAnInterface` is set to `true`:
```ts option='{ "ignoreClassesThatImplementAnInterface": true }' showPlaygroundButton
class X implements Y {
method() {}
property = () => {};
}
```
#### `'public-fields'`
Example of a incorrect code when `ignoreClassesThatImplementAnInterface` is set to `'public-fields'`:
<!--tabs-->
##### ❌ Incorrect
```ts

@@ -57,3 +78,23 @@ class X implements Y {

property = () => {};
private privateMethod() {}
private privateProperty = () => {};
protected privateMethod() {}
protected privateProperty = () => {};
}
```
##### ✅ Correct
```ts
class X implements Y {
method() {}
property = () => {};
}
```
## When Not To Use It
If your project dynamically changes `this` scopes around in a way TypeScript has difficulties modeling, this rule may not be viable to use.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -36,3 +36,3 @@ ---

```ts
```ts option='"constructor"'
const map: Map<string, number> = new Map();

@@ -44,3 +44,3 @@ const set: Set<string> = new Set();

```ts
```ts option='"constructor"'
const map = new Map<string, number>();

@@ -59,3 +59,3 @@ const map: Map<string, number> = new MyMap();

```ts
```ts option='"type-annotation"'
const map = new Map<string, number>();

@@ -67,3 +67,3 @@ const set = new Set<string>();

```ts
```ts option='"type-annotation"'
const map: Map<string, number> = new Map();

@@ -78,1 +78,4 @@ const set: Set<string> = new Set();

You can turn this rule off if you don't want to enforce one kind of generic constructor style over the other.
However, keep in mind that inconsistent style can harm readability in a project.
We recommend picking a single option for this rule that works best for your project.

@@ -36,5 +36,3 @@ ---

```ts
/* eslint @typescript-eslint/consistent-indexed-object-style: ["error", "record"] */
```ts option='"record"'
interface Foo {

@@ -51,5 +49,3 @@ [key: string]: unknown;

```ts
/* eslint @typescript-eslint/consistent-indexed-object-style: ["error", "record"] */
```ts option='"record"'
type Foo = Record<string, unknown>;

@@ -64,5 +60,3 @@ ```

```ts
/* eslint @typescript-eslint/consistent-indexed-object-style: ["error", "index-signature"] */
```ts option='"index-signature"'
type Foo = Record<string, unknown>;

@@ -73,5 +67,3 @@ ```

```ts
/* eslint @typescript-eslint/consistent-indexed-object-style: ["error", "index-signature"] */
```ts option='"index-signature"'
interface Foo {

@@ -85,1 +77,9 @@ [key: string]: unknown;

```
## When Not To Use It
This rule is purely a stylistic rule for maintaining consistency in your project.
You can turn it off if you don't want to keep a consistent style for indexed object types.
However, keep in mind that inconsistent style can harm readability in a project.
We recommend picking a single option for this rule that works best for your project.

@@ -56,3 +56,3 @@ ---

```ts
```ts option='{ "assertionStyle": "as", "objectLiteralTypeAssertions": "never" }'
const x = { ... } as T;

@@ -67,3 +67,3 @@

```ts
```ts option='{ "assertionStyle": "as", "objectLiteralTypeAssertions": "never" }'
const x: T = { ... };

@@ -86,3 +86,3 @@ const y = { ... } as any;

```ts
```ts option='{ "assertionStyle": "as", "objectLiteralTypeAssertions": "allow-as-parameter" }'
const x = { ... } as T;

@@ -97,3 +97,3 @@

```tsx
```tsx option='{ "assertionStyle": "as", "objectLiteralTypeAssertions": "allow-as-parameter" }'
const x: T = { ... };

@@ -113,1 +113,4 @@ const y = { ... } as any;

If you do not want to enforce consistent type assertions.
However, keep in mind that inconsistent style can harm readability in a project.
We recommend picking a single option for this rule that works best for your project.

@@ -39,5 +39,3 @@ ---

```ts
/* eslint @typescript-eslint/consistent-type-definitions: ["error", "interface"] */
```ts option='"interface"'
type T = { x: number };

@@ -48,5 +46,3 @@ ```

```ts
/* eslint @typescript-eslint/consistent-type-definitions: ["error", "interface"] */
```ts option='"interface"'
type T = string;

@@ -66,5 +62,3 @@ type Foo = string | {};

```ts
/* eslint @typescript-eslint/consistent-type-definitions: ["error", "type"] */
```ts option='"type"'
interface T {

@@ -77,5 +71,3 @@ x: number;

```ts
/* eslint @typescript-eslint/consistent-type-definitions: ["error", "type"] */
```ts option='"type"'
type T = { x: number };

@@ -86,2 +78,9 @@ ```

If you specifically want to use an interface or type literal for stylistic reasons, you can disable this rule.
If you specifically want to use an interface or type literal for stylistic reasons, you can avoid this rule.
However, keep in mind that inconsistent style can harm readability in a project.
We recommend picking a single option for this rule that works best for your project.
There are also subtle differences between `Record` and `interface` that can be difficult to catch statically.
For example, if your project is a dependency of another project that relies on a specific type definition style, this rule may be counterproductive.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -86,3 +86,3 @@ ---

```ts
```ts option='{ "fixMixedExportsWithInlineTypeSpecifier": true }'
export { Button } from 'some-library';

@@ -94,3 +94,3 @@ export type { ButtonProps } from 'some-library';

```ts
```ts option='{ "fixMixedExportsWithInlineTypeSpecifier": true }'
export { Button, type ButtonProps } from 'some-library';

@@ -101,3 +101,8 @@ ```

- If you specifically want to use both export kinds for stylistic reasons, you can disable this rule.
- If you use `--isolatedModules` the compiler would error if a type is not re-exported using `export type`. If you also don't wish to enforce one style over the other, you can disable this rule.
If you use `--isolatedModules` the compiler would error if a type is not re-exported using `export type`.
This rule may be less useful in those cases.
If you specifically want to use both export kinds for stylistic reasons, or don't wish to enforce one style over the other, you can avoid this rule.
However, keep in mind that inconsistent style can harm readability in a project.
We recommend picking a single option for this rule that works best for your project.

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

```ts
```ts option='{ "prefer": "type-imports" }' showPlaygroundButton
import type { Foo } from 'Foo';

@@ -35,3 +35,3 @@ import type Bar from 'Bar';

```ts
```ts option='{ "prefer": "type-imports" }' showPlaygroundButton
import { Foo } from 'Foo';

@@ -63,3 +63,3 @@ import Bar from 'Bar';

```ts
```ts option='{ "fixStyle": "separate-type-imports" }'
import type { Foo } from 'Foo';

@@ -73,3 +73,3 @@ import type Bar from 'Bar';

```ts
```ts option='{ "fixStyle": "inline-type-imports" }'
import { type Foo } from 'Foo';

@@ -90,3 +90,3 @@ import type Bar from 'Bar';

```ts
```ts option='{ "disallowTypeAnnotations": true }' showPlaygroundButton
type T = import('Foo').Foo;

@@ -104,4 +104,7 @@ const x: import('Bar') = 1;

- If you specifically want to use both import kinds for stylistic reasons, you can disable this rule.
If you specifically want to use both import kinds for stylistic reasons, or don't wish to enforce one style over the other, you can avoid this rule.
However, keep in mind that inconsistent style can harm readability in a project.
We recommend picking a single option for this rule that works best for your project.
## Related To

@@ -108,0 +111,0 @@

@@ -23,6 +23,12 @@ ---

class Foo {
constructor(public a = 10, private b: number) {}
constructor(
public a = 10,
private b: number,
) {}
}
class Foo {
constructor(public a?: number, private b: number) {}
constructor(
public a?: number,
private b: number,
) {}
}

@@ -42,7 +48,13 @@ ```

class Foo {
constructor(public a, private b = 0) {}
constructor(
public a,
private b = 0,
) {}
}
class Foo {
constructor(public a, private b?: number) {}
constructor(
public a,
private b?: number,
) {}
}
```

@@ -40,3 +40,3 @@ ---

```ts
```ts option='{ "allowPrivateClassPropertyAccess": true }' showPlaygroundButton
class X {

@@ -54,3 +54,3 @@ private priv_prop = 123;

```ts
```ts option='{ "allowProtectedClassPropertyAccess": true }' showPlaygroundButton
class X {

@@ -68,3 +68,3 @@ protected protected_prop = 123;

```ts
```ts option='{ "allowIndexSignaturePropertyAccess": true }' showPlaygroundButton
class X {

@@ -79,1 +79,8 @@ [key: string]: number;

If the TypeScript compiler option `noPropertyAccessFromIndexSignature` is set to `true`, then the above code is always allowed, even if `allowIndexSignaturePropertyAccess` is `false`.
## When Not To Use It
If you specifically want to use both member access kinds for stylistic reasons, or don't wish to enforce one style over the other, you can avoid this rule.
However, keep in mind that inconsistent style can harm readability in a project.
We recommend picking a single option for this rule that works best for your project.

@@ -101,3 +101,3 @@ ---

```ts
```ts option='{ "allowExpressions": true }'
function test() {}

@@ -112,3 +112,3 @@

```ts
```ts option='{ "allowExpressions": true }'
node.addEventListener('click', () => {});

@@ -129,3 +129,3 @@

```ts
```ts option='{ "allowTypedFunctionExpressions": true }'
let arrowFn = () => 'test';

@@ -144,3 +144,3 @@

```ts
```ts option='{ "allowTypedFunctionExpressions": true }'
type FuncType = () => string;

@@ -179,2 +179,6 @@

});
const Comp: FC = () => {
return <button onClick={() => {}} />;
};
```

@@ -190,3 +194,3 @@

```ts
```ts option='{ "allowHigherOrderFunctions": true }'
var arrowFn = () => () => {};

@@ -201,3 +205,3 @@

```ts
```ts option='{ "allowHigherOrderFunctions": true }'
var arrowFn = () => (): void => {};

@@ -218,5 +222,5 @@

```ts
const func = (value: number) => ({ type: 'X', value } as any);
const func = (value: number) => ({ type: 'X', value } as Action);
```ts option='{ "allowDirectConstAssertionInArrowFunctions": true }'
const func = (value: number) => ({ type: 'X', value }) as any;
const func = (value: number) => ({ type: 'X', value }) as Action;
```

@@ -226,4 +230,4 @@

```ts
const func = (value: number) => ({ foo: 'bar', value } as const);
```ts option='{ "allowDirectConstAssertionInArrowFunctions": true }'
const func = (value: number) => ({ foo: 'bar', value }) as const;
const func = () => x as const;

@@ -240,3 +244,3 @@ ```

```ts
```ts option='{ "allowConciseArrowFunctionExpressionsStartingWithVoid": true }'
var join = (a: string, b: string) => `${a}${b}`;

@@ -251,3 +255,3 @@

```ts
```ts option='{ "allowConciseArrowFunctionExpressionsStartingWithVoid": true }'
var log = (message: string) => void console.log(message);

@@ -264,3 +268,3 @@ ```

```ts
```ts option='{ "allowFunctionsWithoutTypeParameters": true }'
function foo<T>(t: T) {

@@ -275,3 +279,3 @@ return t;

```ts
```ts option='{ "allowFunctionsWithoutTypeParameters": true }'
function foo<T>(t: T): T {

@@ -305,9 +309,11 @@ return t;

### `allowIIFE`
### `allowIIFEs`
Examples of code for this rule with `{ allowIIFE: true }`:
Examples of code for this rule with `{ allowIIFEs: true }`:
<!--tabs-->
#### ❌ Incorrect
```ts
```ts option='{ "allowIIFEs": true }'
var func = () => 'foo';

@@ -318,3 +324,3 @@ ```

```ts
```ts option='{ "allowIIFEs": true }'
var foo = (() => 'foo')();

@@ -329,4 +335,3 @@

If you don't wish to prevent calling code from using function return values in unexpected ways, then
you will not need this rule.
If you don't find the added cost of explicitly writing function return types to be worth the visual clarity, or your project is not large enough for it to be a factor in type checking performance, then you will not need this rule.

@@ -333,0 +338,0 @@ ## Further Reading

@@ -68,3 +68,3 @@ ---

```ts
```ts showPlaygroundButton
class Animal {

@@ -92,5 +92,8 @@ constructor(name) {

```ts
```ts option='{ "accessibility": "explicit" }' showPlaygroundButton
class Animal {
public constructor(public breed, name) {
public constructor(
public breed,
name,
) {
// Parameter property and constructor

@@ -116,5 +119,8 @@ this.animalName = name;

```ts
```ts option='{ "accessibility": "no-public" }' showPlaygroundButton
class Animal {
public constructor(public breed, name) {
public constructor(
public breed,
name,
) {
// Parameter property and constructor

@@ -140,5 +146,8 @@ this.animalName = name;

```ts
```ts option='{ "accessibility": "no-public" }' showPlaygroundButton
class Animal {
constructor(protected breed, name) {
constructor(
protected breed,
name,
) {
// Parameter property and constructor

@@ -176,3 +185,3 @@ this.name = name;

```ts
```ts option='{ "overrides": { "constructors": "no-public" } }' showPlaygroundButton
class Animal {

@@ -188,3 +197,3 @@ public constructor(protected animalName) {}

```ts
```ts option='{ "overrides": { "constructors": "no-public" } }' showPlaygroundButton
class Animal {

@@ -204,3 +213,3 @@ constructor(protected animalName) {}

```ts
```ts option='{ "accessibility": "no-public", "overrides": { "properties": "explicit" } }' showPlaygroundButton
class Animal {

@@ -221,3 +230,3 @@ constructor(protected animalName) {}

```ts
```ts option='{ "accessibility": "no-public", "overrides": { "properties": "explicit" } }' showPlaygroundButton
class Animal {

@@ -240,3 +249,3 @@ constructor(protected animalName) {}

```ts
```ts option='{ "accessibility": "off", "overrides": { "parameterProperties": "explicit" } }' showPlaygroundButton
class Animal {

@@ -249,3 +258,3 @@ constructor(readonly animalName: string) {}

```ts
```ts option='{ "accessibility": "off", "overrides": { "parameterProperties": "explicit" } }' showPlaygroundButton
class Animal {

@@ -268,3 +277,3 @@ constructor(public readonly animalName: string) {}

```ts
```ts option='{ "accessibility": "off", "overrides": { "parameterProperties": "no-public" } }' showPlaygroundButton
class Animal {

@@ -277,3 +286,3 @@ constructor(public readonly animalName: string) {}

```ts
```ts option='{ "accessibility": "off", "overrides": { "parameterProperties": "no-public" } }' showPlaygroundButton
class Animal {

@@ -292,3 +301,3 @@ constructor(public animalName: string) {}

```ts
```ts option='{ "overrides": { "accessors" : "off" } }' showPlaygroundButton
class Animal {

@@ -307,3 +316,3 @@ constructor(protected animalName) {}

```ts
```ts option='{ "overrides": { "accessors" : "off" } }' showPlaygroundButton
class Animal {

@@ -325,3 +334,3 @@ public constructor(protected animalName) {}

```ts
```ts option='{ "ignoredMethodNames": ["specificMethod", "whateverMethod"] }' showPlaygroundButton
class Animal {

@@ -342,6 +351,10 @@ get specificMethod() {

If you think defaulting to public is a good default, then you should consider using the `no-public` setting. If you want to mix implicit and explicit public members then disable this rule.
If you think defaulting to public is a good default, then you should consider using the `no-public` setting.
If you want to mix implicit and explicit public members then you can disable this rule.
However, keep in mind that inconsistent style can harm readability in a project.
We recommend picking a single option for this rule that works best for your project.
## Further Reading
- TypeScript [Accessibility Modifiers Handbook Docs](https://www.typescriptlang.org/docs/handbook/2/classes.html#member-visibility)

@@ -105,3 +105,3 @@ ---

```ts
```ts option='{ "allowArgumentsExplicitlyTypedAsAny": false }'
export const func = (value: any): number => value + 1;

@@ -112,3 +112,3 @@ ```

```ts
```ts option='{ "allowArgumentsExplicitlyTypedAsAny": false }'
export const func = (value: number): number => value + 1;

@@ -125,3 +125,3 @@ ```

```ts
```ts option='{ "allowArgumentsExplicitlyTypedAsAny": false }'
export const func = (value: number) => ({ type: 'X', value });

@@ -136,8 +136,8 @@ export const foo = () => ({

```ts
export const func = (value: number) => ({ type: 'X', value } as const);
```ts option='{ "allowArgumentsExplicitlyTypedAsAny": false }'
export const func = (value: number) => ({ type: 'X', value }) as const;
export const foo = () =>
({
bar: true,
} as const);
}) as const;
export const bar = () => 1 as const;

@@ -169,3 +169,3 @@ ```

```ts
```ts option='{ "allowHigherOrderFunctions": false }'
export const arrowFn = () => () => {};

@@ -184,3 +184,3 @@

```ts
```ts option='{ "allowHigherOrderFunctions": false }'
export const arrowFn = () => (): void => {};

@@ -205,3 +205,3 @@

```ts
```ts option='{ "allowTypedFunctionExpressions": false }'
export let arrowFn = () => 'test';

@@ -222,3 +222,3 @@

```ts
```ts option='{ "allowTypedFunctionExpressions": false }'
type FuncType = () => string;

@@ -254,3 +254,3 @@

If you wish to make sure all functions have explicit return types, as opposed to only the module boundaries, you can use [explicit-function-return-type](./explicit-function-return-type.md)
If your project is not used by downstream consumers that are sensitive to API types, you can disable this rule.

@@ -260,1 +260,5 @@ ## Further Reading

- TypeScript [Functions](https://www.typescriptlang.org/docs/handbook/functions.html#function-types)
## Related To
- [explicit-function-return-type](./explicit-function-return-type.md)

@@ -27,5 +27,3 @@ ---

```ts
/*eslint @typescript-eslint/lines-between-class-members: ["error", "always", { "exceptAfterOverload": true }]*/
```ts option='"always", { "exceptAfterOverload": true }' showPlaygroundButton
class foo {

@@ -46,5 +44,3 @@ bar(a: string): void;

```ts
/*eslint @typescript-eslint/lines-between-class-members: ["error", "always", { "exceptAfterOverload": false }]*/
```ts option='"always", { "exceptAfterOverload": false }' showPlaygroundButton
class foo {

@@ -51,0 +47,0 @@ bar(a: string): void;

@@ -161,2 +161,5 @@ ---

If you don't care about enforcing a consistent member delimiter in interfaces and type literals, then you will not need this rule.
If you specifically want to use both member delimiter kinds for stylistic reasons, or don't wish to enforce one style over the other, you can avoid this rule.
However, keep in mind that inconsistent style can harm readability in a project.
We recommend picking a single option for this rule that works best for your project.

@@ -129,2 +129,33 @@ ---

// Accessors
"public-static-accessor",
"protected-static-accessor",
"private-static-accessor",
"#private-static-accessor",
"public-decorated-accessor",
"protected-decorated-accessor",
"private-decorated-accessor",
"public-instance-accessor",
"protected-instance-accessor",
"private-instance-accessor",
"#private-instance-accessor",
"public-abstract-accessor",
"protected-abstract-accessor",
"public-accessor",
"protected-accessor",
"private-accessor",
"#private-accessor",
"static-accessor",
"instance-accessor",
"abstract-accessor",
"decorated-accessor",
"accessor",
// Getters

@@ -260,3 +291,3 @@ "public-static-get",

```ts
```ts option='{ "default": ["signature", "method", "constructor", "field"] }'
interface Foo {

@@ -273,3 +304,3 @@ B: string; // -> field

```ts
```ts option='{ "default": ["signature", "method", "constructor", "field"] }'
type Foo = {

@@ -286,3 +317,3 @@ B: string; // -> field

```ts
```ts option='{ "default": ["signature", "method", "constructor", "field"] }'
class Foo {

@@ -302,3 +333,3 @@ private C: string; // -> field

```ts
```ts option='{ "default": ["signature", "method", "constructor", "field"] }'
const Foo = class {

@@ -321,3 +352,3 @@ private C: string; // -> field

```ts
```ts option='{ "default": ["signature", "method", "constructor", "field"] }'
interface Foo {

@@ -334,3 +365,3 @@ [Z: string]: any; // -> signature

```ts
```ts option='{ "default": ["signature", "method", "constructor", "field"] }'
type Foo = {

@@ -347,3 +378,3 @@ // no signature

```ts
```ts option='{ "default": ["signature", "method", "constructor", "field"] }'
class Foo {

@@ -363,3 +394,3 @@ [Z: string]: any; // -> signature

```ts
```ts option='{ "default": ["signature", "method", "constructor", "field"] }'
const Foo = class {

@@ -403,3 +434,3 @@ [Z: string]: any; // -> signature

```ts
```ts option='{ "default": ["public-instance-method", "public-static-field"] }'
class Foo {

@@ -422,3 +453,3 @@ private C: string; // (irrelevant)

```ts
```ts option='{ "default": ["public-instance-method", "public-static-field"] }'
const Foo = class {

@@ -443,3 +474,3 @@ private C: string; // (irrelevant)

```ts
```ts option='{ "default": ["public-instance-method", "public-static-field"] }'
class Foo {

@@ -462,3 +493,3 @@ public B(): void {} // -> public instance method

```ts
```ts option='{ "default": ["public-instance-method", "public-static-field"] }'
const Foo = class {

@@ -501,3 +532,3 @@ public B(): void {} // -> public instance method

```ts
```ts option='{ "default": ["public-static-field", "static-field", "instance-field"] }'
class Foo {

@@ -516,3 +547,3 @@ private E: string; // -> instance field

```ts
```ts option='{ "default": ["public-static-field", "static-field", "instance-field"] }'
const foo = class {

@@ -538,3 +569,3 @@ public T(): void {} // method (irrelevant)

```ts
```ts option='{ "default": ["public-static-field", "static-field", "instance-field"] }'
class Foo {

@@ -553,3 +584,3 @@ public static A: string; // -> public static field

```ts
```ts option='{ "default": ["public-static-field", "static-field", "instance-field"] }'
const foo = class {

@@ -594,3 +625,3 @@ [Z: string]: any; // -> signature (irrelevant)

```ts
```ts option='{ "classes": ["method", "constructor", "field"] }'
class Foo {

@@ -610,3 +641,3 @@ private C: string; // -> field

```ts
```ts option='{ "classes": ["method", "constructor", "field"] }'
class Foo {

@@ -646,3 +677,3 @@ public static A(): void {} // -> method

```ts
```ts option='{ "classExpressions": ["method", "constructor", "field"] }'
const foo = class {

@@ -662,3 +693,3 @@ private C: string; // -> field

```ts
```ts option='{ "classExpressions": ["method", "constructor", "field"] }'
const foo = class {

@@ -702,3 +733,3 @@ public static A(): void {} // -> method

```ts
```ts option='{ "interfaces": ["signature", "method", "constructor", "field"] }'
interface Foo {

@@ -717,3 +748,3 @@ B: string; // -> field

```ts
```ts option='{ "interfaces": ["signature", "method", "constructor", "field"] }'
interface Foo {

@@ -756,3 +787,3 @@ [Z: string]: any; // -> signature

```ts
```ts option='{ "typeLiterals": ["signature", "method", "constructor", "field"] }'
type Foo = {

@@ -771,3 +802,3 @@ B: string; // -> field

```ts
```ts option='{ "typeLiterals": ["signature", "method", "constructor", "field"] }'
type Foo = {

@@ -814,3 +845,3 @@ [Z: string]: any; // -> signature

```ts
```ts option='{"default":{"memberTypes":["signature","call-signature","public-static-field","protected-static-field","private-static-field","#private-static-field","public-decorated-field","protected-decorated-field","private-decorated-field","public-instance-field","protected-instance-field","private-instance-field","#private-instance-field","public-abstract-field","protected-abstract-field","public-field","protected-field","private-field","#private-field","static-field","instance-field","abstract-field","decorated-field","field","static-initialization","public-constructor","protected-constructor","private-constructor","constructor","public-static-get","protected-static-get","private-static-get","#private-static-get","public-decorated-get","protected-decorated-get","private-decorated-get","public-instance-get","protected-instance-get","private-instance-get","#private-instance-get","public-abstract-get","protected-abstract-get","public-get","protected-get","private-get","#private-get","static-get","instance-get","abstract-get","decorated-get","get","public-static-set","protected-static-set","private-static-set","#private-static-set","public-decorated-set","protected-decorated-set","private-decorated-set","public-instance-set","protected-instance-set","private-instance-set","#private-instance-set","public-abstract-set","protected-abstract-set","public-set","protected-set","private-set","#private-set","static-set","instance-set","abstract-set","decorated-set","set","public-static-method","protected-static-method","private-static-method","#private-static-method","public-decorated-method","protected-decorated-method","private-decorated-method","public-instance-method","protected-instance-method","private-instance-method","#private-instance-method","public-abstract-method","protected-abstract-method","public-method","protected-method","private-method","#private-method","static-method","instance-method","abstract-method","decorated-method","method"],"order":"alphabetically"}}'
interface Foo {

@@ -829,3 +860,3 @@ a: x;

```ts
```ts option='{"default":{"memberTypes":["signature","call-signature","public-static-field","protected-static-field","private-static-field","#private-static-field","public-decorated-field","protected-decorated-field","private-decorated-field","public-instance-field","protected-instance-field","private-instance-field","#private-instance-field","public-abstract-field","protected-abstract-field","public-field","protected-field","private-field","#private-field","static-field","instance-field","abstract-field","decorated-field","field","static-initialization","public-constructor","protected-constructor","private-constructor","constructor","public-static-get","protected-static-get","private-static-get","#private-static-get","public-decorated-get","protected-decorated-get","private-decorated-get","public-instance-get","protected-instance-get","private-instance-get","#private-instance-get","public-abstract-get","protected-abstract-get","public-get","protected-get","private-get","#private-get","static-get","instance-get","abstract-get","decorated-get","get","public-static-set","protected-static-set","private-static-set","#private-static-set","public-decorated-set","protected-decorated-set","private-decorated-set","public-instance-set","protected-instance-set","private-instance-set","#private-instance-set","public-abstract-set","protected-abstract-set","public-set","protected-set","private-set","#private-set","static-set","instance-set","abstract-set","decorated-set","set","public-static-method","protected-static-method","private-static-method","#private-static-method","public-decorated-method","protected-decorated-method","private-decorated-method","public-instance-method","protected-instance-method","private-instance-method","#private-instance-method","public-abstract-method","protected-abstract-method","public-method","protected-method","private-method","#private-method","static-method","instance-method","abstract-method","decorated-method","method"],"order":"alphabetically"}}'
interface Foo {

@@ -844,3 +875,3 @@ B: x;

This config specifies that within each `memberTypes` group, members are in an alphabetic case-sensitive order.
This config specifies that within each `memberTypes` group, members are in an alphabetic case-insensitive order.
You can copy and paste the default order from [Default Configuration](#default-configuration).

@@ -871,3 +902,3 @@

```ts
```ts option='{"default":{"memberTypes":["signature","call-signature","public-static-field","protected-static-field","private-static-field","#private-static-field","public-decorated-field","protected-decorated-field","private-decorated-field","public-instance-field","protected-instance-field","private-instance-field","#private-instance-field","public-abstract-field","protected-abstract-field","public-field","protected-field","private-field","#private-field","static-field","instance-field","abstract-field","decorated-field","field","static-initialization","public-constructor","protected-constructor","private-constructor","constructor","public-static-get","protected-static-get","private-static-get","#private-static-get","public-decorated-get","protected-decorated-get","private-decorated-get","public-instance-get","protected-instance-get","private-instance-get","#private-instance-get","public-abstract-get","protected-abstract-get","public-get","protected-get","private-get","#private-get","static-get","instance-get","abstract-get","decorated-get","get","public-static-set","protected-static-set","private-static-set","#private-static-set","public-decorated-set","protected-decorated-set","private-decorated-set","public-instance-set","protected-instance-set","private-instance-set","#private-instance-set","public-abstract-set","protected-abstract-set","public-set","protected-set","private-set","#private-set","static-set","instance-set","abstract-set","decorated-set","set","public-static-method","protected-static-method","private-static-method","#private-static-method","public-decorated-method","protected-decorated-method","private-decorated-method","public-instance-method","protected-instance-method","private-instance-method","#private-instance-method","public-abstract-method","protected-abstract-method","public-method","protected-method","private-method","#private-method","static-method","instance-method","abstract-method","decorated-method","method"],"order":"alphabetically-case-insensitive"}}'
interface Foo {

@@ -886,3 +917,3 @@ B: x;

```ts
```ts option='{"default":{"memberTypes":["signature","call-signature","public-static-field","protected-static-field","private-static-field","#private-static-field","public-decorated-field","protected-decorated-field","private-decorated-field","public-instance-field","protected-instance-field","private-instance-field","#private-instance-field","public-abstract-field","protected-abstract-field","public-field","protected-field","private-field","#private-field","static-field","instance-field","abstract-field","decorated-field","field","static-initialization","public-constructor","protected-constructor","private-constructor","constructor","public-static-get","protected-static-get","private-static-get","#private-static-get","public-decorated-get","protected-decorated-get","private-decorated-get","public-instance-get","protected-instance-get","private-instance-get","#private-instance-get","public-abstract-get","protected-abstract-get","public-get","protected-get","private-get","#private-get","static-get","instance-get","abstract-get","decorated-get","get","public-static-set","protected-static-set","private-static-set","#private-static-set","public-decorated-set","protected-decorated-set","private-decorated-set","public-instance-set","protected-instance-set","private-instance-set","#private-instance-set","public-abstract-set","protected-abstract-set","public-set","protected-set","private-set","#private-set","static-set","instance-set","abstract-set","decorated-set","set","public-static-method","protected-static-method","private-static-method","#private-static-method","public-decorated-method","protected-decorated-method","private-decorated-method","public-instance-method","protected-instance-method","private-instance-method","#private-instance-method","public-abstract-method","protected-abstract-method","public-method","protected-method","private-method","#private-method","static-method","instance-method","abstract-method","decorated-method","method"],"order":"alphabetically-case-insensitive"}}'
interface Foo {

@@ -920,3 +951,3 @@ a: x;

```ts
```ts option='{ "default": { "memberTypes": "never", "order": "alphabetically" } }'
interface Foo {

@@ -935,3 +966,3 @@ static c = 0;

```ts
```ts option='{ "default": { "memberTypes": "never", "order": "alphabetically" } }'
interface Foo {

@@ -975,3 +1006,3 @@ a: boolean;

```ts
```ts option='{ "default": { "optionalityOrder": "optional-first", "order": "alphabetically" } }'
interface Foo {

@@ -986,3 +1017,3 @@ a: boolean;

```ts
```ts option='{ "default": { "optionalityOrder": "optional-first", "order": "alphabetically" } }'
interface Foo {

@@ -1020,3 +1051,3 @@ b?: number;

```ts
```ts option='{ "default": { "optionalityOrder": "required-first", "order": "alphabetically" } }'
interface Foo {

@@ -1031,3 +1062,3 @@ a: boolean;

```ts
```ts option='{ "default": { "optionalityOrder": "required-first", "order": "alphabetically" } }'
interface Foo {

@@ -1034,0 +1065,0 @@ a: boolean;

@@ -49,3 +49,3 @@ ---

```ts
```ts option='"property"'
interface T1 {

@@ -66,3 +66,3 @@ func(arg: string): number;

```ts
```ts option='"property"'
interface T1 {

@@ -90,3 +90,3 @@ func: (arg: string) => number;

```ts
```ts option='"method"'
interface T1 {

@@ -102,3 +102,3 @@ func: (arg: string) => number;

```ts
```ts option='"method"'
interface T1 {

@@ -115,1 +115,4 @@ func(arg: string): number;

If you don't want to enforce a particular style for object/interface function types, and/or if you don't use `strictFunctionTypes`, then you don't need this rule.
However, keep in mind that inconsistent style can harm readability in a project.
We recommend picking a single option for this rule that works best for your project.

@@ -84,2 +84,7 @@ ---

{
selector: 'import',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'variable',

@@ -220,2 +225,5 @@ format: ['camelCase', 'UPPER_CASE'],

- Allowed `types`: none.
- `import` - matches namespace imports and default imports (i.e. does not match named imports).
- Allowed `modifiers`: `default`, `namespace`.
- Allowed `types`: none.
- `interface` - matches any interface declaration.

@@ -708,2 +716,9 @@ - Allowed `modifiers`: `exported`, `unused`.

If you do not want to enforce naming conventions for anything.
This rule can be very strict.
If you don't have strong needs for enforcing naming conventions, we recommend using it only to flag very egregious violations of your naming standards.
Consider documenting your naming conventions and enforcing them in code review if you have processes like that.
If you do not want to enforce naming conventions for anything, you can disable this rule.
However, keep in mind that inconsistent style can harm readability in a project.
We recommend that if you care about naming conventions, pick a single option for this rule that works best for your project.

@@ -17,4 +17,2 @@ ---

```ts
/*eslint no-array-constructor: "error"*/
Array(0, 1, 2);

@@ -27,4 +25,2 @@ new Array(0, 1, 2);

```ts
/*eslint no-array-constructor: "error"*/
Array<number>(0, 1, 2);

@@ -31,0 +27,0 @@ new Array<Foo>(x, y, z);

@@ -68,3 +68,3 @@ ---

```ts
```ts option='{ "ignoredTypeNames": ["RegExp"] }' showPlaygroundButton
`${/regex/}`;

@@ -80,3 +80,3 @@ '' + /regex/;

If you don't mind `"[object Object]"` in your strings, then you will not need this rule.
If you don't mind a risk of `"[object Object]"` or incorrect type coercions in your values, then you will not need this rule.

@@ -83,0 +83,0 @@ ## Related To

@@ -79,3 +79,3 @@ ---

```ts
```ts option='{ "ignoreArrowShorthand": true }' showPlaygroundButton
promise.then(value => window.postMessage(value));

@@ -96,3 +96,3 @@ ```

```ts
```ts option='{ "ignoreVoidOperator": true }' showPlaygroundButton
// now it's obvious that we don't expect any response

@@ -118,2 +118,2 @@ promise.then(value => void window.postMessage(value));

If you don't care about being explicit about the void type in actual code then don't use this rule.
Also, if you prefer concise coding style then also don't use it.
Also, if you strongly prefer a concise coding style more strongly than any fear of `void`-related bugs then you can avoid this rule.

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

import TypeScriptOverlap from "@site/src/components/TypeScriptOverlap";
<TypeScriptOverlap />
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.

@@ -51,1 +51,9 @@ ---

```
## When Not To Use It
It can sometimes be useful to include duplicate enum members for very specific use cases.
For example, when renaming an enum member, it can sometimes be useful to keep the old name until a scheduled major breaking change.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
In general, if your project intentionally duplicates enum member values, you can avoid this rule.

@@ -8,4 +8,7 @@ :::danger Deprecated

<!--
This doc file has been left on purpose because `import/no-duplicates` is commonly requested.
This exists to help direct people to the replacement rule.
This doc file has been left on purpose because `import/no-duplicates` is
commonly requested. This exists to help direct people to the replacement rule.
Note that there is no actual way to get to this page in the normal navigation,
so end-users will only be able to get to this page from the search bar.
-->

@@ -60,1 +60,8 @@ ---

When set to true, duplicate checks on union type constituents are ignored.
## When Not To Use It
It can sometimes be useful for the sake of documentation to include aliases for the same type.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
> In some of those cases, [branded types](https://basarat.gitbook.io/typescript/main-1/nominaltyping#using-interfaces) might be a type-safe way to represent the underlying data types.

@@ -50,5 +50,5 @@ ---

When you know your keys are safe to delete, this rule can be unnecessary.
Some environments such as older browsers might not support `Map` and `Set`.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
Do not consider this rule as performance advice before profiling your code's bottlenecks.
Even repeated minor performance slowdowns likely do not significantly affect your application's general perceived speed.

@@ -42,3 +42,3 @@ ---

```ts
```ts option='{ "allow": ["private-constructors"] }' showPlaygroundButton
class Foo {

@@ -53,3 +53,3 @@ private constructor() {}

```ts
```ts option='{ "allow": ["protected-constructors"] }' showPlaygroundButton
class Foo {

@@ -64,3 +64,3 @@ protected constructor() {}

```ts
```ts option='{ "allow": ["decoratedFunctions"] }' showPlaygroundButton
@decorator()

@@ -79,3 +79,3 @@ function foo() {}

```ts
```ts option='{ "allow": ["overrideMethods"] }' showPlaygroundButton
abstract class Base {

@@ -91,1 +91,10 @@ protected greet(): void {

```
## When Not To Use It
If you are working with external APIs that require functions even if they do nothing, then you may want to avoid this rule.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
Test code often violates this rule as well.
If your testing setup doesn't support "mock" or "spy" functions such as [`jest.fn()`](https://jestjs.io/docs/mock-functions), [`sinon.spy()`](https://sinonjs.org/releases/latest/spies), or [`vi.fn()`](https://vitest.dev/guide/mocking.html), you may wish to disable this rule in test files.
Again, if those cases aren't extremely common, you might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule in test files.

@@ -101,7 +101,5 @@ ---

Examples of **incorrect** code for the `{ "ignoreRestArgs": false }` option:
The examples below are **incorrect** when `{ignoreRestArgs: false}`, but **correct** when `{ignoreRestArgs: true}`.
```ts
/*eslint @typescript-eslint/no-explicit-any: ["error", { "ignoreRestArgs": false }]*/
```ts option='{ "ignoreRestArgs": false }' showPlaygroundButton
function foo1(...args: any[]): void {}

@@ -131,36 +129,17 @@ function foo2(...args: readonly any[]): void {}

Examples of **correct** code for the `{ "ignoreRestArgs": true }` option:
## When Not To Use It
```ts
/*eslint @typescript-eslint/no-explicit-any: ["error", { "ignoreRestArgs": true }]*/
`any` is always a dangerous escape hatch.
Whenever possible, it is always safer to avoid it.
TypeScript's `unknown` is almost always preferable to `any`.
function foo1(...args: any[]): void {}
function foo2(...args: readonly any[]): void {}
function foo3(...args: Array<any>): void {}
function foo4(...args: ReadonlyArray<any>): void {}
However, there are occasional situations where it can be necessary to use `any`.
Most commonly:
declare function bar(...args: any[]): void;
- If your project isn't fully onboarded to TypeScript yet, `any` can be temporarily used in places where types aren't yet known or representable
- If an external package doesn't yet have typings and you want to use `any` pending adding a `.d.ts` for it
- You're working with particularly complex or nuanced code that can't yet be represented in the TypeScript type system
const baz = (...args: any[]) => {};
const qux = function (...args: any[]) {};
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
type Quux = (...args: any[]) => void;
type Quuz = new (...args: any[]) => void;
interface Grault {
(...args: any[]): void;
}
interface Corge {
new (...args: any[]): void;
}
interface Garply {
f(...args: any[]): void;
}
```
## When Not To Use It
If an unknown type or a library without typings is used
and you want to be able to specify `any`.
## Related To

@@ -176,2 +155,5 @@

- TypeScript [any type](https://www.typescriptlang.org/docs/handbook/basic-types.html#any)
- TypeScript [`any` type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)
- TypeScript's [`unknown` type](https://www.typescriptlang.org/docs/handbook/2/functions.html#unknown)
- TypeScript [`any` type documentation](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)
- TypeScript [`unknown` type release notes](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html#new-unknown-top-type)

@@ -53,1 +53,3 @@ ---

```
<!-- Intentionally Omitted: When Not To Use It -->

@@ -11,1 +11,3 @@ ---

It adds support for class properties.
Note that this rule is classified as a "Suggestion" rule instead of a "Layout & Formatting" rule because [adding extra semi-colons actually changes the AST of the program](https://typescript-eslint.io/play/#ts=5.1.6&showAST=es&fileType=.ts&code=MYewdgzgLgBAHjAvDAjAbg0A&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQHYHsBaRADwBdoBDQ5RAWwEt0p8AzVyAGnG0gAEyATwAOKAMbQGwssWTwGuMgHoCxclRr0mGSImjR80SDwC%2BIE0A&tsconfig=&tokens=false). With that said, modern TypeScript formatters will remove extra semi-colons automatically during the formatting process. Thus, if you [use a formatter](/linting/troubleshooting/formatting), then enabling this rule is probably unnecessary.

@@ -208,3 +208,3 @@ ---

```ts
```ts option='{ "allowConstructorOnly": true }'
class NoFields {}

@@ -215,3 +215,3 @@ ```

```ts
```ts option='{ "allowConstructorOnly": true }'
class NoFields {

@@ -232,3 +232,3 @@ constructor() {

```ts
```ts option='{ "allowEmpty": true }'
class NoFields {

@@ -243,3 +243,3 @@ constructor() {

```ts
```ts option='{ "allowEmpty": true }'
class NoFields {}

@@ -261,3 +261,3 @@ ```

```ts
```ts option='{ "allowStaticOnly": true }'
class EmptyClass {}

@@ -268,3 +268,3 @@ ```

```ts
```ts option='{ "allowStaticOnly": true }'
class NotEmptyClass {

@@ -283,3 +283,3 @@ static version = 42;

```ts
```ts option='{ "allowWithDecorator": true }'
class Constants {

@@ -292,3 +292,3 @@ static readonly version = 42;

```ts
```ts option='{ "allowWithDecorator": true }'
class Constants {

@@ -302,2 +302,3 @@ @logOnRead()

You can disable this rule if you are unable -or unwilling- to switch off using classes as namespaces.
If your project was set up before modern class and namespace practices, and you don't have the time to switch over, you might not be practically able to use this rule.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -73,3 +73,3 @@ ---

```ts
```ts option='{ "ignoreVoid": true }' showPlaygroundButton
async function returnsPromise() {

@@ -91,3 +91,3 @@ return 'value';

```ts
```ts option='{ "ignoreIIFE": true }' showPlaygroundButton
await(async function () {

@@ -104,3 +104,5 @@ await res(1);

If you do not use Promise-like values in your codebase, or want to allow them to remain unhandled.
This rule can be difficult to enable on large existing projects that set up many floating Promises.
Alternately, if you're not worried about crashes from floating or misused Promises -such as if you have global unhandled Promise handlers registered- then in some cases it may be safe to not use this rule.
You might consider using `void`s and/or [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -107,0 +109,0 @@ ## Related To

@@ -56,2 +56,3 @@ ---

If you want to iterate through a loop using the indices in an array as strings, you can turn off this rule.
If your project is a rare one that intentionally loops over string indices of arrays, you can turn off this rule.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -101,2 +101,3 @@ ---

If you want to allow `new Function()` or `setTimeout()`, `setInterval()`, `setImmediate()` and `execScript()` with string arguments, then you can safely disable this rule.
If your project is a rare one that needs to allow `new Function()` or `setTimeout()`, `setInterval()`, `setImmediate()` and `execScript()` with string arguments, then you can disable this rule.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -68,4 +68,3 @@ ---

- If you want to leave behind side effect imports, then you shouldn't use this rule.
- If you're not using TypeScript 5.0's `verbatimModuleSyntax` option, then you don't need this rule.
If you're not using TypeScript 5.0's `verbatimModuleSyntax` option and your project is built with a bundler that manages import side effects for you, this rule may not be as useful for you.

@@ -72,0 +71,0 @@ ## Related To

@@ -81,3 +81,3 @@ ---

```ts
```ts option='{ "ignoreParameters": true }' showPlaygroundButton
function foo(a: number = 5, b: boolean = true) {

@@ -92,3 +92,3 @@ // ...

```ts
```ts option='{ "ignoreProperties": true }' showPlaygroundButton
class Foo {

@@ -101,6 +101,6 @@ prop: number = 5;

If you do not want to enforce inferred types.
If you strongly prefer to have explicit types regardless of whether they can be inferred, this rule may not be for you.
## Further Reading
TypeScript [Inference](https://www.typescriptlang.org/docs/handbook/type-inference.html)
- [TpeScript Inference](https://www.typescriptlang.org/docs/handbook/type-inference.html)

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

import TypeScriptOverlap from "@site/src/components/TypeScriptOverlap";
<TypeScriptOverlap strict />
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.

@@ -69,3 +69,3 @@ ---

```ts
```ts option='{ "allowInGenericTypeArguments": false }' showPlaygroundButton
logAndReturn<void>(undefined);

@@ -79,3 +79,3 @@

```ts
```ts option='{ "allowInGenericTypeArguments": ["Ex.Mx.Tx"] }' showPlaygroundButton
logAndReturn<void>(undefined);

@@ -90,3 +90,3 @@

```ts
```ts option='{ "allowInGenericTypeArguments": ["Ex.Mx.Tx"] }' showPlaygroundButton
type AllowedVoid = Ex.Mx.Tx<void>;

@@ -105,3 +105,3 @@ type AllowedVoidUnion = void | Ex.Mx.Tx<void>;

```ts
```ts option='{ "allowAsThisParameter": false }' showPlaygroundButton
function doThing(this: void) {}

@@ -116,3 +116,2 @@ class Example {

If you don't care about if `void` is used with other types,
or in invalid places, then you don't need this rule.
If you don't care about if `void` is used with other types, or in invalid places, then you don't need this rule.

@@ -43,5 +43,3 @@ ---

```ts
/*eslint @typescript-eslint/no-magic-numbers: ["error", { "ignoreEnums": false }]*/
```ts option='{ "ignoreEnums": false }' showPlaygroundButton
enum foo {

@@ -54,5 +52,3 @@ SECOND = 1000,

```ts
/*eslint @typescript-eslint/no-magic-numbers: ["error", { "ignoreEnums": true }]*/
```ts option='{ "ignoreEnums": true }' showPlaygroundButton
enum foo {

@@ -69,5 +65,3 @@ SECOND = 1000,

```ts
/*eslint @typescript-eslint/no-magic-numbers: ["error", { "ignoreNumericLiteralTypes": false }]*/
```ts option='{ "ignoreNumericLiteralTypes": false }' showPlaygroundButton
type SmallPrimes = 2 | 3 | 5 | 7 | 11;

@@ -78,5 +72,3 @@ ```

```ts
/*eslint @typescript-eslint/no-magic-numbers: ["error", { "ignoreNumericLiteralTypes": true }]*/
```ts option='{ "ignoreNumericLiteralTypes": true }' showPlaygroundButton
type SmallPrimes = 2 | 3 | 5 | 7 | 11;

@@ -89,5 +81,3 @@ ```

```ts
/*eslint @typescript-eslint/no-magic-numbers: ["error", { "ignoreReadonlyClassProperties": false }]*/
```ts option='{ "ignoreReadonlyClassProperties": false }' showPlaygroundButton
class Foo {

@@ -103,5 +93,3 @@ readonly A = 1;

```ts
/*eslint @typescript-eslint/no-magic-numbers: ["error", { "ignoreReadonlyClassProperties": true }]*/
```ts option='{ "ignoreReadonlyClassProperties": true }' showPlaygroundButton
class Foo {

@@ -121,5 +109,3 @@ readonly A = 1;

```ts
/*eslint @typescript-eslint/no-magic-numbers: ["error", { "ignoreTypeIndexes": false }]*/
```ts option='{ "ignoreTypeIndexes": false }' showPlaygroundButton
type Foo = Bar[0];

@@ -131,7 +117,11 @@ type Baz = Parameters<Foo>[2];

```ts
/*eslint @typescript-eslint/no-magic-numbers: ["error", { "ignoreTypeIndexes": true }]*/
```ts option='{ "ignoreTypeIndexes": true }' showPlaygroundButton
type Foo = Bar[0];
type Baz = Parameters<Foo>[2];
```
## When Not To Use It
If your project frequently deals with constant numbers and you don't wish to take up extra space to declare them, this rule might not be for you.
We recommend at least using descriptive comments and/or names to describe constants.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) instead of completely disabling this rule.

@@ -48,1 +48,5 @@ ---

`checkNever: true` will suggest removing `void` when the argument has type `never`.
## When Not To Use It
If you don't mind extra `void`s in your project, you can avoid this rule.

@@ -46,2 +46,3 @@ ---

If you intentionally want a class with a `new` method, and you're confident nobody working in your code will mistake it with a constructor.
If you intentionally want a class with a `new` method, and you're confident nobody working in your code will mistake it with a constructor, you might not want this rule.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -43,3 +43,3 @@ ---

```ts
```ts option='{ "checksConditionals": true }'
const promise = Promise.resolve('value');

@@ -60,3 +60,3 @@

```ts
```ts option='{ "checksConditionals": true }'
const promise = Promise.resolve('value');

@@ -80,4 +80,4 @@

Likewise, if you don't want functions that return promises where a void return is
expected to be checked, your configuration will look like this:
Likewise, if you don't want to check functions that return promises where a void return is
expected, your configuration will look like this:

@@ -126,3 +126,3 @@ ```json

```ts
```ts option='{ "checksVoidReturn": true }'
[1, 2, 3].forEach(async value => {

@@ -147,3 +147,3 @@ await doSomething(value);

```ts
```ts option='{ "checksVoidReturn": true }'
// for-of puts `await` in outer context

@@ -211,3 +211,3 @@ for (const value of [1, 2, 3]) {

```ts
```ts option='{ "checksSpreads": true }'
const getData = () => someAsyncOperation({ myArg: 'foo' });

@@ -226,3 +226,3 @@

```ts
```ts option='{ "checksSpreads": true }'
const getData = () => someAsyncOperation({ myArg: 'foo' });

@@ -243,4 +243,5 @@

If you do not use Promises in your codebase or are not concerned with possible
misuses of them outside of what the TypeScript compiler will check.
This rule can be difficult to enable on large existing projects that set up many misused Promises.
Alternately, if you're not worried about crashes from floating or misused Promises -such as if you have global unhandled Promise handlers registered- then in some cases it may be safe to not use this rule.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -247,0 +248,0 @@ ## Further Reading

@@ -51,3 +51,3 @@ ---

```ts
```ts option='{ "allowDeclarations": true }'
module foo {}

@@ -59,3 +59,3 @@ namespace foo {}

```ts
```ts option='{ "allowDeclarations": true }'
declare module 'foo' {}

@@ -82,3 +82,3 @@ declare module foo {}

```ts
```ts option='{ "allowDeclarations": false }'
module foo {}

@@ -92,3 +92,3 @@ namespace foo {}

```ts
```ts option='{ "allowDeclarations": false }'
declare module 'foo' {}

@@ -105,3 +105,3 @@ ```

```ts
```ts option='{ "allowDefinitionFiles": true }'
// if outside a d.ts file

@@ -120,3 +120,3 @@ module foo {}

```ts
```ts option='{ "allowDefinitionFiles": true }'
declare module 'foo' {}

@@ -129,3 +129,5 @@

If you are using the ES2015 module syntax, then you will not need this rule.
If your project was architected before modern modules and namespaces, it may be difficult to migrate off of namespaces.
In that case you may not be able to use this rule for parts of your project.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -132,0 +134,0 @@ ## Further Reading

@@ -46,2 +46,7 @@ ---

## When Not To Use It
If your project's types don't yet fully describe whether certain values may be nullable, such as if you're transitioning to `strictNullChecks`, this rule might create many false reports.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
## Further Reading

@@ -48,0 +53,0 @@

@@ -32,2 +32,7 @@ ---

## When Not To Use It
If your project's types don't yet fully describe whether certain values may be nullable, such as if you're transitioning to `strictNullChecks`, this rule might create many false reports.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
## Further Reading

@@ -34,0 +39,0 @@

@@ -41,3 +41,3 @@ ---

If your project does not use the `strictNullChecks` compiler option, this rule is likely useless to you.
If your code is often wildly incorrect with respect to strict null-checking, your code may not yet be ready for this rule.
If your project's types don't yet fully describe whether certain values may be nullable, such as if you're transitioning to `strictNullChecks`, this rule might create many false reports.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

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

import TypeScriptOverlap from "@site/src/components/TypeScriptOverlap";
<TypeScriptOverlap />
This rule extends the base [`eslint/no-redeclare`](https://eslint.org/docs/rules/no-redeclare) rule.

@@ -42,3 +46,3 @@ It adds support for TypeScript function overloads, and declaration merging.

```ts
```ts option='{ "ignoreDeclarationMerge": true }' showPlaygroundButton
interface A {

@@ -69,3 +73,3 @@ prop1: 1;

```ts
```ts option='{ "ignoreDeclarationMerge": true }' showPlaygroundButton
type something = string;

@@ -72,0 +76,0 @@ // eslint-disable-next-line @typescript-eslint/no-redeclare -- intentionally naming the variable the same as the type

@@ -73,2 +73,16 @@ ---

## When Not To Use It
Some projects choose to occasionally intentionally include a redundant type constituent for documentation purposes.
For example, the following code includes `string` in a union even though the `unknown` makes it redundant:
```ts
/**
* Normally a string name, but sometimes arbitrary unknown data.
*/
type NameOrOther = string | unknown;
```
If you strongly feel a preference for these unnecessary type constituents, this rule might not be for you.
## Further Reading

@@ -75,0 +89,0 @@

@@ -33,3 +33,4 @@ ---

If you don't care about using newer module syntax, then you will not need this rule.
If your project frequently uses older CommonJS `require`s, then this rule might not be applicable to you.
If only a subset of your project uses `require`s then you might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -36,0 +37,0 @@ ## Related To

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

This rule extends the base [`eslint/no-restricted-imports`](https://eslint.org/docs/rules/no-restricted-imports) rule.
This rule extends the base [`eslint/no-restricted-imports`](https://eslint.org/docs/rules/no-restricted-imports) rule. It adds support for the type import (`import type X from "..."`, `import { type X } from "..."`) and `import x = require("...")` syntaxes.

@@ -23,13 +23,23 @@ ## Options

```jsonc
"@typescript-eslint/no-restricted-imports": ["error", {
"paths": [{
"name": "import-foo",
"message": "Please use import-bar instead.",
"allowTypeImports": true
}, {
"name": "import-baz",
"message": "Please use import-quux instead.",
"allowTypeImports": true
}]
}]
{
"rules": {
"@typescript-eslint/no-restricted-imports": [
"error",
{
"paths": [
{
"name": "import-foo",
"message": "Please use import-bar instead.",
"allowTypeImports": true
},
{
"name": "import-baz",
"message": "Please use import-quux instead.",
"allowTypeImports": true
}
]
}
]
}
}
```

@@ -45,3 +55,3 @@

```ts
```ts option='{"paths":[{"name":"import-foo","message":"Please use import-bar instead.","allowTypeImports":true},{"name":"import-baz","message":"Please use import-quux instead.","allowTypeImports":true}]}'
import foo from 'import-foo';

@@ -56,3 +66,3 @@ export { Foo } from 'import-foo';

```ts
```ts option='{"paths":[{"name":"import-foo","message":"Please use import-bar instead.","allowTypeImports":true},{"name":"import-baz","message":"Please use import-quux instead.","allowTypeImports":true}]}'
import { foo } from 'other-module';

@@ -59,0 +69,0 @@

@@ -37,3 +37,3 @@ ---

```ts
```ts option='{ "ignoreTypeValueShadow": true }' showPlaygroundButton
type Foo = number;

@@ -76,3 +76,3 @@ const Foo = 1;

```ts
```ts option='{ "ignoreFunctionTypeParameterNameValueShadow": true }' showPlaygroundButton
const test = 1;

@@ -79,0 +79,0 @@ type Func = (test: string) => typeof test;

@@ -38,2 +38,3 @@ ---

If you need to assign `this` to variables, you shouldn’t use this rule.
If your project is structured in a way that it needs to assign `this` to variables, this rule is likely not for you.
If only a subset of your project assigns `this` to variables then you might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -23,4 +23,2 @@ ---

```ts
/*eslint @typescript-eslint/no-throw-literal: "error"*/
throw 'error';

@@ -57,15 +55,13 @@

```ts
/*eslint @typescript-eslint/no-throw-literal: "error"*/
throw new Error();
throw new Error("error");
throw new Error('error');
const e = new Error("error");
const e = new Error('error');
throw e;
try {
throw new Error("error");
throw new Error('error');
} catch (e) {
throw e;
throw e;
}

@@ -82,4 +78,4 @@

const foo = {
bar: new Error();
}
bar: new Error(),
};
throw foo.bar;

@@ -89,3 +85,3 @@

// ...
};
}
throw new CustomError();

@@ -116,1 +112,3 @@ ```

```
<!-- Intentionally omitted: When Not To Use It -->

@@ -115,3 +115,3 @@ ---

```ts
```ts option='{ "allowAliases": "always" }' showPlaygroundButton
// primitives

@@ -143,3 +143,3 @@ type Foo = 'a';

```ts
```ts option='{ "allowAliases": "in-unions" }' showPlaygroundButton
// primitives

@@ -165,3 +165,3 @@ type Foo = 'a';

```ts
```ts option='{ "allowAliases": "in-unions" }' showPlaygroundButton
// primitives

@@ -183,3 +183,3 @@ type Foo = 'a' | 'b';

```ts
```ts option='{ "allowAliases": "in-intersections" }' showPlaygroundButton
// primitives

@@ -207,3 +207,3 @@ type Foo = 'a';

```ts
```ts option='{ "allowAliases": "in-intersections" }' showPlaygroundButton
// primitives

@@ -223,3 +223,3 @@ type Foo = string & string[];

```ts
```ts option='{ "allowAliases": "in-unions-and-intersections" }' showPlaygroundButton
// primitives

@@ -241,3 +241,3 @@ type Foo = 'a';

```ts
```ts option='{ "allowAliases": "in-unions-and-intersections" }' showPlaygroundButton
// primitives

@@ -273,3 +273,3 @@ type Foo = 'a' | 'b';

```ts
```ts option='{ "allowCallbacks": "always" }' showPlaygroundButton
type Foo = () => void;

@@ -292,3 +292,3 @@

```ts
```ts option='{ "allowConditionalTypes": "always" }' showPlaygroundButton
type Foo<T> = T extends number ? number : null;

@@ -307,3 +307,3 @@ ```

```ts
```ts option='{ "allowConstructors": "always" }' showPlaygroundButton
type Foo = new () => void;

@@ -325,3 +325,3 @@ ```

```ts
```ts option='{ "allowLiterals": "always" }' showPlaygroundButton
type Foo = {};

@@ -347,3 +347,3 @@

```ts
```ts option='{ "allowLiterals": "in-unions" }' showPlaygroundButton
type Foo = {};

@@ -367,3 +367,3 @@

```ts
```ts option='{ "allowLiterals": "in-unions" }' showPlaygroundButton
type Foo = { name: string } | { age: number };

@@ -374,3 +374,3 @@ ```

```ts
```ts option='{ "allowLiterals": "in-intersections" }' showPlaygroundButton
type Foo = {};

@@ -394,3 +394,3 @@

```ts
```ts option='{ "allowLiterals": "in-intersections" }' showPlaygroundButton
type Foo = { name: string } & { age: number };

@@ -401,3 +401,3 @@ ```

```ts
```ts option='{ "allowLiterals": "in-unions-and-intersections" }' showPlaygroundButton
type Foo = {};

@@ -419,3 +419,3 @@

```ts
```ts option='{ "allowLiterals": "in-unions-and-intersections" }' showPlaygroundButton
type Foo = { name: string } | { age: number };

@@ -439,3 +439,3 @@

```ts
```ts option='{ "allowMappedTypes": "always" }' showPlaygroundButton
type Foo<T> = { readonly [P in keyof T]: T[P] };

@@ -460,3 +460,3 @@

```ts
```ts option='{ "allowMappedTypes": "in-unions" }' showPlaygroundButton
type Foo<T> = { readonly [P in keyof T]: T[P] };

@@ -475,3 +475,3 @@

```ts
```ts option='{ "allowMappedTypes": "in-unions" }' showPlaygroundButton
type Foo<T, U> =

@@ -486,3 +486,3 @@ | { readonly [P in keyof T]: T[P] }

```ts
```ts option='{ "allowMappedTypes": "in-intersections" }' showPlaygroundButton
type Foo<T> = { readonly [P in keyof T]: T[P] };

@@ -501,3 +501,3 @@

```ts
```ts option='{ "allowMappedTypes": "in-intersections" }' showPlaygroundButton
type Foo<T, U> = { readonly [P in keyof T]: T[P] } & {

@@ -512,3 +512,3 @@ readonly [P in keyof U]: U[P];

```ts
```ts option='{ "allowMappedTypes": "in-unions-and-intersections" }' showPlaygroundButton
type Foo<T> = { readonly [P in keyof T]: T[P] };

@@ -521,3 +521,3 @@

```ts
```ts option='{ "allowMappedTypes": "in-unions-and-intersections" }' showPlaygroundButton
type Foo<T, U> =

@@ -549,3 +549,3 @@ | { readonly [P in keyof T]: T[P] }

```ts
```ts option='{ "allowTupleTypes": "always" }' showPlaygroundButton
type Foo = [number];

@@ -562,3 +562,3 @@

```ts
```ts option='{ "allowTupleTypes": "in-unions" }' showPlaygroundButton
type Foo = [number];

@@ -573,3 +573,3 @@

```ts
```ts option='{ "allowTupleTypes": "in-unions" }' showPlaygroundButton
type Foo = [number] | [number, number];

@@ -582,3 +582,3 @@

```ts
```ts option='{ "allowTupleTypes": "in-intersections" }' showPlaygroundButton
type Foo = [number];

@@ -593,3 +593,3 @@

```ts
```ts option='{ "allowTupleTypes": "in-intersections" }' showPlaygroundButton
type Foo = [number] & [number, number];

@@ -602,3 +602,3 @@

```ts
```ts option='{ "allowTupleTypes": "in-unions-and-intersections" }' showPlaygroundButton
type Foo = [number];

@@ -609,5 +609,5 @@

Examples of **correct** code for the `{ "allowLiterals": "in-unions-and-intersections" }` option:
Examples of **correct** code for the `{ "allowTupleTypes": "in-unions-and-intersections" }` option:
```ts
```ts option='{ "allowTupleTypes": "in-unions-and-intersections" }' showPlaygroundButton
type Foo = [number] & [number, number];

@@ -628,3 +628,3 @@

```ts
```ts option='{ "allowGenerics": "always" }' showPlaygroundButton
type Foo = Bar<string>;

@@ -641,9 +641,6 @@

## When Not To Use It
<!-- Intentionally Omitted: When Not To Use It -->
When you can't express some shape with an interface or you need to use a union, tuple type,
callback, etc. that would cause the code to be unreadable or impractical.
## Further Reading
- [Advanced Types](https://www.typescriptlang.org/docs/handbook/advanced-types.html)

@@ -64,3 +64,3 @@ ---

```ts
```ts option='{ "allowComparingNullableBooleansToTrue": false }'
declare const someUndefinedCondition: boolean | undefined;

@@ -77,3 +77,3 @@ if (someUndefinedCondition === true) {

```ts
```ts option='{ "allowComparingNullableBooleansToTrue": false }'
declare const someUndefinedCondition: boolean | undefined;

@@ -96,3 +96,3 @@ if (someUndefinedCondition) {

```ts
```ts option='{ "allowComparingNullableBooleansToFalse": false }'
declare const someUndefinedCondition: boolean | undefined;

@@ -109,3 +109,3 @@ if (someUndefinedCondition === false) {

```ts
```ts option='{ "allowComparingNullableBooleansToFalse": false }'
declare const someUndefinedCondition: boolean | undefined;

@@ -133,3 +133,3 @@ if (someUndefinedCondition ?? true) {

## Not To Use It
## When Not To Use It

@@ -136,0 +136,0 @@ Do not use this rule when `strictNullChecks` is disabled.

@@ -80,3 +80,3 @@ ---

```ts
```ts option='{ "allowConstantLoopConditions": true }' showPlaygroundButton
while (true) {}

@@ -99,3 +99,4 @@ for (; true; ) {}

The main downside to using this rule is the need for type information.
If your project is not accurately typed, such as if it's in the process of being converted to TypeScript or is susceptible to [trade-offs in control flow analysis](https://github.com/Microsoft/TypeScript/issues/9998), it may be difficult to enable this rule for particularly non-type-safe areas of code.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -102,0 +103,0 @@ This rule has a known edge case of triggering on conditions that were modified within function calls (as side effects).

@@ -51,2 +51,2 @@ ---

If you don't care about having unneeded enum or namespace qualifiers, then you don't need to use this rule.
If you explicitly prefer to use fully qualified names, such as for explicitness, then you don't need to use this rule.

@@ -74,1 +74,5 @@ ---

```
## When Not To Use It
If you prefer explicitly specifying type parameters even when they are equal to the default, you can skip this rule.

@@ -68,5 +68,5 @@ ---

With `@typescript-eslint/no-unnecessary-type-assertion: ["error", { typesToIgnore: ['Foo'] }]`, the following is **correct** code":
With `@typescript-eslint/no-unnecessary-type-assertion: ["error", { typesToIgnore: ['Foo'] }]`, the following is **correct** code:
```ts
```ts option='{ "typesToIgnore": ["Foo"] }' showPlaygroundButton
type Foo = 3;

@@ -73,0 +73,0 @@ const foo: Foo = 3;

@@ -76,9 +76,19 @@ ---

```ts
declare function foo(arg1: unknown, arg2: Set<unkown>, arg3: unknown[]): void;
```ts showPlaygroundButton
declare function foo(arg1: unknown, arg2: Set<unknown>, arg3: unknown[]): void;
foo(1 as any, new Set<any>(), [] as any[]);
```
## When Not To Use It
If your codebase has many existing `any`s or areas of unsafe code, it may be difficult to enable this rule.
It may be easier to skip the `no-unsafe-*` rules pending increasing type safety in unsafe areas of your project.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
## Related To
- [`no-explicit-any`](./no-explicit-any.md)
- [`no-unsafe-assignment`](./no-unsafe-assignment.md)
- [`no-unsafe-call`](./no-unsafe-call.md)
- [`no-unsafe-member-access`](./no-unsafe-member-access.md)
- [`no-unsafe-return`](./no-unsafe-return.md)

@@ -78,3 +78,3 @@ ---

```ts
```ts showPlaygroundButton
const x: unknown = y as any;

@@ -85,4 +85,14 @@ const x: unknown[] = y as any[];

## When Not To Use It
If your codebase has many existing `any`s or areas of unsafe code, it may be difficult to enable this rule.
It may be easier to skip the `no-unsafe-*` rules pending increasing type safety in unsafe areas of your project.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
## Related To
- [`no-explicit-any`](./no-explicit-any.md)
- [`no-unsafe-argument`](./no-unsafe-argument.md)
- [`no-unsafe-call`](./no-unsafe-call.md)
- [`no-unsafe-member-access`](./no-unsafe-member-access.md)
- [`no-unsafe-return`](./no-unsafe-return.md)

@@ -56,4 +56,14 @@ ---

## When Not To Use It
If your codebase has many existing `any`s or areas of unsafe code, it may be difficult to enable this rule.
It may be easier to skip the `no-unsafe-*` rules pending increasing type safety in unsafe areas of your project.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
## Related To
- [`no-explicit-any`](./no-explicit-any.md)
- [`no-unsafe-argument`](./no-unsafe-argument.md)
- [`no-unsafe-assignment`](./no-unsafe-assignment.md)
- [`no-unsafe-member-access`](./no-unsafe-member-access.md)
- [`no-unsafe-return`](./no-unsafe-return.md)

@@ -52,4 +52,9 @@ ---

## When Not To Use It
If your project intentionally defines classes and interfaces with unsafe declaration merging patterns, this rule might not be for you.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
## Further Reading
- [Declaration Merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html)

@@ -9,18 +9,20 @@ ---

The TypeScript compiler can be surprisingly lenient when working with enums.
For example, it will allow you to compare enum values against numbers even though they might not have any type overlap:
The TypeScript compiler can be surprisingly lenient when working with enums. String enums are widely considered to be safer than number enums, but even string enums have some pitfalls. For example, it is allowed to compare enum values against literals:
```ts
enum Fruit {
Apple,
Banana,
enum Vegetable {
Asparagus = 'asparagus',
}
declare let fruit: Fruit;
declare const vegetable: Vegetable;
fruit === 999; // No error
vegetable === 'asparagus'; // No error
```
This rule flags when an enum typed value is compared to a non-enum `number`.
The above code snippet should instead be written as `vegetable === Vegetable.Asparagus`. Allowing literals in comparisons subverts the point of using enums in the first place. By enforcing comparisons with properly typed enums:
- It makes a codebase more resilient to enum members changing values.
- It allows for code IDEs to use the "Rename Symbol" feature to quickly rename an enum.
- It aligns code to the proper enum semantics of referring to them by name and treating their values as implementation details.
## Examples

@@ -39,3 +41,3 @@

fruit === 999;
fruit === 0;
```

@@ -62,3 +64,3 @@

fruit === Fruit.Banana;
fruit === Fruit.Apple;
```

@@ -81,1 +83,4 @@

If you don't mind number and/or literal string constants being compared against enums, you likely don't need this rule.
Separately, in the rare case of relying on an third party enums that are only imported as `type`s, it may be difficult to adhere to this rule.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -57,3 +57,3 @@ ---

arr[1];
const idx = 1;
let idx = 1;
arr[idx];

@@ -63,4 +63,14 @@ arr[idx++];

## When Not To Use It
If your codebase has many existing `any`s or areas of unsafe code, it may be difficult to enable this rule.
It may be easier to skip the `no-unsafe-*` rules pending increasing type safety in unsafe areas of your project.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
## Related To
- [`no-explicit-any`](./no-explicit-any.md)
- [`no-unsafe-argument`](./no-unsafe-argument.md)
- [`no-unsafe-assignment`](./no-unsafe-assignment.md)
- [`no-unsafe-call`](./no-unsafe-call.md)
- [`no-unsafe-return`](./no-unsafe-return.md)

@@ -91,3 +91,3 @@ ---

```ts
```ts showPlaygroundButton
function foo1(): unknown {

@@ -102,4 +102,14 @@ return JSON.parse(singleObjString); // Return type for JSON.parse is any.

## When Not To Use It
If your codebase has many existing `any`s or areas of unsafe code, it may be difficult to enable this rule.
It may be easier to skip the `no-unsafe-*` rules pending increasing type safety in unsafe areas of your project.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
## Related To
- [`no-explicit-any`](./no-explicit-any.md)
- [`no-unsafe-argument`](./no-unsafe-argument.md)
- [`no-unsafe-assignment`](./no-unsafe-assignment.md)
- [`no-unsafe-call`](./no-unsafe-call.md)
- [`no-unsafe-member-access`](./no-unsafe-member-access.md)

@@ -42,5 +42,3 @@ ---

```ts
/*eslint no-use-before-define: ["error", { "enums": true }]*/
```ts option='{ "enums": true }'
const x = Foo.FOO;

@@ -55,5 +53,3 @@

```ts
/*eslint no-use-before-define: ["error", { "enums": false }]*/
```ts option='{ "enums": false }'
function foo() {

@@ -75,5 +71,3 @@ return Foo.FOO;

```ts
/*eslint no-use-before-define: ["error", { "typedefs": false }]*/
```ts option='{ "typedefs": false }' showPlaygroundButton
let myVar: StringOrNumber;

@@ -90,5 +84,3 @@ type StringOrNumber = string | number;

```ts
/*eslint no-use-before-define: ["error", { "ignoreTypeReferences": true }]*/
```ts option='{ "ignoreTypeReferences": true }' showPlaygroundButton
let var1: StringOrNumber;

@@ -95,0 +87,0 @@ type StringOrNumber = string | number;

@@ -44,1 +44,5 @@ ---

```
## When Not To Use It
If you don't mind an empty `export {}` at the bottom of files, you likely don't need this rule.

@@ -33,3 +33,4 @@ ---

If you don't care about using newer module syntax, then you will not need this rule.
If your project frequently uses older CommonJS `require`s, then this rule might not be applicable to you.
If only a subset of your project uses `require`s then you might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -36,0 +37,0 @@ ## Related To

@@ -41,2 +41,2 @@ ---

If you don't mind having unnecessarily verbose type casts, you can avoid this rule.
If you don't mind having unnecessarily verbose type assertions, you can avoid this rule.

@@ -112,3 +112,3 @@ ---

```ts
```ts option='{ "allow": ["readonly"] }'
class Foo {

@@ -141,3 +141,3 @@ constructor(private name: string) {}

```ts
```ts option='{ "allow": ["readonly"] }'
class Foo {

@@ -160,3 +160,3 @@ constructor(name: string) {}

```ts
```ts option='{ "allow": ["private"] }'
class Foo {

@@ -189,3 +189,3 @@ constructor(readonly name: string) {}

```ts
```ts option='{ "allow": ["private"] }'
class Foo {

@@ -208,3 +208,3 @@ constructor(name: string) {}

```ts
```ts option='{ "allow": ["protected"] }'
class Foo {

@@ -237,3 +237,3 @@ constructor(readonly name: string) {}

```ts
```ts option='{ "allow": ["protected"] }'
class Foo {

@@ -256,3 +256,3 @@ constructor(name: string) {}

```ts
```ts option='{ "allow": ["public"] }'
class Foo {

@@ -285,3 +285,3 @@ constructor(readonly name: string) {}

```ts
```ts option='{ "allow": ["public"] }'
class Foo {

@@ -304,3 +304,3 @@ constructor(name: string) {}

```ts
```ts option='{ "allow": ["private readonly"] }'
class Foo {

@@ -333,3 +333,3 @@ constructor(readonly name: string) {}

```ts
```ts option='{ "allow": ["private readonly"] }'
class Foo {

@@ -352,3 +352,3 @@ constructor(name: string) {}

```ts
```ts option='{ "allow": ["protected readonly"] }'
class Foo {

@@ -381,3 +381,3 @@ constructor(readonly name: string) {}

```ts
```ts option='{ "allow": ["protected readonly"] }'
class Foo {

@@ -400,3 +400,3 @@ constructor(name: string) {}

```ts
```ts option='{ "allow": ["public readonly"] }'
class Foo {

@@ -429,3 +429,3 @@ constructor(readonly name: string) {}

```ts
```ts option='{ "allow": ["public readonly"] }'
class Foo {

@@ -448,3 +448,3 @@ constructor(name: string) {}

```ts
```ts option='{ "prefer": "parameter-property" }'
class Foo {

@@ -474,3 +474,3 @@ private name: string;

```ts
```ts option='{ "prefer": "parameter-property" }'
class Foo {

@@ -501,2 +501,5 @@ private differentName: string;

If you don't care about the using parameter properties in constructors, then you will not need this rule.
If you don't care about which style of parameter properties in constructors is used in your classes, then you will not need this rule.
However, keep in mind that inconsistent style can harm readability in a project.
We recommend picking a single option for this rule that works best for your project.

@@ -44,2 +44,5 @@ ---

If you are using TypeScript < 3.4
If you don't care about which style of literals assertions is used in your code, then you will not need this rule.
However, keep in mind that inconsistent style can harm readability in a project.
We recommend picking a single option for this rule that works best for your project.

@@ -44,4 +44,2 @@ ---

## When Not To Use It
If you transpile for browsers that do not support for-of loops, you may wish to use traditional for loops that produce more compact code.
<!-- Intentionally Omitted: When Not To Use It -->

@@ -87,3 +87,3 @@ ---

If you specifically want to use an interface or type literal with a single call signature for stylistic reasons, you can disable this rule.
If you specifically want to use an interface or type literal with a single call signature for stylistic reasons, you can avoid this rule.

@@ -90,0 +90,0 @@ This rule has a known edge case of sometimes triggering on global augmentations such as `interface Function`.

@@ -75,4 +75,2 @@ ---

## When Not To Use It
If you don't want to suggest `includes`, you can safely turn this rule off.
<!-- Intentionally Omitted: When Not To Use It -->

@@ -72,3 +72,3 @@ ---

```ts
```ts option='{ "allowBitwiseExpressions": true }'
const x = 1;

@@ -88,3 +88,3 @@ enum Foo {

```ts
```ts option='{ "allowBitwiseExpressions": true }'
enum Foo {

@@ -103,2 +103,2 @@ A = 1 << 0,

If you want use anything other than simple literals as an enum value.
If you want use anything other than simple literals as an enum value, this rule might not be for you.

@@ -41,3 +41,3 @@ ---

If you are using the ES2015 module syntax, then you will not need this rule.
If you are not using TypeScript's older `module`/`namespace` keywords, then you will not need this rule.

@@ -44,0 +44,0 @@ ## Further Reading

@@ -12,3 +12,3 @@ ---

This rule reports when you can safely replace:
This rule reports when you may consider replacing:

@@ -30,3 +30,3 @@ - An `||` operator with `??`

```ts
```ts option='{ "ignoreTernaryTests": false }' showPlaygroundButton
const foo: any = 'bar';

@@ -49,3 +49,3 @@ foo !== undefined && foo !== null ? foo : 'a string';

```ts
```ts option='{ "ignoreTernaryTests": false }' showPlaygroundButton
const foo: any = 'bar';

@@ -76,3 +76,3 @@ foo ?? 'a string';

```ts
```ts option='{ "ignoreConditionalTests": false }' showPlaygroundButton
declare const a: string | null;

@@ -94,3 +94,3 @@ declare const b: string | null;

```ts
```ts option='{ "ignoreConditionalTests": false }' showPlaygroundButton
declare const a: string | null;

@@ -120,3 +120,3 @@ declare const b: string | null;

```ts
```ts option='{ "ignoreMixedLogicalExpressions": false }' showPlaygroundButton
declare const a: string | null;

@@ -136,3 +136,3 @@ declare const b: string | null;

```ts
```ts option='{ "ignoreMixedLogicalExpressions": false }' showPlaygroundButton
declare const a: string | null;

@@ -154,3 +154,3 @@ declare const b: string | null;

If you would like to ignore certain primitive types that can be falsy then you may pass an object containing a boolean value for each primitive:
If you would like to ignore expressions containing operands of certain primitive types that can be falsy then you may pass an object containing a boolean value for each primitive:

@@ -162,5 +162,5 @@ - `string: true`, ignores `null` or `undefined` unions with `string` (default: false).

Incorrect code for `ignorePrimitives: { string: true }`, and correct code for `ignorePrimitives: { string: false }`:
Incorrect code for `ignorePrimitives: { string: false }`, and correct code for `ignorePrimitives: { string: true }`:
```ts
```ts option='{ "ignorePrimitives": { "string": true } }' showPlaygroundButton
const foo: string | undefined = 'bar';

@@ -170,5 +170,5 @@ foo || 'a string';

Correct code for `ignorePrimitives: { string: true }`:
Correct code for both `ignorePrimitives: { string: false }` and `ignorePrimitives: { string: true }`:
```ts
```ts option='{ "ignorePrimitives": { "string": true } }' showPlaygroundButton
const foo: string | undefined = 'bar';

@@ -178,3 +178,3 @@ foo ?? 'a string';

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 }`.
Also, if you would like to ignore all primitives types, you can set `ignorePrimitives: true`. It is equivalent to `ignorePrimitives: { string: true, number: true, bigint: true, boolean: true }`.

@@ -181,0 +181,0 @@ ## When Not To Use It

@@ -71,3 +71,3 @@ ---

```ts
```ts option='{ "allowPotentiallyUnsafeFixesThatModifyTheReturnTypeIKnowWhatImDoing": true }' showPlaygroundButton
declare const foo: { bar: boolean } | null | undefined;

@@ -80,3 +80,3 @@ declare function acceptsBoolean(arg: boolean): void;

// ❌ typechecks UNSUCCESSFULLY as the expression returns `boolean | undefined`
acceptsBoolean(foo != null && foo.bar);
acceptsBoolean(foo?.bar);
```

@@ -96,3 +96,3 @@

```ts
```ts option='{ "checkAny": true }'
declare const thing: any;

@@ -105,3 +105,3 @@

```ts
```ts option='{ "checkAny": false }'
declare const thing: any;

@@ -122,3 +122,3 @@

```ts
```ts option='{ "checkUnknown": true }'
declare const thing: unknown;

@@ -131,3 +131,3 @@

```ts
```ts option='{ "checkUnknown": false }'
declare const thing: unknown;

@@ -148,3 +148,3 @@

```ts
```ts option='{ "checkString": true }'
declare const thing: string;

@@ -157,3 +157,3 @@

```ts
```ts option='{ "checkString": false }'
declare const thing: string;

@@ -174,3 +174,3 @@

```ts
```ts option='{ "checkNumber": true }'
declare const thing: number;

@@ -183,3 +183,3 @@

```ts
```ts option='{ "checkNumber": false }'
declare const thing: number;

@@ -200,3 +200,3 @@

```ts
```ts option='{ "checkBoolean": true }'
declare const thing: boolean;

@@ -209,3 +209,3 @@

```ts
```ts option='{ "checkBoolean": false }'
declare const thing: boolean;

@@ -226,3 +226,3 @@

```ts
```ts option='{ "checkBigInt": true }'
declare const thing: bigint;

@@ -235,3 +235,3 @@

```ts
```ts option='{ "checkBigInt": false }'
declare const thing: bigint;

@@ -252,3 +252,3 @@

```ts
```ts option='{ "requireNullish": true }'
declare const thing1: string | null;

@@ -260,3 +260,3 @@ thing1 && thing1.toString();

```ts
```ts option='{ "requireNullish": true }'
declare const thing1: string | null;

@@ -273,3 +273,4 @@ thing1?.toString();

If you don't mind using more explicit `&&`s/`||`s, you don't need this rule.
If your project is not accurately typed, such as if it's in the process of being converted to TypeScript or is susceptible to [trade-offs in control flow analysis](https://github.com/Microsoft/TypeScript/issues/9998), it may be difficult to enable this rule for particularly non-type-safe areas of code.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -276,0 +277,0 @@ ## Further Reading

@@ -161,3 +161,3 @@ ---

```ts
```ts option='{"allow":["$",{"source":"file","name":"Foo"},{"source":"lib","name":"HTMLElement"},{"from":"package","name":"Bar","package":"bar-lib"}]}'
interface ThisIsMutable {

@@ -176,8 +176,13 @@ prop: string;

function fn1(arg: ThisIsMutable) {} // Incorrect because ThisIsMutable is not readonly
function fn2(arg: Wrapper) {} // Incorrect because Wrapper.sub is not readonly
function fn3(arg: WrapperWithOther) {} // Incorrect because WrapperWithOther.otherProp is not readonly and not in the allowlist
// Incorrect because ThisIsMutable is not readonly
function fn1(arg: ThisIsMutable) {}
// Incorrect because Wrapper.sub is not readonly
function fn2(arg: Wrapper) {}
// Incorrect because WrapperWithOther.otherProp is not readonly and not in the allowlist
function fn3(arg: WrapperWithOther) {}
```
```ts
```ts option='{"allow":["$",{"source":"file","name":"Foo"},{"source":"lib","name":"HTMLElement"},{"from":"package","name":"Bar","package":"bar-lib"}]}'
import { Foo } from 'some-lib';

@@ -190,5 +195,10 @@ import { Bar } from 'incorrect-lib';

function fn1(arg: Foo) {} // Incorrect because Foo is not a local type
function fn2(arg: HTMLElement) {} // Incorrect because HTMLElement is not from the default library
function fn3(arg: Bar) {} // Incorrect because Bar is not from "bar-lib"
// Incorrect because Foo is not a local type
function fn1(arg: Foo) {}
// Incorrect because HTMLElement is not from the default library
function fn2(arg: HTMLElement) {}
// Incorrect because Bar is not from "bar-lib"
function fn3(arg: Bar) {}
```

@@ -198,3 +208,3 @@

```ts
```ts option='{"allow":["$",{"source":"file","name":"Foo"},{"source":"lib","name":"HTMLElement"},{"from":"package","name":"Bar","package":"bar-lib"}]}'
interface Foo {

@@ -209,7 +219,10 @@ prop: string;

function fn1(arg: Foo) {} // Works because Foo is allowed
function fn2(arg: Wrapper) {} // Works even when Foo is nested somewhere in the type, with other properties still being checked
// Works because Foo is allowed
function fn1(arg: Foo) {}
// Works even when Foo is nested somewhere in the type, with other properties still being checked
function fn2(arg: Wrapper) {}
```
```ts
```ts option='{"allow":["$",{"source":"file","name":"Foo"},{"source":"lib","name":"HTMLElement"},{"from":"package","name":"Bar","package":"bar-lib"}]}'
import { Bar } from 'bar-lib';

@@ -221,11 +234,17 @@

function fn1(arg: Foo) {} // Works because Foo is a local type
function fn2(arg: HTMLElement) {} // Works because HTMLElement is from the default library
function fn3(arg: Bar) {} // Works because Bar is from "bar-lib"
// Works because Foo is a local type
function fn1(arg: Foo) {}
// Works because HTMLElement is from the default library
function fn2(arg: HTMLElement) {}
// Works because Bar is from "bar-lib"
function fn3(arg: Bar) {}
```
```ts
```ts option='{"allow":["$",{"source":"file","name":"Foo"},{"source":"lib","name":"HTMLElement"},{"from":"package","name":"Bar","package":"bar-lib"}]}'
import { Foo } from './foo';
function fn(arg: Foo) {} // Works because Foo is still a local type - it has to be in the same package
// Works because Foo is still a local type - it has to be in the same package
function fn(arg: Foo) {}
```

@@ -244,3 +263,3 @@

```ts
```ts option='{ "checkParameterProperties": true }'
class Foo {

@@ -253,3 +272,3 @@ constructor(private paramProp: string[]) {}

```ts
```ts option='{ "checkParameterProperties": true }'
class Foo {

@@ -264,3 +283,3 @@ constructor(private paramProp: readonly string[]) {}

```ts
```ts option='{ "checkParameterProperties": false }' showPlaygroundButton
class Foo {

@@ -284,3 +303,3 @@ constructor(

```ts
```ts option='{ "ignoreInferredTypes": true }'
import { acceptsCallback, CallbackOptions } from 'external-dependency';

@@ -294,3 +313,3 @@

```ts
```ts option='{ "ignoreInferredTypes": true }'
export interface CallbackOptions {

@@ -309,3 +328,3 @@ prop: string;

```ts
```ts option='{ "ignoreInferredTypes": true }'
import { acceptsCallback } from 'external-dependency';

@@ -319,3 +338,3 @@

```ts
```ts option='{ "ignoreInferredTypes": true }'
export interface CallbackOptions {

@@ -342,3 +361,3 @@ prop: string;

```ts
```ts option='{ "treatMethodsAsReadonly": false }'
type MyType = {

@@ -353,3 +372,3 @@ readonly prop: string;

```ts
```ts option='{ "treatMethodsAsReadonly": false }'
type MyType = Readonly<{

@@ -372,3 +391,3 @@ prop: string;

```ts
```ts option='{ "treatMethodsAsReadonly": true }' showPlaygroundButton
type MyType = {

@@ -380,1 +399,5 @@ readonly prop: string;

```
## When Not To Use It
If your project does not attempt to enforce strong immutability guarantees of parameters, you can avoid this rule.

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

Member variables with the privacy `private` are never permitted to be modified outside of their declaring class.
Private member variables (whether using the `private` modifier or private `#` fields) are never permitted to be modified outside of their declaring class.
If that class never modifies their value, they may safely be marked as `readonly`.

@@ -26,2 +26,3 @@

private onlyModifiedInConstructor: number;
#neverModifiedPrivateField = 3;

@@ -54,2 +55,9 @@ public constructor(

}
// This is modified later on by the class
#modifiedLaterPrivateField = 'unchanged';
public mutatePrivateField() {
this.#modifiedLaterPrivateField = 'mutated';
}
}

@@ -76,3 +84,3 @@ ```

```ts
```ts option='{ "onlyInlineLambdas": true }'
class Container {

@@ -87,3 +95,3 @@ private onClick = () => {

```ts
```ts option='{ "onlyInlineLambdas": true }'
class Container {

@@ -93,1 +101,5 @@ private neverModifiedPrivate = 'unchanged';

```
## When Not To Use It
If you aren't trying to enforce strong immutability guarantees, this rule may be too restrictive for your project.

@@ -58,2 +58,4 @@ ---

If you don't want to use typechecking in your linting, you can't use this rule.
This rule can sometimes be difficult to work around when creating objects using a `.reduce`.
See [[prefer-reduce-type-parameter] unfixable reporting #3440](https://github.com/typescript-eslint/typescript-eslint/issues/3440) for more details.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -57,2 +57,3 @@ ---

If you don't mind that style, you can turn this rule off safely.
If you don't mind which style of string checking is used, you can turn this rule off safely.
However, keep in mind that inconsistent style can harm readability in a project.

@@ -66,2 +66,3 @@ ---

If you are compiling against multiple versions of TypeScript and using `@ts-ignore` to ignore version-specific type errors, this rule might get in your way.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -68,0 +69,0 @@ ## Further Reading

@@ -60,1 +60,6 @@ ---

```
## When Not To Use It
This rule can be difficult to enable on projects that use APIs which require functions to always be `async`.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) along with filing issues on your dependencies for those specific situations instead of completely disabling this rule.

@@ -9,16 +9,53 @@ ---

`@typescript-eslint/eslint-plugin` includes over 100 rules that detect best practice violations, bugs, and/or stylistic issues specifically for TypeScript code.
See [Configs](/linting/configs) for how to enable recommended rules using configs.
`@typescript-eslint/eslint-plugin` includes over 100 rules that detect best practice violations, bugs, and/or stylistic issues specifically for TypeScript code. All of our rules are listed below.
## Supported Rules
:::tip
Instead of enabling rules one by one, we recommend using one of [our pre-defined configs](/linting/configs) to enable a large set of recommended rules.
:::
## Rules
The rules are listed in alphabetical order. You can optionally filter them based on these categories:
import RulesTable from "@site/src/components/RulesTable";
<RulesTable ruleset="supported-rules" />
<RulesTable />
## Filtering
### Config Group (⚙️)
"Config Group" refers to the [pre-defined config](/linting/configs) that includes the rule. Extending from a configuration preset allow for enabling a large set of recommended rules all at once.
### Metadata
- `🔧 fixable` refers to whether the rule contains an [ESLint `--fix` auto-fixer](https://eslint.org/docs/latest/use/command-line-interface#--fix).
- `💡 has suggestions` refers to whether the rule contains an ESLint suggestion fixer.
- Sometimes, it is not safe to automatically fix the code with an auto-fixer. But in these cases, we often have a good guess of what the correct fix should be, and we can provide it as a suggestion to the developer.
- `💭 requires type information` refers to whether the rule requires [typed linting](/linting/typed-linting).
- `🧱 extension rule` means that the rule is an extension of an [core ESLint rule](https://eslint.org/docs/latest/rules) (see [Extension Rules](#extension-rules)).
- `📐 formatting rule` means that the rule has to do with formatting.
- We [strongly recommend against using ESLint for formatting](/linting/troubleshooting/formatting).
- Soon, formatting rules will be moved to the [ESLint stylistic plugin](https://eslint.style).
- `💀 deprecated rule` means that the rule should no longer be used and will be removed from the plugin in a future version.
## Extension Rules
In some cases, ESLint provides a rule itself, but it doesn't support TypeScript syntax; either it crashes, or it ignores the syntax, or it falsely reports against it.
In these cases, we create what we call an extension rule; a rule within our plugin that has the same functionality, but also supports TypeScript.
Some core ESLint rules do not support TypeScript syntax: either they crash, ignore the syntax, or falsely report against it.
In these cases, we create what we call an "extension rule": a rule within our plugin that has the same functionality, but also supports TypeScript.
<RulesTable ruleset="extension-rules" />
Extension rules generally completely replace the base rule from ESLint core.
If the base rule is enabled in a config you extend from, you'll need to disable the base rule:
```js
module.exports = {
extends: ['eslint:recommended'],
rules: {
// Note: you must disable the base rule as it can report incorrect errors
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
},
};
```
[Search for `🧱 extension rule`s](?=extension#rules) in this page to see all extension rules.
---
description: 'Require `Array#sort` calls to always provide a `compareFunction`.'
description: 'Require `Array#sort` and `Array#toSorted` calls to always provide a `compareFunction`.'
---

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

When called without a compare function, `Array#sort()` converts all non-undefined array elements into strings and then compares said strings based off their UTF-16 code units [[ECMA specification](https://www.ecma-international.org/ecma-262/9.0/#sec-sortcompare)].
When called without a compare function, `Array#sort()` and `Array#toSorted()` converts all non-undefined array elements into strings and then compares said strings based off their UTF-16 code units [[ECMA specification](https://www.ecma-international.org/ecma-262/9.0/#sec-sortcompare)].

@@ -19,7 +19,7 @@ The result is that elements are sorted alphabetically, regardless of their type.

This rule reports on any call to the `Array#sort()` method that doesn't provide a `compare` argument.
This rule reports on any call to the sort methods that do not provide a `compare` argument.
## Examples
This rule aims to ensure all calls of the native `Array#sort` method provide a `compareFunction`, while ignoring calls to user-defined `sort` methods.
This rule aims to ensure all calls of the native sort methods provide a `compareFunction`, while ignoring calls to user-defined methods.

@@ -62,3 +62,3 @@ <!--tabs-->

```ts
```ts option='{ "ignoreStringArrays": true }'
const one = 1;

@@ -72,3 +72,3 @@ const two = 2;

```ts
```ts option='{ "ignoreStringArrays": true }'
const one = '1';

@@ -82,2 +82,2 @@ const two = '2';

If you understand the language specification enough, and/or only ever sort arrays in a string-like manner, you can turn this rule off safely.
If you intentionally want your arrays to be always sorted in a string-like manner, you can turn this rule off safely.

@@ -77,3 +77,3 @@ ---

```ts
```ts option='{ "allowAny": true }'
let fn = (a: number, b: []) => a + b;

@@ -85,3 +85,3 @@ let fn = (a: string, b: []) => a + b;

```ts
```ts option='{ "allowAny": true }'
let fn = (a: number, b: any) => a + b;

@@ -99,3 +99,3 @@ let fn = (a: string, b: any) => a + b;

```ts
```ts option='{ "allowBoolean": true }'
let fn = (a: number, b: unknown) => a + b;

@@ -107,3 +107,3 @@ let fn = (a: string, b: unknown) => a + b;

```ts
```ts option='{ "allowBoolean": true }'
let fn = (a: number, b: boolean) => a + b;

@@ -121,3 +121,3 @@ let fn = (a: string, b: boolean) => a + b;

```ts
```ts option='{ "allowNullish": true }'
let fn = (a: number, b: unknown) => a + b;

@@ -131,3 +131,3 @@ let fn = (a: number, b: never) => a + b;

```ts
```ts option='{ "allowNullish": true }'
let fn = (a: number, b: undefined) => a + b;

@@ -147,3 +147,3 @@ let fn = (a: number, b: null) => a + b;

```ts
```ts option='{ "allowNumberAndString": true }'
let fn = (a: number, b: unknown) => a + b;

@@ -155,3 +155,3 @@ let fn = (a: number, b: never) => a + b;

```ts
```ts option='{ "allowNumberAndString": true }'
let fn = (a: number, b: string) => a + b;

@@ -169,3 +169,3 @@ let fn = (a: number, b: number | string) => a + b;

```ts
```ts option='{ "allowRegExp": true }'
let fn = (a: number, b: RegExp) => a + b;

@@ -176,3 +176,3 @@ ```

```ts
```ts option='{ "allowRegExp": true }'
let fn = (a: string, b: RegExp) => a + b;

@@ -183,3 +183,3 @@ ```

Examples of code for this rule with `{ skipCompoundAssignments: true }`:
Examples of code for this rule with `{ skipCompoundAssignments: false }`:

@@ -190,3 +190,3 @@ <!--tabs-->

```ts
```ts option='{ "skipCompoundAssignments": true }'
let foo: string | undefined;

@@ -201,3 +201,3 @@ foo += 'some data';

```ts
```ts option='{ "skipCompoundAssignments": true }'
let foo: number = 0;

@@ -212,3 +212,3 @@ foo += 1;

If you don't mind `"[object Object]"` in your strings, then you will not need this rule.
If you don't mind a risk of `"[object Object]"` or incorrect type coercions in your values, then you will not need this rule.

@@ -215,0 +215,0 @@ ## Related To

@@ -54,3 +54,3 @@ ---

```ts
```ts option='{ "allowNumber": true }' showPlaygroundButton
const arg = 123;

@@ -67,3 +67,3 @@ const msg1 = `arg = ${arg}`;

```ts
```ts option='{ "allowBoolean": true }' showPlaygroundButton
const arg = true;

@@ -78,3 +78,3 @@ const msg1 = `arg = ${arg}`;

```ts
```ts option='{ "allowAny": true }' showPlaygroundButton
const user = JSON.parse('{ "name": "foo" }');

@@ -89,3 +89,3 @@ const msg1 = `arg = ${user.name}`;

```ts
```ts option='{ "allowNullish": true }' showPlaygroundButton
const arg = condition ? 'ok' : null;

@@ -99,3 +99,3 @@ const msg1 = `arg = ${arg}`;

```ts
```ts option='{ "allowRegExp": true }' showPlaygroundButton
const arg = new RegExp('foo');

@@ -105,3 +105,3 @@ const msg1 = `arg = ${arg}`;

```ts
```ts option='{ "allowRegExp": true }' showPlaygroundButton
const arg = /foo/;

@@ -115,3 +115,3 @@ const msg1 = `arg = ${arg}`;

```ts
```ts option='{ "allowNever": true }' showPlaygroundButton
const arg = 'something';

@@ -121,2 +121,6 @@ const msg1 = typeof arg === 'string' ? arg : `arg = ${arg}`;

## When Not To Use It
If you're not worried about incorrectly stringifying non-string values in template literals, then you likely don't need this rule.
## Related To

@@ -123,0 +127,0 @@

@@ -40,3 +40,3 @@ ---

```ts
```ts option='"in-try-catch"'
async function invalidInTryCatch1() {

@@ -87,3 +87,3 @@ try {

```ts
```ts option='"in-try-catch"'
async function validInTryCatch1() {

@@ -142,3 +142,3 @@ try {

```ts
```ts option='"always"'
async function invalidAlways1() {

@@ -161,3 +161,3 @@ try {

```ts
```ts option='"always"'
async function validAlways1() {

@@ -188,3 +188,3 @@ try {

```ts
```ts option='"never"'
async function invalidNever1() {

@@ -207,3 +207,3 @@ try {

```ts
```ts option='"never"'
async function validNever1() {

@@ -210,0 +210,0 @@ try {

@@ -102,1 +102,7 @@ ---

- `nullish` - `null` and `undefined`
## When Not To Use It
This rule is purely a stylistic rule for maintaining consistency in your project.
You can turn it off if you don't want to keep a consistent, predictable order for intersection and union types.
However, keep in mind that inconsistent style can harm readability in a project.

@@ -181,4 +181,11 @@ ---

## When Not To Use It
If your project isn't likely to experience bugs from falsy non-boolean values being used in logical conditions, you can skip enabling this rule.
Otherwise, this rule can be quite strict around requiring exact comparisons in logical checks.
If you prefer more succinct checks over more precise boolean logic, this rule might not be for you.
## Related To
- [no-unnecessary-condition](./no-unnecessary-condition.md) - Similar rule which reports always-truthy and always-falsy values in conditions
---
description: 'Require switch-case statements to be exhaustive with union type.'
description: 'Require switch-case statements to be exhaustive.'
---

@@ -9,9 +9,15 @@

When working with union types in TypeScript, it's common to want to write a `switch` statement intended to contain a `case` for each constituent (possible type in the union).
However, if the union type changes, it's easy to forget to modify the cases to account for any new types.
When working with union types or enums in TypeScript, it's common to want to write a `switch` statement intended to contain a `case` for each constituent (possible type in the union or the enum).
However, if the union type or the enum changes, it's easy to forget to modify the cases to account for any new types.
This rule reports when a `switch` statement over a value typed as a union of literals is missing a case for any of those literal types and does not have a `default` clause.
This rule reports when a `switch` statement over a value typed as a union of literals or as an enum is missing a case for any of those literal types and does not have a `default` clause.
There is also an option to check the exhaustiveness of switches on non-union types by requiring a default clause.
## Examples
When the switch doesn't have exhaustive cases, either filling them all out or adding a default will correct the rule's complaint.
Here are some examples of code working with a union of literals:
<!--tabs-->

@@ -31,3 +37,3 @@

const day = 'Monday' as Day;
declare const day: Day;
let result = 0;

@@ -54,3 +60,3 @@

const day = 'Monday' as Day;
declare const day: Day;
let result = 0;

@@ -95,3 +101,3 @@

const day = 'Monday' as Day;
declare const day: Day;
let result = 0;

@@ -108,4 +114,99 @@

<!--/tabs-->
Likewise, here are some examples of code working with an enum:
<!--tabs-->
### ❌ Incorrect
```ts
enum Fruit {
Apple,
Banana,
Cherry,
}
declare const fruit: Fruit;
switch (fruit) {
case Fruit.Apple:
console.log('an apple');
break;
}
```
### ✅ Correct
```ts
enum Fruit {
Apple,
Banana,
Cherry,
}
declare const fruit: Fruit;
switch (fruit) {
case Fruit.Apple:
console.log('an apple');
break;
case Fruit.Banana:
console.log('a banana');
break;
case Fruit.Cherry:
console.log('a cherry');
break;
}
```
### ✅ Correct
```ts
enum Fruit {
Apple,
Banana,
Cherry,
}
declare const fruit: Fruit;
switch (fruit) {
case Fruit.Apple:
console.log('an apple');
break;
default:
console.log('a fruit');
break;
}
```
<!--/tabs-->
## Options
### `requireDefaultForNonUnion`
Examples of additional **incorrect** code for this rule with `{ requireDefaultForNonUnion: true }`:
```ts option='{ "requireDefaultForNonUnion": true }' showPlaygroundButton
const value: number = Math.floor(Math.random() * 3);
switch (value) {
case 0:
return 0;
case 1:
return 1;
}
```
Since `value` is a non-union type it requires the switch case to have a default clause only with `requireDefaultForNonUnion` enabled.
<!--/tabs-->
## When Not To Use It
If you don't frequently `switch` over union types with many parts, or intentionally wish to leave out some parts.
If you don't frequently `switch` over union types or enums with many parts, or intentionally wish to leave out some parts, this rule may not be for you.

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

```ts
```ts option='{ "path": "never", "types": "never", "lib": "never" }' showPlaygroundButton
/// <reference path="foo" />

@@ -26,3 +26,3 @@ /// <reference types="bar" />

```ts
```ts option='{ "types": "prefer-import" }' showPlaygroundButton
/// <reference types="foo" />

@@ -32,3 +32,3 @@ import * as foo from 'foo';

```ts
```ts option='{ "types": "prefer-import" }' showPlaygroundButton
/// <reference types="foo" />

@@ -40,3 +40,3 @@ import foo = require('foo');

```ts
```ts option='{ "path": "always", "types": "always", "lib": "always" }' showPlaygroundButton
/// <reference path="foo" />

@@ -49,13 +49,16 @@ /// <reference types="bar" />

```ts
```ts option='{ "types": "prefer-import" }' showPlaygroundButton
import * as foo from 'foo';
```
```ts
```ts option='{ "types": "prefer-import" }' showPlaygroundButton
import foo = require('foo');
```
## When To Use It
## When Not To Use It
If you want to ban use of one or all of the triple slash reference directives, or any time you might use triple-slash type reference directives and ES6 import declarations in the same file.
Most modern TypeScript projects generally use `import` statements to bring in types.
It's rare to need a `///` triple-slash reference outside of auto-generated code.
If your project is a rare one with one of those use cases, this rule might not be for you.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.

@@ -62,0 +65,0 @@ ## When Not To Use It

@@ -101,3 +101,3 @@ ---

<!-- prettier-ignore -->
```ts
```ts option='{ "before": false, "after": true }'
let foo:string = "bar";

@@ -131,3 +131,3 @@ let foo :string = "bar";

<!-- prettier-ignore -->
```ts
```ts option='{ "before": false, "after": true }'
let foo: string = "bar";

@@ -155,3 +155,3 @@

<!-- prettier-ignore -->
```ts
```ts option='{ "before": true, "after": true }'
let foo: string = "bar";

@@ -185,3 +185,3 @@ let foo:string = "bar";

<!-- prettier-ignore -->
```ts
```ts option='{ "before": true, "after": true }'
let foo : string = "bar";

@@ -213,3 +213,3 @@

<!-- prettier-ignore -->
```ts
```ts option='{"before":false,"after":false,"overrides":{"colon":{"before":true,"after":true}}}'
let foo: string = "bar";

@@ -243,3 +243,3 @@ let foo:string = "bar";

<!-- prettier-ignore -->
```ts
```ts option='{"before":false,"after":false,"overrides":{"colon":{"before":true,"after":true}}}'
let foo : string = "bar";

@@ -275,3 +275,3 @@

<!-- prettier-ignore -->
```ts
```ts option='{"before":false,"after":false,"overrides":{"arrow":{"before":true,"after":true}}}'
let foo: string = "bar";

@@ -305,3 +305,3 @@ let foo : string = "bar";

<!-- prettier-ignore -->
```ts
```ts option='{"before":false,"after":false,"overrides":{"arrow":{"before":true,"after":true}}}'
let foo:string = "bar";

@@ -308,0 +308,0 @@

@@ -70,3 +70,3 @@ ---

```ts
```ts option='{ "arrayDestructuring": true }'
const [a] = [1];

@@ -78,3 +78,3 @@ const [b, c] = [1, 2];

```ts
```ts option='{ "arrayDestructuring": true }'
const [a]: number[] = [1];

@@ -98,3 +98,3 @@ const [b]: [number] = [2];

```ts
```ts option='{ "arrowParameter": true }'
const logsSize = size => console.log(size);

@@ -111,3 +111,3 @@

```ts
```ts option='{ "arrowParameter": true }'
const logsSize = (size: number) => console.log(size);

@@ -132,3 +132,3 @@

```ts
```ts option='{ "memberVariableDeclaration": true }'
class ContainsText {

@@ -142,3 +142,3 @@ delayedText;

```ts
```ts option='{ "memberVariableDeclaration": true }'
class ContainsText {

@@ -160,3 +160,3 @@ delayedText: string;

```ts
```ts option='{ "objectDestructuring": true }'
const { length } = 'text';

@@ -168,3 +168,3 @@ const [b, c] = Math.random() ? [1, 2] : [3, 4];

```ts
```ts option='{ "objectDestructuring": true }'
const { length }: { length: number } = 'text';

@@ -187,3 +187,3 @@ const [b, c]: [number, number] = Math.random() ? [1, 2] : [3, 4];

```ts
```ts option='{ "parameter": true }'
function logsSize(size): void {

@@ -216,3 +216,3 @@ console.log(size);

```ts
```ts option='{ "parameter": true }'
function logsSize(size: number): void {

@@ -253,3 +253,3 @@ console.log(size);

```ts
```ts option='{ "propertyDeclaration": true }'
type Members = {

@@ -263,3 +263,3 @@ member;

```ts
```ts option='{ "propertyDeclaration": true }'
type Members = {

@@ -281,3 +281,3 @@ member: boolean;

```ts
```ts option='{ "variableDeclaration": true }'
const text = 'text';

@@ -290,3 +290,3 @@ let initialText = 'text';

```ts
```ts option='{ "variableDeclaration": true }'
const text: string = 'text';

@@ -307,3 +307,3 @@ let initialText: string = 'text';

```ts
```ts option='{ "variableDeclaration": true, "variableDeclarationIgnoreFunction": true }'
const text = 'text';

@@ -314,3 +314,3 @@ ```

```ts
```ts option='{ "variableDeclaration": true, "variableDeclarationIgnoreFunction": true }'
const a = (): void => {};

@@ -317,0 +317,0 @@ const b = function (): void => {};

@@ -86,3 +86,3 @@ ---

```ts
```ts option='{ "ignoreStatic": true }' showPlaygroundButton
class OtherClass {

@@ -102,4 +102,6 @@ static log() {

If your code intentionally waits to bind methods after use, such as by passing a `scope: this` along with the method, you can disable this rule.
If your project dynamically changes `this` scopes around in a way TypeScript has difficulties modeling, this rule may not be viable to use.
One likely difficult pattern is if your code intentionally waits to bind methods after use, such as by passing a `scope: this` along with the method.
You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
If you're wanting to use `toBeCalled` and similar matches in `jest` tests, you can disable this rule for your test files in favor of [`eslint-plugin-jest`'s version of this rule](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/unbound-method.md).

@@ -58,3 +58,3 @@ ---

```ts
```ts option='{ "ignoreDifferentlyNamedParameters": true }'
function f(a: number): void;

@@ -66,5 +66,14 @@ function f(a: string): void;

```ts
```ts option='{ "ignoreDifferentlyNamedParameters": true }'
function f(a: number): void;
function f(b: string): void;
```
## When Not To Use It
This is purely a stylistic rule to help with readability of function signature overloads.
You can turn it off if you don't want to consistently keep them next to each other and unified.
## Related To
- [`adjacent-overload-signatures`](./adjacent-overload-signatures.md)

@@ -1,2 +0,2 @@

import type { TSESLint } from '@typescript-eslint/utils';
import type { ClassicConfig } from '@typescript-eslint/utils/ts-eslint';

@@ -6,5 +6,5 @@ import type rules from './rules';

declare const cjsExport: {
configs: Record<string, TSESLint.Linter.Config>;
configs: Record<string, ClassicConfig.Config>;
rules: typeof rules;
};
export = cjsExport;
{
"name": "@typescript-eslint/eslint-plugin",
"version": "6.4.0",
"version": "6.15.0",
"description": "TypeScript plugin for ESLint",

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

"generate:configs": "yarn tsx tools/generate-configs.ts",
"lint": "nx lint",
"lint": "npx nx lint",
"test": "jest --coverage --logHeapUsage",

@@ -61,6 +61,6 @@ "test-single": "jest --no-coverage",

"@eslint-community/regexpp": "^4.5.1",
"@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",
"@typescript-eslint/scope-manager": "6.15.0",
"@typescript-eslint/type-utils": "6.15.0",
"@typescript-eslint/utils": "6.15.0",
"@typescript-eslint/visitor-keys": "6.15.0",
"debug": "^4.3.4",

@@ -74,17 +74,21 @@ "graphemer": "^1.4.0",

"devDependencies": {
"@prettier/sync": "*",
"@types/debug": "*",
"@types/marked": "*",
"@types/natural-compare": "*",
"@types/prettier": "*",
"@typescript-eslint/rule-schema-to-typescript-types": "6.4.0",
"@typescript-eslint/rule-tester": "6.4.0",
"@typescript-eslint/rule-schema-to-typescript-types": "6.15.0",
"@typescript-eslint/rule-tester": "6.15.0",
"ajv": "^6.12.6",
"chalk": "^5.3.0",
"cross-fetch": "*",
"jest-specific-snapshot": "*",
"grapheme-splitter": "^1.0.4",
"jest": "29.7.0",
"jest-specific-snapshot": "^8.0.0",
"json-schema": "*",
"markdown-table": "^3.0.3",
"marked": "^5.1.1",
"prettier": "*",
"prettier": "^3.0.3",
"rimraf": "*",
"title-case": "^3.0.3",
"tsx": "*",
"typescript": "*"

@@ -105,3 +109,3 @@ },

},
"gitHead": "14bea42e4864c72d28f502e0d15e675fe8bd729a"
"gitHead": "6128a02cb15d500fe22fe265c83e4d7a73ae52c3"
}

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

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

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

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

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

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

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