Skip to content
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
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

38 changes: 0 additions & 38 deletions .eslintrc

This file was deleted.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
/tmp
/yarn.lock
node_modules
.eslintcache
.eslintcache
.idea
mtgen
20 changes: 6 additions & 14 deletions bin/run
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
#!/usr/bin/env node
#!/usr/bin/env node --import=tsx/esm

// const fs = require('fs')
// const path = require('path')
// const project = path.join(__dirname, '../tsconfig.json')
// const dev = fs.existsSync(project)
import { run } from '../lib/index.js'
import { flush, handle } from '@oclif/core'

// if (dev) {
// require('ts-node').register({project})
// }

// require(`../${dev ? 'src' : 'lib'}`).run()

require(`../lib`).run()
.then(require("@oclif/core/flush"))
.catch(require("@oclif/core/handle"));
run()
.then(flush)
.catch(handle)
90 changes: 90 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import js from "@eslint/js";
import tseslint from "@typescript-eslint/eslint-plugin";
import tsparser from "@typescript-eslint/parser";
import prettier from "eslint-config-prettier";

export default [
// TypeScript files
{
files: ["**/*.ts", "**/*.tsx"],
ignores: ["**/*.test.ts", "**/*.spec.ts", "**/*.test.tsx", "**/*.spec.tsx"],
languageOptions: {
parser: tsparser,
parserOptions: {
ecmaVersion: 2022,
sourceType: "module",
project: "./tsconfig.json"
},
globals: {
// Node.js globals
process: "readonly",
Buffer: "readonly",
console: "readonly",
__dirname: "readonly",
__filename: "readonly",
global: "readonly",
module: "readonly",
require: "readonly",
exports: "readonly"
}
},
plugins: {
"@typescript-eslint": tseslint
},
rules: {
// Start with recommended rules
...js.configs.recommended.rules,
...tseslint.configs.recommended.rules,

// Your disabled rules
camelcase: "off",
quotes: "off",
semi: "off",
"object-curly-spacing": "off",
indent: "off",
"no-warning-comments": "off",
"no-console": "off",
complexity: "off",
"brace-style": "off",
"no-trailing-spaces": "off",
"no-case-declarations": "off",
"comma-dangle": "off",
"no-return-await": "off",
"no-process-exit": "off",
"padding-line-between-statements": "off",
"unicorn/no-process-exit": "off",
"unicorn/filename-case": "off",
"unicorn/catch-error-name": "off",
"unicorn/no-abusive-eslint-disable": "off",
"unicorn/no-array-for-each": "off",
"unicorn/prefer-node-protocol": "off",
"unicorn/better-regex": "off",
"unicorn/no-useless-undefined": "off",
"unicorn/prefer-module": "off",
"unicorn/consistent-function-scoping": "off",
"unicorn/no-console-spaces": "off",
"unicorn/prefer-negative-index": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/member-delimiter-style": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/consistent-type-assertions": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off"
}
},

// JavaScript files
{
files: ["**/*.js", "**/*.mjs"],
...js.configs.recommended
},

// Prettier - disables conflicting formatting rules
prettier,

// Ignores
{
ignores: ["lib/**", "**/artifacts/**", "node_modules/**", "**/*.d.ts", "coverage/**"]
}
];
13 changes: 13 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
testEnvironment: "node",
testMatch: ["<rootDir>/src/**/*.test.ts"],
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
tsconfig: "tsconfig.test.json"
}
]
},
sandboxInjectedGlobals: ["Math", "JSON"]
};
11 changes: 0 additions & 11 deletions jest.config.js

This file was deleted.

