mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 13:48:46 -05:00
Fix up linting, make lint clean
Now that we are modules, there's no reason to ban multiple namespaces per file; each file is its own scope and declaring a namespace won't merge it into any other files.
This commit is contained in:
@@ -87,7 +87,6 @@
|
||||
"local/simple-indent": "error",
|
||||
"local/debug-assert": "error",
|
||||
"local/no-keywords": "error",
|
||||
"local/one-namespace-per-file": "error",
|
||||
|
||||
// eslint-plugin-import
|
||||
"import/no-extraneous-dependencies": ["error", { "optionalDependencies": false }],
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
const { AST_NODE_TYPES, TSESTree } = require("@typescript-eslint/utils");
|
||||
const { createRule } = require("./utils.cjs");
|
||||
|
||||
module.exports = createRule({
|
||||
name: "one-namespace-per-file",
|
||||
meta: {
|
||||
docs: {
|
||||
description: `Limits each file to having at most one top-level namespace declaration`,
|
||||
recommended: "error",
|
||||
},
|
||||
messages: {
|
||||
excessNamespaceError: `All but one of these namespaces should be moved into separate files.`,
|
||||
},
|
||||
schema: [],
|
||||
type: "problem",
|
||||
},
|
||||
defaultOptions: [],
|
||||
|
||||
create(context) {
|
||||
/** @type {(node: TSESTree.Node) => node is TSESTree.TSModuleDeclaration} */
|
||||
const isNamespaceDeclaration = (node) => node.type === AST_NODE_TYPES.TSModuleDeclaration;
|
||||
|
||||
/** @type {(node: TSESTree.Program) => void} */
|
||||
const checkSourceFile = (node) => {
|
||||
if (context.getFilename().endsWith(".d.ts")) {
|
||||
return;
|
||||
}
|
||||
const members = node.body;
|
||||
const namespaces = members.filter(isNamespaceDeclaration);
|
||||
if (namespaces.length <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
namespaces.forEach(n => {
|
||||
context.report({
|
||||
messageId: "excessNamespaceError", node: n
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
Program: checkSourceFile,
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -7,14 +7,13 @@ import {
|
||||
|
||||
/* Tracing events for the compiler. */
|
||||
|
||||
// eslint-disable-line local/one-namespace-per-file
|
||||
// should be used as tracing?.___
|
||||
/** @internal */
|
||||
export let tracing: typeof tracingEnabled | undefined;
|
||||
// enable the above using startTracing()
|
||||
|
||||
// `tracingEnabled` should never be used directly, only through the above
|
||||
namespace tracingEnabled { // eslint-disable-line local/one-namespace-per-file
|
||||
namespace tracingEnabled {
|
||||
type Mode = "project" | "build" | "server";
|
||||
|
||||
let fs: typeof import("fs");
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as ts from "./_namespaces/ts";
|
||||
import * as Harness from "./_namespaces/Harness";
|
||||
|
||||
// eslint-disable-line local/one-namespace-per-file
|
||||
interface FileInformation {
|
||||
contents?: string;
|
||||
contentsPath?: string;
|
||||
|
||||
@@ -2079,7 +2079,7 @@ export class ProjectService {
|
||||
configFileName: configFileName(),
|
||||
projectType: project instanceof ExternalProject ? "external" : "configured",
|
||||
languageServiceEnabled: project.languageServiceEnabled,
|
||||
version: version, // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier
|
||||
version,
|
||||
};
|
||||
this.eventHandler({ eventName: ProjectInfoTelemetryEvent, data });
|
||||
|
||||
|
||||
@@ -2953,7 +2953,7 @@ export class Session<TMessage = string> implements EventSender {
|
||||
|
||||
private handlers = new Map(getEntries<(request: protocol.Request) => HandlerResponse>({
|
||||
[CommandNames.Status]: () => {
|
||||
const response: protocol.StatusResponseBody = { version: version }; // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier
|
||||
const response: protocol.StatusResponseBody = { version };
|
||||
return this.requiredResponse(response);
|
||||
},
|
||||
[CommandNames.OpenExternalProject]: (request: protocol.OpenExternalProjectRequest) => {
|
||||
|
||||
@@ -75,8 +75,8 @@ declare global {
|
||||
declare global {
|
||||
// Module transform: converted from ambient declaration
|
||||
/** @internal */
|
||||
var Promise: PromiseConstructor;
|
||||
} // eslint-disable-line no-var
|
||||
var Promise: PromiseConstructor; // eslint-disable-line no-var
|
||||
}
|
||||
|
||||
// These utilities are common to multiple language service features.
|
||||
//#region
|
||||
|
||||
@@ -249,7 +249,7 @@ export function start() {
|
||||
let totalPassing = 0;
|
||||
const startDate = new Date();
|
||||
|
||||
const progressBars = new ProgressBars({ noColors: noColors }); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier
|
||||
const progressBars = new ProgressBars({ noColors });
|
||||
const progressUpdateInterval = 1 / progressBars._options.width;
|
||||
let nextProgress = progressUpdateInterval;
|
||||
|
||||
@@ -259,7 +259,7 @@ export function start() {
|
||||
let closedWorkers = 0;
|
||||
for (let i = 0; i < workerCount; i++) {
|
||||
// TODO: Just send the config over the IPC channel or in the command line arguments
|
||||
const config: TestConfig = { light: lightMode, listenForWork: true, runUnitTests: runUnitTests, stackTraceLimit: stackTraceLimit, timeout: globalTimeout }; // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier
|
||||
const config: TestConfig = { light: lightMode, listenForWork: true, runUnitTests, stackTraceLimit, timeout: globalTimeout };
|
||||
const configPath = ts.combinePaths(taskConfigsFolder, `task-config${i}.json`);
|
||||
IO.writeFile(configPath, JSON.stringify(config));
|
||||
const worker: Worker = {
|
||||
@@ -558,8 +558,7 @@ export function start() {
|
||||
failedTestReporter = new FailedTestReporter(replayRunner, {
|
||||
reporterOptions: {
|
||||
file: path.resolve(".failed-tests"),
|
||||
keepFailed: keepFailed // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier
|
||||
// eslint-disable-line @typescript-eslint/no-unnecessary-qualifier
|
||||
keepFailed,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user