Skip to content

Commit

Permalink
add typescript config
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmachuca committed Nov 25, 2024
1 parent 90104d9 commit c6b939f
Show file tree
Hide file tree
Showing 20 changed files with 3,425 additions and 891 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

6 changes: 0 additions & 6 deletions .eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.66
2.5.100-beta
70 changes: 70 additions & 0 deletions build-esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// build.js
const esbuild = require("esbuild");
const alias = require("esbuild-plugin-alias");
const path = require("path");

const baseSettings = {
entryPoints: ["src/index.ts"], // Your entry file
bundle: true,
outdir: "public/cjs", // Output dir
format: "cjs", // or "esm" depending on your module system
target: ["esnext"], // Adjust based on your target environment
tsconfig: "tsconfig.json", // Path to your tsconfig.json,
globalName: "global",
minify:false,
keepNames: true,
sourcemap: true,
splitting: false,
chunkNames: "chunks/[name]-[hash]",
plugins: [
alias({
"types": path.join(__dirname, "src/types/global/index.d.ts")
})
],
external: ["os", "path", "http", "url",
"child_process", "events", "fs", "process",
"node:fs", "node:os", "node:child_process",
"node:path", "readline", "node:net", "node:repl",
"node:vm", "http2", "vm", "qcobjects", "qcobjects-sdk"
]

};

const cjsSettings = {...baseSettings,
entryPoints: ["src/index.ts"], // Your entry file
outdir: "public/cjs", // Output dir
format: "cjs", // or "esm" depending on your module system
platform: "node", // or "browser" depending on your target environment
outExtension: {
".js":".cjs"
}

};

const esmSettings = {...baseSettings,
entryPoints: ["src/index.ts"], // Your entry file
outdir: "public/esm", // Output dir
format: "esm", // or "esm" depending on your module system
platform: "browser", // or "browser" depending on your target environment
outExtension: {
".js":".mjs"
}

};

const browserSettings = {...baseSettings,
entryPoints: ["src/index.ts"], // Your entry file
bundle: true,
outdir: "public/browser", // Output dir
format: "iife", // or "esm" depending on your module system
platform: "browser", // or "browser" depending on your target environment
outExtension: {
".js":".js"
}
};

const logError = (e) => {console.log(e);process.exit(1);};

esbuild.build(cjsSettings).catch(logError);
esbuild.build(esmSettings).catch(logError);
esbuild.build(browserSettings).catch(logError);
87 changes: 87 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";

import * as parser 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 [
{ languageOptions: {
globals: {
...globals.browser,
...globals.node,
Atomics: "readonly",
SharedArrayBuffer: "readonly",
},

ecmaVersion: "latest",
sourceType: "module",
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
programs: [parser.createProgram('tsconfig.json')],
}
,

} },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{ files: ["**/*.{js,mjs,cjs,ts}"] }
,{
ignores: [
"**/*.js",
"spec/**/*",
"src/*.js",
"src/**/*.js",
"node_modules/**/*",
"**/node_modules"
],
}, ...compat.extends("eslint:recommended"),
{ rules: {
semi: ["error", "always"],
quotes: ["error", "double"],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/ban-types": "off",
"array-callback-return": "warn",
"no-useless-call": "off",
camelcase: "off",
"no-var": "off",
}},
{
files: ["**/*.ts", "**/*.d.ts", "**/*.d.tsx", "**/*.tsx"]
},
{ files: ["**/*.d.ts"],
rules: {
"no-unused-vars":"off"
}
},
{
files: ["**/*.ts", "**/*.d.ts"],
rules: {
"no-dupe-class-members":"off",
"@typescript-eslint/no-unsafe-function-type":"off",
"no-redeclare": "off",
"@typescript-eslint/no-unsafe-member-access":"off",
"@typescript-eslint/no-unsafe-assignment":"off",
"@typescript-eslint/no-unsafe-call":"off",
"@typescript-eslint/no-unsafe-argument":"off"

}
}
];
Loading

0 comments on commit c6b939f

Please sign in to comment.