Skip to content

Commit 4d696f5

Browse files
authored
fix(workspaces): properly setup eslint v9 (#1793)
1 parent 074936a commit 4d696f5

File tree

21 files changed

+233
-102
lines changed

21 files changed

+233
-102
lines changed

.eslintrc.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import pluginJs from '@eslint/js';
2+
import globals from 'globals';
3+
import tseslint from 'typescript-eslint';
4+
5+
/** @type {import('eslint').Linter.Config[]} */
6+
export default [
7+
{ files: ['**/*.{js,mjs,cjs,ts}'] },
8+
{ languageOptions: { globals: globals.browser } },
9+
pluginJs.configs.recommended,
10+
...tseslint.configs.recommended,
11+
{
12+
rules: {
13+
'@typescript-eslint/no-explicit-any': 'warn',
14+
'no-prototype-builtins': 'warn',
15+
'no-useless-escape': 'warn',
16+
'@typescript-eslint/no-non-null-asserted-optional-chain': 'warn',
17+
'@typescript-eslint/no-unsafe-function-type': 'warn',
18+
'@typescript-eslint/no-require-imports': 'warn',
19+
'@typescript-eslint/ban-ts-comment': 'warn',
20+
'no-case-declarations': 'warn',
21+
'@typescript-eslint/no-unused-vars': 'warn',
22+
},
23+
},
24+
];

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
"devDependencies": {
2929
"@commitlint/cli": "^19.3.0",
3030
"@commitlint/config-conventional": "^19.2.2",
31+
"@eslint/eslintrc": "^3.2.0",
32+
"@eslint/js": "^9.17.0",
3133
"@faker-js/faker": "^8.4.0",
3234
"@release-it-plugins/workspaces": "^4.2.0",
3335
"@release-it/conventional-changelog": "^8.0.1",
@@ -40,6 +42,7 @@
4042
"eslint-config-prettier": "^9.1.0",
4143
"eslint-config-turbo": "^2.3.3",
4244
"eslint-plugin-prettier": "^5.1.3",
45+
"globals": "^15.14.0",
4346
"husky": "^9.1.6",
4447
"lint-staged": "^15.2.10",
4548
"npm-run-all": "^4.1.5",
@@ -49,6 +52,7 @@
4952
"tsup": "^8.0.2",
5053
"turbo": "^1.13.3",
5154
"typescript": "^4.7.4",
55+
"typescript-eslint": "^8.19.1",
5256
"vitest": "^0.6.3",
5357
"zx": "^7.2.3"
5458
},

packages/angular/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
pascal,
1818
sanitize,
1919
toObjectString,
20-
VERBS_WITH_BODY,
2120
} from '@orval/core';
2221

2322
const ANGULAR_DEPENDENCIES: GeneratorDependency[] = [

packages/axios/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
pascal,
1818
sanitize,
1919
toObjectString,
20-
VERBS_WITH_BODY,
2120
} from '@orval/core';
2221

