Skip to content

enable @typescript-eslint/no-unused-vars #57123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f63fde8
enable no-unused-vars
abrahamguo Jan 22, 2024
2b30e24
format
abrahamguo Jan 22, 2024
141e474
correct lockfile
abrahamguo Jan 22, 2024
1dfaf68
revert lockfile
abrahamguo Jan 22, 2024
ba1df11
revert package.json
abrahamguo Jan 22, 2024
f937aae
new ignorepatterns
abrahamguo Jan 22, 2024
6480177
tweaks
abrahamguo Jan 22, 2024
dbea78b
dumb mistake
abrahamguo Jan 22, 2024
4b48354
Merge branch 'main' of github.com:abrahamguo/TypeScript into no-unuse…
abrahamguo Jan 23, 2024
a083d48
suppress
abrahamguo Jan 23, 2024
4cd2960
Merge branch 'main' of github.com:abrahamguo/TypeScript into no-unuse…
abrahamguo Jan 25, 2024
3c9cd1d
remove unused type params
abrahamguo Jan 25, 2024
a963787
Merge branch 'main' of github.com:abrahamguo/TypeScript into no-unuse…
abrahamguo Jan 27, 2024
d67a4f6
remove nounused from tsconfigs
abrahamguo Jan 27, 2024
1101dca
remove allowunusedlabels
abrahamguo Jan 27, 2024
c44c704
more readable regex
abrahamguo Jan 27, 2024
0d12055
Merge branch 'main' of github.com:abrahamguo/TypeScript into no-unuse…
abrahamguo Jan 28, 2024
778b343
switch to jsdoc imports
abrahamguo Jan 28, 2024
d1ba2ce
Merge branch 'main' of github.com:abrahamguo/TypeScript into no-unuse…
abrahamguo Jan 28, 2024
efda314
restore SetAccessorDeclaration import
abrahamguo Jan 28, 2024
1185e6b
improve comment
abrahamguo Jan 28, 2024
c524b68
Merge branch 'main' of github.com:abrahamguo/TypeScript into no-unuse…
abrahamguo Jan 29, 2024
0f15b4e
inline nonunion typedefs
abrahamguo Jan 29, 2024
e9e939c
declaration merging
abrahamguo Jan 29, 2024
121a1db
add explicit return type
abrahamguo Jan 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,14 @@
}
}
],

// Todo: For each of these, investigate whether we want to enable them ✨
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_([^_]|_*$)",
"varsIgnorePattern": "^_[^_]",
"ignoreRestSiblings": true
}
],

// Pending https://github.com/typescript-eslint/typescript-eslint/issues/4820
"@typescript-eslint/prefer-optional-chain": "off",
Expand Down
3 changes: 2 additions & 1 deletion scripts/eslint/rules/argument-trivia.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { AST_NODE_TYPES, TSESTree, ESLintUtils } = require("@typescript-eslint/utils");
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { AST_NODE_TYPES, /* used in JSDoc */ TSESTree, ESLintUtils } = require("@typescript-eslint/utils");
const { createRule } = require("./utils.cjs");
const ts = require("typescript");

Expand Down
3 changes: 2 additions & 1 deletion scripts/eslint/rules/debug-assert.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { AST_NODE_TYPES, TSESTree } = require("@typescript-eslint/utils");
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { AST_NODE_TYPES, TSESTree /* used in JSDoc */ } = require("@typescript-eslint/utils");
const { createRule } = require("./utils.cjs");

