Skip to content

Migrate to eslint9 #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

47 changes: 0 additions & 47 deletions .eslintrc.json

This file was deleted.

68 changes: 68 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { defineConfig, globalIgnores } from "eslint/config";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import unusedImports from "eslint-plugin-unused-imports";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default defineConfig([globalIgnores(["**/node_modules/", "**/dist/"]), {
extends: compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"),

plugins: {
"@typescript-eslint": typescriptEslint,
"simple-import-sort": simpleImportSort,
"unused-imports": unusedImports,
},

languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest,
},

parser: tsParser,
ecmaVersion: "latest",
sourceType: "module",
},

rules: {
indent: "off",

quotes: ["error", "single", {
avoidEscape: true,
allowTemplateLiterals: true,
}],

"quote-props": ["error", "as-needed"],
semi: ["error", "always"],
"simple-import-sort/imports": 1,
"simple-import-sort/exports": 1,
"unused-imports/no-unused-imports": 1,

"@typescript-eslint/no-unused-vars": [1, {
argsIgnorePattern: "React|res|next|^_",
}],

"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-var-requires": 0,
"no-console": 0,
"@typescript-eslint/ban-ts-comment": 0,
"prefer-const": 0,
"no-case-declarations": 0,
"no-implicit-globals": 0,
"@typescript-eslint/no-unsafe-declaration-merging": 0,
},
}]);
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
"@types/jest-in-case": "^1.0.2",
"@types/mkdirp": "1.0.2",
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0",
"@typescript-eslint/eslint-plugin": "^8.35.0",
"@typescript-eslint/parser": "^8.35.0",
"copyfiles": "^2.4.1",
"eslint": "^8.56.0",
"eslint": "^9.30.0",
"eslint-config-prettier": "^10.1.5",
"eslint-plugin-simple-import-sort": "^12.1.0",
"eslint-plugin-unused-imports": "^4.0.0",
"glob": "^10",
"globals": "^16.2.0",
"jest": "^29.6.2",
"jest-in-case": "^1.0.2",
"lerna": "^6",
Expand Down
1 change: 0 additions & 1 deletion packages/ast/.eslintignore

This file was deleted.

1 change: 0 additions & 1 deletion packages/ts-codegen/.eslintignore

This file was deleted.

19 changes: 10 additions & 9 deletions packages/ts-codegen/scripts/cmds.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const fs = require('fs');
const path = require('path');
const { globSync: glob } = require('glob');
const Case = require('case');
const srcDir = path.resolve(`${__dirname}/../src/commands`);
import { kebab, snake } from 'case';
import { writeFileSync } from 'fs';
import { globSync as glob } from 'glob';
import { basename, resolve } from 'path';

const srcDir = resolve(`${__dirname}/../src/commands`);

interface PathObj {
name: string;
Expand All @@ -15,9 +16,9 @@ const paths: PathObj[] = glob(`${srcDir}/**.[j|t]s`)
.map((file: string) => {
const [, name] = file.match(/\/(.*)\.[j|t]s$/);
return {
name: path.basename(name),
param: Case.kebab(path.basename(name)),
safe: Case.snake(path.basename(name)),
name: basename(name),
param: kebab(basename(name)),
safe: snake(basename(name)),
path: file
.replace(srcDir, './commands')
.replace(/\.js$/, '')
Expand All @@ -43,4 +44,4 @@ ${paths

`;

fs.writeFileSync(`${__dirname}/../src/cmds.ts`, out);
writeFileSync(`${__dirname}/../src/cmds.ts`, out);
15 changes: 7 additions & 8 deletions packages/ts-codegen/src/commands/create-boilerplate.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { MinimistArgs } from '@cosmwasm/ts-codegen-types';
import dargs from 'dargs';
import { lstatSync, readFileSync, writeFileSync } from 'fs';
import { globSync as glob } from 'glob';
import * as path from 'path';
import * as shell from 'shelljs';

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

const { globSync: glob } = require('glob');
const fs = require('fs');
const path = require('path');

const repo = 'https://github.com/hyperweb-io/ts-codegen-module-boilerplate';
export default async (argv: MinimistArgs) => {
if (!shell.which('git')) {
Expand All @@ -29,7 +28,7 @@ export default async (argv: MinimistArgs) => {
shell.exec(`git clone ${repo} ${name}`);
shell.cd(name);

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

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

for (let i = 0; i < files.length; i++) {
const templateFile = files[i];
if (fs.lstatSync(templateFile).isDirectory()) continue;
if (lstatSync(templateFile).isDirectory()) continue;

let content = fs.readFileSync(templateFile).toString();
let content = readFileSync(templateFile, 'utf-8');
if (
path.basename(templateFile) === 'LICENSE' &&
license.__LICENSE__ === 'closed'
Expand Down Expand Up @@ -129,7 +128,7 @@ Proprietary and confidential`;
// content = `# ${results.__MODULENAME__}`;
// }

fs.writeFileSync(templateFile, content);
writeFileSync(templateFile, content);
}

shell.rm('-rf', '.git');
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-codegen/src/commands/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default async (argv: MinimistArgs) => {
let thisPackage;
try {
thisPackage = JSON.parse(readFileSync(join(cur, 'package.json'), 'utf-8'));
} catch (e) {
} catch {
throw new Error('make sure you are inside of a telescope package!');
}

Expand Down
3 changes: 2 additions & 1 deletion packages/ts-codegen/src/file.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env node
import { readFileSync } from 'fs';
import minimist from 'minimist';

import { cli } from './cli';
import { prompt } from './utils/prompt';

const argv = require('minimist')(process.argv.slice(2));
const argv = minimist(process.argv.slice(2));

const question = [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-codegen/src/plugins/react-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class ReactQueryPlugin extends BuilderPluginBase<RenderOptions> {

const clientImports = [];

QueryMsg && clientImports.push(QueryClient);
if (QueryMsg) clientImports.push(QueryClient);

// check that there are commands within the exec msg
const shouldGenerateMutationHooks =
Expand Down
4 changes: 3 additions & 1 deletion packages/ts-codegen/src/ts-codegen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env node
import minimist from 'minimist';

import { cli } from './cli';

let argv = require('minimist')(process.argv.slice(2));
let argv = minimist(process.argv.slice(2));

(async () => {
await cli(argv);
Expand Down
3 changes: 0 additions & 3 deletions packages/ts-codegen/src/utils/cleanse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ export const cleanFor = (str: string) => {
2. ONLY if you find capitals after, modify it
*/

// When we upgrade to eslint v9, we can remove this exception and
// rely on allExceptWhileTrue (https://eslint.org/docs/latest/rules/no-constant-condition)
// eslint-disable-next-line no-constant-condition
while (true) {
const match = str.match(/(_[a-z]+_)[A-Z]/);
if (!match) break;
Expand Down
1 change: 0 additions & 1 deletion packages/types/.eslintignore

This file was deleted.

Loading