Skip to content

Commit

Permalink
Migrate eslint 9
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeguerin committed Sep 13, 2024
1 parent 2602282 commit 9f1b8ef
Show file tree
Hide file tree
Showing 45 changed files with 83 additions and 125 deletions.
9 changes: 3 additions & 6 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @ts-check
import eslint from "@eslint/js";
import deprecation from "eslint-plugin-deprecation";
import reactHooks from "eslint-plugin-react-hooks";
import unicorn from "eslint-plugin-unicorn";
import vitest from "eslint-plugin-vitest";
Expand Down Expand Up @@ -76,10 +75,8 @@ const allFilesConfig = tsEslint.config({
export function getTypeScriptProjectRules(root) {
return tsEslint.config({
files: ["**/*.ts", "**/*.tsx"],
ignores: ["packages/http-client-csharp/**/*"], // Ignore isolated modules
plugins: {
deprecation,
},
ignores: ["**/packages/http-client-csharp/**/*", "**/packages/http-client-java/**/*"], // Ignore isolated modules
plugins: {},
languageOptions: {
parserOptions: {
project: "./tsconfig.json",
Expand All @@ -89,7 +86,7 @@ export function getTypeScriptProjectRules(root) {
rules: {
// Only put rules here that need typescript project information
"@typescript-eslint/no-floating-promises": "error",
"deprecation/deprecation": ["warn"],
"@typescript-eslint/no-deprecated": "warn",
},
});
}
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@
"devDependencies": {
"@chronus/chronus": "^0.12.1",
"@chronus/github": "^0.4.3",
"@eslint/js": "^8.57.0",
"@microsoft/api-extractor": "^7.47.8",
"@eslint/js": "^9.10.0",
"@microsoft/api-extractor": "^7.47.9",
"@octokit/core": "^6.1.2",
"@octokit/plugin-paginate-graphql": "^5.2.2",
"@octokit/plugin-rest-endpoint-methods": "^13.2.4",
"@pnpm/find-workspace-packages": "^6.0.9",
"@types/micromatch": "^4.0.9",
"@types/node": "~22.5.4",
"@typescript-eslint/parser": "^7.17.0",
"@typescript-eslint/utils": "^7.17.0",
"@typescript-eslint/parser": "^8.5.0",
"@typescript-eslint/utils": "^8.5.0",
"@vitest/coverage-v8": "^2.1.0",
"c8": "^10.1.2",
"cspell": "^8.14.2",
"eslint": "^8.57.0",
"eslint": "^9.10.0",
"eslint-plugin-deprecation": "^3.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-unicorn": "^54.0.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-react-hooks": "^5.1.0-rc-94e652d5-20240912",
"eslint-plugin-unicorn": "^55.0.0",
"eslint-plugin-vitest": "^0.5.4",
"micromatch": "^4.0.8",
"picocolors": "~1.1.0",
Expand Down
1 change: 0 additions & 1 deletion packages/bundler/src/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export async function watchTypeSpecBundle(
},
});

// eslint-disable-next-line @typescript-eslint/no-misused-promises
watcher.on("event", async (event) => {
switch (event.code) {
case "BUNDLE_START":
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/src/core/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5285,7 +5285,7 @@ export function createChecker(program: Program): Checker {
const defaultValue = checkDefaultValue(prop.default, type.type);
if (defaultValue !== null) {
type.defaultValue = defaultValue;
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
type.default = checkLegacyDefault(prop.default);
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/compiler/src/core/cli/actions/compile/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ function logProgramResult(
console.log(); // Insert a newline

if (program.emitters.length === 0 && !program.compilerOptions.noEmit) {
// eslint-disable-next-line no-console
log(
"No emitter was configured, no output was generated. Use `--emit <emitterName>` to pick emitter or specify it in the TypeSpec config."
);
Expand Down
1 change: 0 additions & 1 deletion packages/compiler/src/core/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export * from "./projected-names-utils.js";

export {
explainStringTemplateNotSerializable,
// eslint-disable-next-line deprecation/deprecation
stringTemplateToString,
} from "./string-template-utils.js";
export { printIdentifier as formatIdentifier, printIdentifier } from "./syntax-utils.js";
Expand Down
2 changes: 0 additions & 2 deletions packages/compiler/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ export {
type Discriminator,
} from "./intrinsic-type-state.js";
export {
// eslint-disable-next-line deprecation/deprecation
createCadlLibrary,
createLinterRule as createRule,
createTypeSpecLibrary,
defineLinter,
definePackageFlags,
paramMessage,
// eslint-disable-next-line deprecation/deprecation
setCadlNamespace,
setTypeSpecNamespace,
} from "./library.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/src/core/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function getCaller() {
function getCallStack() {
const _prepareStackTrace = Error.prepareStackTrace;
Error.prepareStackTrace = (_, stack) => stack;
const stack = (new Error() as any).stack.slice(1); // eslint-disable-line unicorn/error-message
const stack = (new Error() as any).stack.slice(1);
Error.prepareStackTrace = _prepareStackTrace;
return stack;
}
1 change: 0 additions & 1 deletion packages/compiler/src/core/logger/support-hyperlinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export function supportsHyperlink(stream: NodeJS.WriteStream) {
case "WezTerm":
return version.major >= 20200620;
case "vscode":
// eslint-disable-next-line no-mixed-operators
return version.major > 1 || (version.major === 1 && version.minor >= 72);
// No default
}
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/src/core/path-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ export function getRelativePathFromDirectory(
fromDirectory: string,
to: string,
getCanonicalFileName: GetCanonicalFileName
): string; // eslint-disable-line @typescript-eslint/unified-signatures
): string;
export function getRelativePathFromDirectory(
fromDirectory: string,
to: string,
Expand Down
8 changes: 4 additions & 4 deletions packages/compiler/src/core/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ export async function compile(

let emit = options.emit;
let emitterOptions = options.options;
/* eslint-disable deprecation/deprecation */
/* eslint-disable @typescript-eslint/no-deprecated */
if (options.emitters) {
emit ??= Object.keys(options.emitters);
emitterOptions ??= options.emitters;
}
/* eslint-enable deprecation/deprecation */
/* eslint-enable @typescript-eslint/no-deprecated */

await loadEmitters(basedir, emit ?? [], emitterOptions ?? {});

Expand Down Expand Up @@ -439,7 +439,7 @@ export async function compile(

const libDefinition: TypeSpecLibrary<any> | undefined = entrypoint?.esmExports.$lib;
const metadata = computeLibraryMetadata(module, libDefinition);
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
const linterDef = entrypoint?.esmExports.$linter ?? libDefinition?.linter;
return {
...resolution,
Expand Down Expand Up @@ -899,7 +899,7 @@ export async function compile(
* Resolve compiler options from input options.
*/
function resolveOptions(options: CompilerOptions): CompilerOptions {
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
const outputDir = options.outputDir ?? options.outputPath;
return {
...options,
Expand Down
10 changes: 5 additions & 5 deletions packages/compiler/src/core/projector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export function createProjector(

if (model.templateMapper) {
projectedModel.templateMapper = projectTemplateMapper(model.templateMapper);
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
projectedModel.templateArguments = mutate(projectedModel.templateMapper.args);
}

Expand Down Expand Up @@ -357,7 +357,7 @@ export function createProjector(

if (scalar.templateMapper) {
projectedScalar.templateMapper = projectTemplateMapper(scalar.templateMapper);
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
projectedScalar.templateArguments = mutate(projectedScalar.templateMapper.args);
}

Expand Down Expand Up @@ -423,7 +423,7 @@ export function createProjector(

if (op.templateMapper) {
projectedOp.templateMapper = projectTemplateMapper(op.templateMapper);
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
projectedOp.templateArguments = mutate(projectedOp.templateMapper.args);
}

Expand Down Expand Up @@ -455,7 +455,7 @@ export function createProjector(

if (iface.templateMapper) {
projectedIface.templateMapper = projectTemplateMapper(iface.templateMapper);
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
projectedIface.templateArguments = mutate(projectedIface.templateMapper.args);
}

Expand Down Expand Up @@ -486,7 +486,7 @@ export function createProjector(

if (union.templateMapper) {
projectedUnion.templateMapper = projectTemplateMapper(union.templateMapper);
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
projectedUnion.templateArguments = mutate(projectedUnion.templateMapper.args);
}

Expand Down
4 changes: 1 addition & 3 deletions packages/compiler/src/lib/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ export const $withoutDefaultValues: WithoutDefaultValuesDecorator = (
) => {
// remove all read-only properties from the target type
target.properties.forEach((p) => {
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
delete p.default;
delete p.defaultValue;
});
Expand All @@ -957,7 +957,6 @@ const listPropertiesKey = createStateSymbol("listProperties");
/**
* @deprecated Use the `listsResource` decorator in `@typespec/rest` instead.
*/
// eslint-disable-next-line deprecation/deprecation
export const $list: ListDecorator = (
context: DecoratorContext,
target: Operation,
Expand Down Expand Up @@ -1229,7 +1228,6 @@ export const $withDefaultKeyVisibility: WithDefaultKeyVisibilityDecorator = (
* model Foo {}
* ```
*/
// eslint-disable-next-line deprecation/deprecation
export const $deprecated: DeprecatedDecorator = (
context: DecoratorContext,
target: Type,
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/src/lib/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const $service: ServiceDecorator = (
versionProp
);
if (version.kind === "String") {
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
serviceDetails.version = version.value;
} else {
reportDiagnostic(context.program, {
Expand Down
1 change: 0 additions & 1 deletion packages/compiler/src/lib/tsp-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export const $decorators = {
minValueExclusive: $minValueExclusive,
maxValueExclusive: $maxValueExclusive,
secret: $secret,
// eslint-disable-next-line deprecation/deprecation
list: $list,
tag: $tag,
friendlyName: $friendlyName,
Expand Down
2 changes: 0 additions & 2 deletions packages/compiler/src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,8 @@ function profile<T extends (...args: any) => any>(func: T): T {

return (async (...args: any[]) => {
profileSession!.post("Profiler.enable", () => {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
profileSession!.post("Profiler.start", async () => {
const ret = await func.apply(undefined!, args);
// eslint-disable-next-line @typescript-eslint/no-misused-promises
profileSession!.post("Profiler.stop", async (err, args) => {
if (!err && args.profile) {
await mkdir(profileDir!, { recursive: true });
Expand Down
12 changes: 6 additions & 6 deletions packages/compiler/src/server/serverlib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,28 +210,28 @@ export function createServer(host: ServerHost): Server {
changeNotifications: true,
},
};
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
} else if (params.rootUri) {
workspaceFolders = [
{
name: "<root>",
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
uri: params.rootUri,
path: ensureTrailingDirectorySeparator(
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
await fileService.fileURLToRealPath(params.rootUri)
),
},
];
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
} else if (params.rootPath) {
workspaceFolders = [
{
name: "<root>",
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
uri: compilerHost.pathToFileURL(params.rootPath),
path: ensureTrailingDirectorySeparator(
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
await getNormalizedRealPath(compilerHost, params.rootPath)
),
},
Expand Down
1 change: 0 additions & 1 deletion packages/compiler/src/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ export function resolveRelativeUrlOrPath(base: string, relativeOrAbsolute: strin
* A specially typed version of `Array.isArray` to work around [this issue](https://github.com/microsoft/TypeScript/issues/17002).
*/
export function isArray<T>(
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
arg: T | {}
): arg is T extends readonly any[] ? (unknown extends T ? never : readonly any[]) : any[] {
return Array.isArray(arg);
Expand Down
4 changes: 2 additions & 2 deletions packages/compiler/test/checker/clone-type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ describe("compiler: type cloning", () => {
strictEqual(test.kind, "ModelProperty" as const);
strictEqual(test.type.kind, "Model" as const);
const clone = testHost.program.checker.cloneType(test.type);
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
strictEqual(clone.templateArguments?.length, 2);
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
deepStrictEqual(test.type.templateArguments, clone.templateArguments);
deepStrictEqual(test.type.templateMapper, clone.templateMapper);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/compiler/test/checker/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ describe("compiler: models", () => {
`
);
const { foo } = (await testHost.compile("main.tsp")) as { foo: ModelProperty };
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
expect({ ...foo.default }).toMatchObject(expectedValue);
});

Expand All @@ -224,7 +224,7 @@ describe("compiler: models", () => {
`
);
const { foo } = (await testHost.compile("main.tsp")) as { foo: ModelProperty };
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
deepStrictEqual(foo.default, undefined);
});

Expand All @@ -236,7 +236,7 @@ describe("compiler: models", () => {
`
);
const { foo } = (await testHost.compile("main.tsp")) as { foo: ModelProperty };
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
deepStrictEqual(foo.default, undefined);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("compiler: stringTemplateToString (deprecated)", () => {
};

strictEqual(value.type.kind, "StringTemplate");
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
return stringTemplateToString(value.type);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/compiler/test/projection/projector-identity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,9 @@ describe("compiler: projector: Identity", () => {
ok(projected.templateMapper !== original.templateMapper);
ok(projected.templateMapper.args !== original.templateMapper.args);
ok(projected.templateMapper.map !== original.templateMapper.map);
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
ok(projected.templateArguments !== original.templateArguments);
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
ok(projected.templateArguments === projected.templateMapper.args);
strictEqual(projected.templateMapper.args.length, original.templateMapper.args.length);
strictEqual(projected.templateMapper.map.size, original.templateMapper.map.size);
Expand Down
10 changes: 5 additions & 5 deletions packages/eslint-plugin-typespec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@
},
"devDependencies": {
"@types/node": "~22.5.4",
"@typescript-eslint/parser": "^7.17.0",
"@typescript-eslint/rule-tester": "^7.17.0",
"@typescript-eslint/types": "^7.17.0",
"@typescript-eslint/parser": "^8.5.0",
"@typescript-eslint/rule-tester": "^8.5.0",
"@typescript-eslint/types": "^8.5.0",
"@vitest/coverage-v8": "^2.1.0",
"@vitest/ui": "^2.1.0",
"c8": "^10.1.2",
"eslint": "^8.57.0",
"eslint": "^9.10.0",
"rimraf": "~6.0.1",
"typescript": "~5.6.2",
"vitest": "^2.1.0"
},
"dependencies": {
"@typescript-eslint/utils": "^7.17.0"
"@typescript-eslint/utils": "^8.5.0"
}
}
Loading

0 comments on commit 9f1b8ef

Please sign in to comment.