Skip to content
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

chore(deps): updated typescript-eslint #1425

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 10 additions & 5 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,29 @@ module.exports = {
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-var-requires": [
"@typescript-eslint/no-require-imports": [
"error",
{
allow: ["/package\\.json$"],
},
],
"@typescript-eslint/no-duplicate-type-constituents": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/no-base-to-string": "error",
"@typescript-eslint/restrict-template-expressions": "error",
"@typescript-eslint/no-useless-template-literals": "error",
"@typescript-eslint/no-unnecessary-template-expression": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/switch-exhaustiveness-check": "error",
"@typescript-eslint/switch-exhaustiveness-check": [
"error",
{ considerDefaultExhaustiveForUnions: true },
],
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/no-restricted-types": "error",
"@typescript-eslint/no-empty-object-type": "error",
"@typescript-eslint/no-unsafe-function-type": "error",
"@typescript-eslint/no-wrapper-object-types": "error",
"@typescript-eslint/consistent-generic-constructors": [
"error",
"type-annotation",
Expand Down
5 changes: 3 additions & 2 deletions bin/tact.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env node

// eslint-disable-next-line @typescript-eslint/no-require-imports
const pkg = require("../package.json");
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const main = require("../dist/node.js");
const meowModule = import("meow");
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { execFileSync } = require("child_process");

void meowModule.then(
Expand Down
2 changes: 1 addition & 1 deletion bin/unboc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-require-imports */

const meowModule = import("meow");
const { decompileAll } = require("@tact-lang/opcode");
Expand Down
2 changes: 1 addition & 1 deletion examples/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function verify(args: {
try {
const data = JSON.parse(args.pkg);
unpacked = fileFormat.parse(data);
} catch (e) {
} catch (_) {
return { ok: false, error: "invalid-package-format" };
}

Expand Down
2 changes: 1 addition & 1 deletion jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const coverage = require("@tact-lang/coverage");

module.exports = async () => {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
"@types/jest": "^29.5.12",
"@types/json-bigint": "^1.0.4",
"@types/node": "^22.5.0",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"ajv-cli": "^5.0.0",
"cross-env": "^7.0.3",
"cspell": "^8.8.3",
Expand Down
6 changes: 3 additions & 3 deletions src/abi/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export const GlobalFunctions: Map<string, AbiFunction> = new Map([
let c: Cell;
try {
c = Cell.fromBase64(str);
} catch (e) {
} catch (_) {
throwCompilationError(`Invalid cell ${str}`, ref);
}

Expand Down Expand Up @@ -445,7 +445,7 @@ export const GlobalFunctions: Map<string, AbiFunction> = new Map([
let c: Cell;
try {
c = Cell.fromBase64(str);
} catch (e) {
} catch (_) {
throwCompilationError(`Invalid slice ${str}`, ref);
}

Expand Down Expand Up @@ -500,7 +500,7 @@ export const GlobalFunctions: Map<string, AbiFunction> = new Map([
let c: Cell;
try {
c = beginCell().storeBuffer(Buffer.from(str)).endCell();
} catch (e) {
} catch (_) {
throwCompilationError(`Invalid slice data ${str}`, ref);
}

Expand Down
2 changes: 1 addition & 1 deletion src/context/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface ILogger {
error: (message: messageType) => void;
}

const logLevelToMethodName: { [key in LogLevel]: keyof ILogger | null } = {
const logLevelToMethodName: Record<LogLevel, keyof ILogger | null> = {
[LogLevel.NONE]: null,
[LogLevel.ERROR]: "error",
[LogLevel.WARN]: "warn",
Expand Down
4 changes: 2 additions & 2 deletions src/func/funcCompile.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ILogger } from "../context/logger";

// Wasm Imports
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const CompilerModule = require("./funcfiftlib.js");
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const FuncFiftLibWasm = require("./funcfiftlib.wasm.js").FuncFiftLibWasm;
const WasmBinary = Buffer.from(FuncFiftLibWasm, "base64");

Expand Down
1 change: 1 addition & 0 deletions src/grammar/next/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ const parseParens = ({ child }: $ast.Parens): Handler<A.AstExpression> => {
};

// has to be an interface because of the way TS handles circular type references
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface Binary extends $ast.Binary<Expression, A.AstBinaryOperation> {}
Copy link
Contributor Author

@Danil42Russia Danil42Russia Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the error I couldn't beat. As a temporary solution, I suppressed it

Copy link
Contributor

@verytactical verytactical Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's completely fine to ignore it here, and you did the right thing.

This "empty" type is a workaround for a buggy implementation of recursive types in TS, and linter has no way to know about it.


type Expression =
Expand Down
16 changes: 8 additions & 8 deletions src/optimizer/associative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class AssociativeRule1 extends AllowableOpRule {
);
const newRight = val;
return util.makeBinaryExpression(op, newLeft, newRight);
} catch (e) {
} catch (_) {
// Do nothing: will exit rule without modifying tree
}
}
Expand Down Expand Up @@ -231,7 +231,7 @@ export class AssociativeRule1 extends AllowableOpRule {
util.makeBinaryExpression(op1, x1, newValNode),
);
return util.makeBinaryExpression(op2, newLeft, x2);
} catch (e) {
} catch (_) {
// Do nothing: will exit rule without modifying tree
}
}
Expand Down Expand Up @@ -289,7 +289,7 @@ export class AssociativeRule1 extends AllowableOpRule {
util.makeBinaryExpression(op2, x2, newValNode),
);
return util.makeBinaryExpression(op1, newLeft, x1);
} catch (e) {
} catch (_) {
// Do nothing: will exit rule without modifying tree
}
}
Expand Down Expand Up @@ -345,7 +345,7 @@ export class AssociativeRule1 extends AllowableOpRule {
);
const newLeft = val;
return util.makeBinaryExpression(op, newLeft, newRight);
} catch (e) {
} catch (_) {
// Do nothing: will exit rule without modifying tree
}
}
Expand Down Expand Up @@ -1585,7 +1585,7 @@ export class AssociativeRule3 extends Rule {
// previously
return applyRules(data.simplifiedExpression);
}
} catch (e) {
} catch (_) {
// Do nothing: will exit rule without modifying tree
}
} else if (
Expand Down Expand Up @@ -1620,7 +1620,7 @@ export class AssociativeRule3 extends Rule {
// previously
return applyRules(data.simplifiedExpression);
}
} catch (e) {
} catch (_) {
// Do nothing: will exit rule without modifying tree
}
} else if (
Expand Down Expand Up @@ -1655,7 +1655,7 @@ export class AssociativeRule3 extends Rule {
// previously
return applyRules(data.simplifiedExpression);
}
} catch (e) {
} catch (_) {
// Do nothing: will exit rule without modifying tree
}
} else if (
Expand Down Expand Up @@ -1690,7 +1690,7 @@ export class AssociativeRule3 extends Rule {
// previously
return applyRules(data.simplifiedExpression);
}
} catch (e) {
} catch (_) {
// Do nothing: will exit rule without modifying tree
}
}
Expand Down
1 change: 1 addition & 0 deletions src/pipeline/version.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-require-imports
const version = require("../../package.json").version;