2322
const AXIOS_DEPENDENCIES: GeneratorDependency[] = [

packages/core/src/getters/route.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import { camel, sanitize } from '../utils';
1+
import { ServerObject } from 'openapi3-ts/oas31';
22
import { TEMPLATE_TAG_REGEX } from '../constants';
3-
import {
4-
BaseUrlFromConstant,
5-
BaseUrlFromSpec,
6-
ContextSpecs,
7-
NormalizedOutputOptions,
8-
} from '../types';
9-
import { PathItemObject, ServerObject } from 'openapi3-ts/oas31';
3+
import { BaseUrlFromConstant, BaseUrlFromSpec } from '../types';
4+
import { camel, sanitize } from '../utils';
105

116
const TEMPLATE_TAG_IN_PATH_REGEX = /\/([\w]+)(?:\$\{)/g; // all dynamic parts of path
127

packages/core/src/utils/assertion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function isUndefined(x: any): x is undefined {
4848
}
4949

5050
export function isNull(x: any): x is null {
51-
return typeof x === null;
51+
return x === null;
5252
}
5353

5454
export function isSchema(x: any): x is SchemaObject {

packages/core/src/utils/case.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const prep = (s: string, isFill = false, isPascal = false, isUpper = false) => {
7373
s = low.call(s);
7474
}
7575
if (!isFill && !regexps.hole.test(s)) {
76+
// eslint-disable-next-line no-var
7677
var holey = fill(s, ' ');
7778
if (regexps.hole.test(holey)) {
7879
s = holey;
@@ -89,7 +90,7 @@ const lower = (s: string, fillWith: string, isDeapostrophe: boolean) => {
8990
};
9091

9192
// Caches the previously converted strings to improve performance
92-
let pascalMemory: Record<string, string> = {};
93+
const pascalMemory: Record<string, string> = {};
9394

9495
export const pascal = (s: string) => {
9596
if (pascalMemory[s]) {

packages/core/src/utils/path.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Object.entries(basepath).forEach(([propName, propValue]) => {
5050
}
5151
});
5252

53-
let { join, resolve, extname, dirname, basename, isAbsolute } = path;
53+
const { join, resolve, extname, dirname, basename, isAbsolute } = path;
5454
export { join, resolve, extname, dirname, basename, isAbsolute };
5555

5656
/**

packages/hono/src/index.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ import {
44
ClientFooterBuilder,
55
ClientGeneratorsBuilder,
66
ClientHeaderBuilder,
7+
ContextSpecs,
8+
generateMutatorImports,
79
GeneratorDependency,
10+
GeneratorImport,
11+
GeneratorMutator,
812
GeneratorOptions,
913
GeneratorVerbOptions,
1014
getFileInfo,
11-
pascal,
12-
upath,
13-
kebab,
14-
ContextSpecs,
15-
NormalizedOutputOptions,
16-
GeneratorImport,
1715
getOrvalGeneratedTypes,
1816
jsDoc,
19-
generateMutatorImports,
20-
GeneratorMutator,
17+
kebab,
2118
NormalizedMutator,
19+
NormalizedOutputOptions,
20+
pascal,
21+
upath,
2222
} from '@orval/core';
23-
import { getRoute } from './route';
24-
import fs from 'fs-extra';
2523
import { generateZod } from '@orval/zod';
24+
import fs from 'fs-extra';
2625
import { InfoObject } from 'openapi3-ts/oas30';
26+
import { getRoute } from './route';
2727

2828
const HONO_DEPENDENCIES: GeneratorDependency[] = [
2929
{
@@ -164,7 +164,7 @@ const getZvalidatorImports = (
164164
verbOption: GeneratorVerbOptions,
165165
isHonoValidator: boolean,
166166
) => {
167-
let imports = [];
167+
const imports = [];
168168

169169
if (verbOption.headers) {
170170
imports.push(`${verbOption.operationName}Header`);
@@ -561,7 +561,7 @@ const generateContext = async (
561561

562562
const imps = verbs
563563
.flatMap((verb) => {
564-
let imports: GeneratorImport[] = [];
564+
const imports: GeneratorImport[] = [];
565565
if (verb.params.length) {
566566
imports.push(...verb.params.map((param) => param.imports).flat());
567567
}
@@ -614,7 +614,7 @@ const generateContext = async (
614614

615615
const imps = Object.values(verbOptions)
616616
.flatMap((verb) => {
617-
let imports: GeneratorImport[] = [];
617+
const imports: GeneratorImport[] = [];
618618
if (verb.params.length) {
619619
imports.push(...verb.params.map((param) => param.imports).flat());
620620
}
@@ -661,9 +661,7 @@ const generateZodFiles = async (
661661
output: NormalizedOutputOptions,
662662
context: ContextSpecs,
663663
) => {
664-
const { pathWithoutExtension, extension, dirname, filename } = getFileInfo(
665-
output.target,
666-
);
664+
const { extension, dirname, filename } = getFileInfo(output.target);
667665

668666
const header = getHeader(
669667
output.override.header,

0 commit comments

Comments
 (0)