Skip to content

Commit 4b90df7

Browse files
authored
Merge pull request #172 from hyperweb-io/eslint9
Migrate to eslint9
2 parents 3b4cf15 + dabe057 commit 4b90df7

File tree

15 files changed

+324
-249
lines changed

15 files changed

+324
-249
lines changed

.eslintignore

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

.eslintrc.json

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

eslint.config.mjs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { defineConfig, globalIgnores } from "eslint/config";
2+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
3+
import simpleImportSort from "eslint-plugin-simple-import-sort";
4+
import unusedImports from "eslint-plugin-unused-imports";
5+
import globals from "globals";
6+
import tsParser from "@typescript-eslint/parser";
7+
import path from "node:path";
8+
import { fileURLToPath } from "node:url";
9+
import js from "@eslint/js";
10+
import { FlatCompat } from "@eslint/eslintrc";
11+
12+
const __filename = fileURLToPath(import.meta.url);
13+
const __dirname = path.dirname(__filename);
14+
const compat = new FlatCompat({
15+
baseDirectory: __dirname,
16+
recommendedConfig: js.configs.recommended,
17+
allConfig: js.configs.all
18+
});
19+
20+
export default defineConfig([globalIgnores(["**/node_modules/", "**/dist/"]), {
21+
extends: compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"),
22+
23+
plugins: {
24+
"@typescript-eslint": typescriptEslint,
25+
"simple-import-sort": simpleImportSort,
26+
"unused-imports": unusedImports,
27+
},
28+
29+
languageOptions: {
30+
globals: {
31+
...globals.browser,
32+
...globals.node,
33+
...globals.jest,
34+
},
35+
36+
parser: tsParser,
37+
ecmaVersion: "latest",
38+
sourceType: "module",
39+
},
40+
41+
rules: {
42+
indent: "off",
43+
44+
quotes: ["error", "single", {
45+
avoidEscape: true,
46+
allowTemplateLiterals: true,
47+
}],
48+
49+
"quote-props": ["error", "as-needed"],
50+
semi: ["error", "always"],
51+
"simple-import-sort/imports": 1,
52+
"simple-import-sort/exports": 1,
53+
"unused-imports/no-unused-imports": 1,
54+
55+
"@typescript-eslint/no-unused-vars": [1, {
56+
argsIgnorePattern: "React|res|next|^_",
57+
}],
58+
59+
"@typescript-eslint/no-explicit-any": 0,
60+
"@typescript-eslint/no-var-requires": 0,
61+
"no-console": 0,
62+
"@typescript-eslint/ban-ts-comment": 0,
63+
"prefer-const": 0,
64+
"no-case-declarations": 0,
65+
"no-implicit-globals": 0,
66+
"@typescript-eslint/no-unsafe-declaration-merging": 0,
67+
},
68+
}]);

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
"@types/jest-in-case": "^1.0.2",
2020
"@types/mkdirp": "1.0.2",
2121
"@types/node": "^20.12.7",
22-
"@typescript-eslint/eslint-plugin": "^7.10.0",
23-
"@typescript-eslint/parser": "^7.10.0",
22+
"@typescript-eslint/eslint-plugin": "^8.35.0",
23+
"@typescript-eslint/parser": "^8.35.0",
2424
"copyfiles": "^2.4.1",
25-
"eslint": "^8.56.0",
25+
"eslint": "^9.30.0",
2626
"eslint-config-prettier": "^10.1.5",
2727
"eslint-plugin-simple-import-sort": "^12.1.0",
2828
"eslint-plugin-unused-imports": "^4.0.0",
2929
"glob": "^10",
30+
"globals": "^16.2.0",
3031
"jest": "^29.6.2",
3132
"jest-in-case": "^1.0.2",
3233
"lerna": "^6",

packages/ast/.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/ts-codegen/.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/ts-codegen/scripts/cmds.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const fs = require('fs');
2-
const path = require('path');
3-
const { globSync: glob } = require('glob');
4-
const Case = require('case');
5-
const srcDir = path.resolve(`${__dirname}/../src/commands`);
1+
import { kebab, snake } from 'case';
2+
import { writeFileSync } from 'fs';
3+
import { globSync as glob } from 'glob';
4+
import { basename, resolve } from 'path';
5+
6+
const srcDir = resolve(`${__dirname}/../src/commands`);
67