2 changes: 2 additions & 0 deletions lib/helpers/cli.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { Interfaces } from "@oclif/core";
export declare const helpFlag: (opts?: Partial<Interfaces.BooleanFlag<boolean>>) => Interfaces.BooleanFlag<boolean>;
11 changes: 11 additions & 0 deletions lib/helpers/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Flags } from "@oclif/core";
export const helpFlag = (opts = {}) => {
return Flags.boolean({
description: "Show CLI help.",
...opts,
parse: async () => {
// Just return true - oclif will handle the help display
return true;
}
});
};
61 changes: 61 additions & 0 deletions lib/helpers/constants.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* TypeScript keywords categorized by their usage context. (where I got the list)
* @see {@link https://github.com/microsoft/TypeScript/issues/2536 TS Reserved Words}
*/
/**
* Regular JavaScript/TypeScript reserved words that cannot be used as identifiers in any context.
* These are the core keywords that form the basic syntax and control flow of the language.
* Using these as identifiers will always result in a syntax error.
*
* @example
* // These will cause syntax errors:
* type if = string; // Error: 'if' is a reserved word
* interface class {} // Error: 'class' is a reserved word
*/
export declare const tsReservedWords: readonly ["break", "case", "catch", "class", "const", "continue", "debugger", "default", "delete", "do", "else", "enum", "export", "extends", "false", "finally", "for", "function", "if", "import", "in", "instanceof", "new", "null", "return", "super", "switch", "this", "throw", "true", "try", "typeof", "var", "void", "while", "with"];
/**
* Additional reserved words that include both JavaScript strict mode keywords
* and TypeScript-specific modifiers. These cannot be used as identifiers in
* strict mode or when using TypeScript features.
*
* @example
* // These will cause errors:
* let interface = "foo"; // Error: 'interface' is reserved
*/
export declare const tsStrictModeReservedWords: readonly ["as", "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"];
/**
* Contextual keywords that have special meaning in certain contexts but can be used as identifiers.
* These keywords need to be handled carefully during type generation to avoid creating invalid TypeScript.
*
* @example
* // These would create invalid type definitions:
* type type = string; // Error: 'type' is a contextual keyword
* interface get<T> {} // Error: 'get' cannot be used as an interface name
* type async<T> = T; // Error: 'async' cannot be used as a type alias
*/
export declare const tsContextualKeywords: readonly ["any", "async", "await", "boolean", "constructor", "declare", "get", "infer", "is", "keyof", "module", "namespace", "never", "readonly", "require", "number", "set", "string", "symbol", "type", "from", "of", "unknown", "undefined", "unique", "global"];
/**
* Combined array of all TypeScript keywords, including reserved words,
* strict mode reserved words, and contextual keywords.
* This comprehensive list can be used when checking if a string is any kind
* of TypeScript keyword.
*/
export declare const tsReservedKeywords: readonly ["break", "case", "catch", "class", "const", "continue", "debugger", "default", "delete", "do", "else", "enum", "export", "extends", "false", "finally", "for", "function", "if", "import", "in", "instanceof", "new", "null", "return", "super", "switch", "this", "throw", "true", "try", "typeof", "var", "void", "while", "with", "as", "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield", "any", "async", "await", "boolean", "constructor", "declare", "get", "infer", "is", "keyof", "module", "namespace", "never", "readonly", "require", "number", "set", "string", "symbol", "type", "from", "of", "unknown", "undefined", "unique", "global"];
/**
* Regex pattern that matches any character that is not a valid TypeScript identifier character.
* Used to split strings into parts that could form valid identifiers.
* Valid characters are: a-z, A-Z, 0-9, underscore (_), and dollar sign ($)
*/
export declare const TS_IDENTIFIER_SEPARATOR_REGEX: RegExp;
/**
* Regex pattern that matches invalid TypeScript identifier characters.
* Used to clean individual parts of an identifier.
* Matches anything that is not: a-z, A-Z, 0-9, underscore (_), or dollar sign ($)
*/
export declare const TS_INVALID_CHAR_REGEX: RegExp;
/**
* Regex pattern that matches invalid starting characters for TypeScript identifiers.
* Used to ensure the first part of an identifier starts with a valid character.
* Matches any characters that are not: a-z, A-Z, underscore (_), or dollar sign ($)
*/
export declare const TS_INVALID_START_REGEX: RegExp;
Loading