let __DANGER__VersionNumberDisabled = false;
Expand Down
13 changes: 7 additions & 6 deletions src/utils/tricks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ type Intersect<T> = (T extends unknown ? (x: T) => 0 : never) extends (
*/
type Unwrap<T> = T extends infer R ? { [K in keyof R]: R[K] } : never;

type Inputs<I, T extends string> = I extends { [Z in T]: infer K }
? K extends string
? Record<K, (input: I) => unknown>
: never
: never;
type Inputs<I, T extends string> =
I extends Record<T, infer K>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be checked manually. In TS a type and alias to the same type are not the same thing, because they implement aliases as instantations, in C++ way.

I'd rather prefer to disable that rule, because it's mostly pointless.

? K extends string
? Record<K, (input: I) => unknown>
: never
: never;
type Outputs<O> = { [K in keyof O]: (input: never) => O[K] };
type Handlers<I, O, T extends string> = Unwrap<Intersect<Inputs<I, T>>> &
Outputs<O>;
Expand All @@ -119,7 +120,7 @@ export const makeMakeVisitor =
<T extends string>(tag: T) =>
<I>() =>
<O>(handlers: Handlers<I, O, T>) =>
(input: Extract<I, { [K in T]: string }>): O[keyof O] => {
(input: Extract<I, Record<T, string>>): O[keyof O] => {
const handler = (handlers as Record<string, (input: I) => O[keyof O]>)[
input[tag]
];
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"lib": ["ESNext"],
// "allowJs": true, /* Allow javascript files to be compiled. */
"allowJs": true /* Allow javascript files to be compiled. */,
Copy link
Contributor

@verytactical verytactical Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? Tact is TS-only project, and allowJs: false seems to be some kind of a lint.

// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
"declaration": true /* Generates corresponding '.d.ts' file. */,
Expand Down
Loading
Loading