78
interface PathObj {
89
name: string;
@@ -15,9 +16,9 @@ const paths: PathObj[] = glob(`${srcDir}/**.[j|t]s`)
1516
.map((file: string) => {
1617
const [, name] = file.match(/\/(.*)\.[j|t]s$/);
1718
return {
18-
name: path.basename(name),
19-
param: Case.kebab(path.basename(name)),
20-
safe: Case.snake(path.basename(name)),
19+
name: basename(name),
20+
param: kebab(basename(name)),
21+
safe: snake(basename(name)),
2122
path: file
2223
.replace(srcDir, './commands')
2324
.replace(/\.js$/, '')
@@ -43,4 +44,4 @@ ${paths
4344
4445
`;
4546

46-
fs.writeFileSync(`${__dirname}/../src/cmds.ts`, out);
47+
writeFileSync(`${__dirname}/../src/cmds.ts`, out);

packages/ts-codegen/src/commands/create-boilerplate.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { MinimistArgs } from '@cosmwasm/ts-codegen-types';
22
import dargs from 'dargs';
3+
import { lstatSync, readFileSync, writeFileSync } from 'fs';
4+
import { globSync as glob } from 'glob';
5+
import * as path from 'path';
36
import * as shell from 'shelljs';
47

58
import { prompt } from '../utils/prompt';
69

7-
const { globSync: glob } = require('glob');
8-
const fs = require('fs');
9-
const path = require('path');
10-
1110
const repo = 'https://github.com/hyperweb-io/ts-codegen-module-boilerplate';
1211
export default async (argv: MinimistArgs) => {
1312
if (!shell.which('git')) {
@@ -29,7 +28,7 @@ export default async (argv: MinimistArgs) => {
2928
shell.exec(`git clone ${repo} ${name}`);
3029
shell.cd(name);
3130

32-
const questions = JSON.parse(fs.readFileSync(`.questions.json`));
31+
const questions = JSON.parse(readFileSync(`.questions.json`, 'utf-8'));
3332

3433
const fullname = shell
3534
.exec('git config --global user.name', { silent: true })
@@ -88,9 +87,9 @@ export default async (argv: MinimistArgs) => {
8887

8988
for (let i = 0; i < files.length; i++) {
9089
const templateFile = files[i];
91-
if (fs.lstatSync(templateFile).isDirectory()) continue;
90+
if (lstatSync(templateFile).isDirectory()) continue;
9291

93-
let content = fs.readFileSync(templateFile).toString();
92+
let content = readFileSync(templateFile, 'utf-8');
9493
if (
9594
path.basename(templateFile) === 'LICENSE' &&
9695
license.__LICENSE__ === 'closed'
@@ -129,7 +128,7 @@ Proprietary and confidential`;
129128
// content = `# ${results.__MODULENAME__}`;
130129
// }
131130

132-
fs.writeFileSync(templateFile, content);
131+
writeFileSync(templateFile, content);
133132
}
134133

135134
shell.rm('-rf', '.git');

packages/ts-codegen/src/commands/install.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default async (argv: MinimistArgs) => {
3535
let thisPackage;
3636
try {
3737
thisPackage = JSON.parse(readFileSync(join(cur, 'package.json'), 'utf-8'));
38-
} catch (e) {
38+
} catch {
3939
throw new Error('make sure you are inside of a telescope package!');
4040
}
4141

packages/ts-codegen/src/file.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env node
22
import { readFileSync } from 'fs';
3+
import minimist from 'minimist';
34

45
import { cli } from './cli';
56
import { prompt } from './utils/prompt';
67

7-
const argv = require('minimist')(process.argv.slice(2));
8+
const argv = minimist(process.argv.slice(2));
89

910
const question = [
1011
{

packages/ts-codegen/src/plugins/react-query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class ReactQueryPlugin extends BuilderPluginBase<RenderOptions> {
5656

5757
const clientImports = [];
5858

59-
QueryMsg && clientImports.push(QueryClient);
59+
if (QueryMsg) clientImports.push(QueryClient);
6060

6161
// check that there are commands within the exec msg
6262
const shouldGenerateMutationHooks =

packages/ts-codegen/src/ts-codegen.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env node
2+
import minimist from 'minimist';
3+
24
import { cli } from './cli';
35

4-
let argv = require('minimist')(process.argv.slice(2));
6+
let argv = minimist(process.argv.slice(2));
57

68
(async () => {
79
await cli(argv);

packages/ts-codegen/src/utils/cleanse.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ export const cleanFor = (str: string) => {
66
2. ONLY if you find capitals after, modify it
77
*/
88

9-
// When we upgrade to eslint v9, we can remove this exception and
10-
// rely on allExceptWhileTrue (https://eslint.org/docs/latest/rules/no-constant-condition)
11-
// eslint-disable-next-line no-constant-condition
129
while (true) {
1310
const match = str.match(/(_[a-z]+_)[A-Z]/);
1411
if (!match) break;

packages/types/.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)