Skip to content

Commit 23156cb

Browse files
authored
Error on unused eslint directives, reenable lost eslint rules (microsoft#57350)
1 parent a773703 commit 23156cb

File tree

7 files changed

+13
-10
lines changed

7 files changed

+13
-10
lines changed

.eslintrc.json

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@
8282
{ "selector": "property", "format": null }
8383
],
8484

85+
"@typescript-eslint/unified-signatures": "error",
86+
"no-unused-expressions": "off",
87+
"@typescript-eslint/no-unused-expressions": ["error", { "allowTernary": true }],
88+
8589
// Rules enabled in typescript-eslint configs that are not applicable here
8690
"@typescript-eslint/ban-ts-comment": "off",
8791
"@typescript-eslint/class-literal-property-style": "off",

Herebyfile.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ export const lint = task({
517517
`${folder}/.eslintcache`,
518518
"--format",
519519
formatter,
520+
"--report-unused-disable-directives",
520521
];
521522

522523
if (cmdLineOptions.fix) {

scripts/build/options.mjs

-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const parsed = minimist(process.argv.slice(2), {
77
boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci", "bundle", "typecheck", "lint", "coverage"],
88
string: ["browser", "tests", "break", "host", "reporter", "stackTraceLimit", "timeout", "shards", "shardId"],
99
alias: {
10-
/* eslint-disable quote-props */
1110
b: "browser",
1211
i: ["inspect", "inspect-brk", "break", "debug", "debug-brk"],
1312
t: ["tests", "test"],
@@ -17,7 +16,6 @@ const parsed = minimist(process.argv.slice(2), {
1716
skippercent: "skipPercent",
1817
w: "workers",
1918
f: "fix",
20-
/* eslint-enable quote-props */
2119
},
2220
default: {
2321
soft: false,

src/compiler/moduleNameResolver.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ interface PackageJson extends PackageJsonPathFields {
349349
}
350350

351351
function readPackageJsonField<K extends MatchingKeys<PackageJson, string | undefined>>(jsonContent: PackageJson, fieldName: K, typeOfTag: "string", state: ModuleResolutionState): PackageJson[K] | undefined;
352-
function readPackageJsonField<K extends MatchingKeys<PackageJson, object | undefined>>(jsonContent: PackageJson, fieldName: K, typeOfTag: "object", state: ModuleResolutionState): PackageJson[K] | undefined;
352+
function readPackageJsonField<K extends MatchingKeys<PackageJson, object | undefined>>(jsonContent: PackageJson, fieldName: K, typeOfTag: "object", state: ModuleResolutionState): PackageJson[K] | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
353353
function readPackageJsonField<K extends keyof PackageJson>(jsonContent: PackageJson, fieldName: K, typeOfTag: "string" | "object", state: ModuleResolutionState): PackageJson[K] | undefined {
354354
if (!hasProperty(jsonContent, fieldName)) {
355355
if (state.traceEnabled) {
@@ -1327,7 +1327,7 @@ export function createModuleResolutionCache(
13271327
getCanonicalFileName: (s: string) => string,
13281328
options?: CompilerOptions,
13291329
packageJsonInfoCache?: PackageJsonInfoCache,
1330-
optionsToRedirectsKey?: Map<CompilerOptions, RedirectsCacheKey>,
1330+
optionsToRedirectsKey?: Map<CompilerOptions, RedirectsCacheKey>, // eslint-disable-line @typescript-eslint/unified-signatures
13311331
): ModuleResolutionCache;
13321332
export function createModuleResolutionCache(
13331333
currentDirectory: string,
@@ -1360,7 +1360,7 @@ export function createTypeReferenceDirectiveResolutionCache(
13601360
getCanonicalFileName: (s: string) => string,
13611361
options?: CompilerOptions,
13621362
packageJsonInfoCache?: PackageJsonInfoCache,
1363-
optionsToRedirectsKey?: Map<CompilerOptions, RedirectsCacheKey>,
1363+
optionsToRedirectsKey?: Map<CompilerOptions, RedirectsCacheKey>, // eslint-disable-line @typescript-eslint/unified-signatures
13641364
): TypeReferenceDirectiveResolutionCache;
13651365
export function createTypeReferenceDirectiveResolutionCache(
13661366
currentDirectory: string,
@@ -1754,7 +1754,7 @@ function tryResolveJSModuleWorker(moduleName: string, initialDir: string, host:
17541754
}
17551755
export function bundlerModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
17561756
/** @internal */
1757-
export function bundlerModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, conditions?: string[]): ResolvedModuleWithFailedLookupLocations;
1757+
export function bundlerModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, conditions?: string[]): ResolvedModuleWithFailedLookupLocations; // eslint-disable-line @typescript-eslint/unified-signatures
17581758
export function bundlerModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, conditions?: string[]): ResolvedModuleWithFailedLookupLocations {
17591759
const containingDirectory = getDirectoryPath(containingFile);
17601760
let extensions = compilerOptions.noDtsResolution ? Extensions.ImplementationFiles : Extensions.TypeScript | Extensions.JavaScript | Extensions.Declaration;

src/compiler/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8697,7 +8697,7 @@ export interface NodeFactory {
86978697
/** @deprecated */ createImportTypeAssertionContainer(clause: AssertClause, multiLine?: boolean): ImportTypeAssertionContainer;
86988698
/** @deprecated */ updateImportTypeAssertionContainer(node: ImportTypeAssertionContainer, clause: AssertClause, multiLine?: boolean): ImportTypeAssertionContainer;
86998699
createImportAttributes(elements: NodeArray<ImportAttribute>, multiLine?: boolean): ImportAttributes;
8700-
/** @internal */ createImportAttributes(elements: NodeArray<ImportAttribute>, multiLine?: boolean, token?: ImportAttributes["token"]): ImportAttributes;
8700+
/** @internal */ createImportAttributes(elements: NodeArray<ImportAttribute>, multiLine?: boolean, token?: ImportAttributes["token"]): ImportAttributes; // eslint-disable-line @typescript-eslint/unified-signatures
87018701
updateImportAttributes(node: ImportAttributes, elements: NodeArray<ImportAttribute>, multiLine?: boolean): ImportAttributes;
87028702
createImportAttribute(name: ImportAttributeName, value: Expression): ImportAttribute;
87038703
updateImportAttribute(node: ImportAttribute, name: ImportAttributeName, value: Expression): ImportAttribute;

src/server/editorServices.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4202,7 +4202,7 @@ export class ProjectService {
42024202

42034203
closeExternalProject(uncheckedFileName: string): void;
42044204
/** @internal */
4205-
closeExternalProject(uncheckedFileName: string, print: boolean): void;
4205+
closeExternalProject(uncheckedFileName: string, print: boolean): void; // eslint-disable-line @typescript-eslint/unified-signatures
42064206
closeExternalProject(uncheckedFileName: string, print?: boolean): void {
42074207
const fileName = toNormalizedPath(uncheckedFileName);
42084208
const configuredProjects = this.externalProjectToConfiguredProjectMap.get(fileName);
@@ -4373,7 +4373,7 @@ export class ProjectService {
43734373

43744374
openExternalProject(proj: protocol.ExternalProject): void;
43754375
/** @internal */
4376-
openExternalProject(proj: protocol.ExternalProject, print: boolean): void;
4376+
openExternalProject(proj: protocol.ExternalProject, print: boolean): void; // eslint-disable-line @typescript-eslint/unified-signatures
43774377
openExternalProject(proj: protocol.ExternalProject, print?: boolean): void {
43784378
const existingExternalProject = this.findExternalProjectByProjectName(proj.projectFileName);
43794379
const existingConfiguredProjects = this.externalProjectToConfiguredProjectMap.get(proj.projectFileName);

src/typingsInstallerCore/typingsInstaller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ export abstract class TypingsInstaller {
526526
protected abstract installWorker(requestId: number, packageNames: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void;
527527
protected abstract sendResponse(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes | WatchTypingLocations): void;
528528
/** @internal */
529-
protected abstract sendResponse(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes | WatchTypingLocations | PackageInstalledResponse | TypesRegistryResponse): void;
529+
protected abstract sendResponse(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes | WatchTypingLocations | PackageInstalledResponse | TypesRegistryResponse): void; // eslint-disable-line @typescript-eslint/unified-signatures
530530
protected readonly latestDistTag = "latest";
531531
}
532532

0 commit comments

Comments
 (0)