module.exports = createRule({
Expand Down
3 changes: 2 additions & 1 deletion scripts/eslint/rules/jsdoc-format.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { TSESTree } = require("@typescript-eslint/utils");
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { TSESTree /* used in JSDoc */ } = require("@typescript-eslint/utils");
const { createRule } = require("./utils.cjs");

module.exports = createRule({
Expand Down
3 changes: 2 additions & 1 deletion scripts/eslint/rules/no-in-operator.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { TSESTree } = require("@typescript-eslint/utils");
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { TSESTree /* used in JSDoc */ } = require("@typescript-eslint/utils");
const { createRule } = require("./utils.cjs");

module.exports = createRule({
Expand Down
3 changes: 2 additions & 1 deletion scripts/eslint/rules/no-keywords.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { TSESTree, AST_NODE_TYPES } = require("@typescript-eslint/utils");
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { /* used in JSDoc */ TSESTree, AST_NODE_TYPES } = require("@typescript-eslint/utils");
const { createRule } = require("./utils.cjs");

module.exports = createRule({
Expand Down
3 changes: 2 additions & 1 deletion scripts/eslint/rules/only-arrow-functions.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { AST_NODE_TYPES, TSESTree } = require("@typescript-eslint/utils");
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { AST_NODE_TYPES, TSESTree /* used in JSDoc */ } = require("@typescript-eslint/utils");
const { createRule } = require("./utils.cjs");

module.exports = createRule({
Expand Down
4 changes: 3 additions & 1 deletion src/compiler/core.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
__String,
CharacterCodes,
Comparer,
Comparison,
Expand Down Expand Up @@ -286,6 +285,7 @@ export function filter<T>(array: T[], f: (x: T) => boolean): T[];
/** @internal */
export function filter<T, U extends T>(array: readonly T[], f: (x: T) => x is U): readonly U[];
/** @internal */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function filter<T, U extends T>(array: readonly T[], f: (x: T) => boolean): readonly T[];
/** @internal */
export function filter<T, U extends T>(array: T[] | undefined, f: (x: T) => x is U): U[] | undefined;
Expand All @@ -294,6 +294,7 @@ export function filter<T>(array: T[] | undefined, f: (x: T) => boolean): T[] | u
/** @internal */
export function filter<T, U extends T>(array: readonly T[] | undefined, f: (x: T) => x is U): readonly U[] | undefined;
/** @internal */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function filter<T, U extends T>(array: readonly T[] | undefined, f: (x: T) => boolean): readonly T[] | undefined;
/** @internal */
export function filter<T>(array: readonly T[] | undefined, f: (x: T) => boolean): readonly T[] | undefined {
Expand Down Expand Up @@ -830,6 +831,7 @@ export function insertSorted<T>(array: SortedArray<T>, insert: T, compare: Compa
}

/** @internal */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function sortAndDeduplicate<T>(array: readonly string[]): SortedReadonlyArray<string>;
/** @internal */
export function sortAndDeduplicate<T>(array: readonly T[], comparer: Comparer<T>, equalityComparer?: EqualityComparer<T>): SortedReadonlyArray<T>;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4131,7 +4131,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
writeSpace();
nextPos = emitTokenWithComment(SyntaxKind.AsKeyword, nextPos, writeKeyword, node);
writeSpace();
nextPos = emitTokenWithComment(SyntaxKind.NamespaceKeyword, nextPos, writeKeyword, node);
emitTokenWithComment(SyntaxKind.NamespaceKeyword, nextPos, writeKeyword, node);
writeSpace();
emit(node.name);
writeTrailingSemicolon();
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/factory/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ import {
ReadonlyKeyword,
RelationalOperator,
RelationalOperatorOrHigher,
SetAccessorDeclaration,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
SetAccessorDeclaration, // used in JSDoc
setOriginalNode,
setParent,
setStartsOnNewLine,
Expand Down
1 change: 1 addition & 0 deletions src/compiler/moduleNameResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ interface PackageJson extends PackageJsonPathFields {
version?: string;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
function readPackageJsonField<TMatch, K extends MatchingKeys<PackageJson, string | undefined>>(jsonContent: PackageJson, fieldName: K, typeOfTag: "string", state: ModuleResolutionState): PackageJson[K] | undefined;
function readPackageJsonField<K extends MatchingKeys<PackageJson, object | undefined>>(jsonContent: PackageJson, fieldName: K, typeOfTag: "object", state: ModuleResolutionState): PackageJson[K] | undefined;
function readPackageJsonField<K extends keyof PackageJson>(jsonContent: PackageJson, fieldName: K, typeOfTag: "string" | "object", state: ModuleResolutionState): PackageJson[K] | undefined {
Expand Down
1 change: 1 addition & 0 deletions src/compiler/watchPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export interface ProgramHost<T extends BuilderProgram> {
*
* @internal
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export interface ProgramHost<T extends BuilderProgram> {
// TODO: GH#18217 Optional methods are frequently asserted
createDirectory?(path: string): void;
Expand Down
1 change: 1 addition & 0 deletions src/harness/collectionsImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export class Metadata {
public get size(): number {
if (this._size === -1 || (this._parent && this._parent._version !== this._parentVersion)) {
let size = 0;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
for (const _ in this._map) size++;
this._size = size;
if (this._parent) {
Expand Down
2 changes: 1 addition & 1 deletion src/services/codefixes/fixAddMissingConstraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function addMissingConstraint(changes: textChanges.ChangeTracker, program: Progr
}

function tryGetConstraintFromDiagnosticMessage(messageText: string | DiagnosticMessageChain) {
const [_, constraint] = flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [];
const [, constraint] = flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [];
return constraint;
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/codefixes/fixNaNEquality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, ar
}

function getSuggestion(messageText: string | DiagnosticMessageChain) {
const [_, suggestion] = flattenDiagnosticMessageText(messageText, "\n", 0).match(/'(.*)'/) || [];
const [, suggestion] = flattenDiagnosticMessageText(messageText, "\n", 0).match(/'(.*)'/) || [];
return suggestion;
}
1 change: 0 additions & 1 deletion src/services/refactors/moveToFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
getModuleSpecifier,
} from "../../compiler/moduleSpecifiers";
import {
__String,
AnyImportOrRequireStatement,
append,
ApplicableRefactorInfo,
Expand Down