Skip to content

Commit

Permalink
feat: move to full ESM, fully upgrade everything (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomyCesaille authored Dec 21, 2024
2 parents 154ea27 + 0a5ff38 commit df66073
Show file tree
Hide file tree
Showing 16 changed files with 4,514 additions and 1,173 deletions.
33 changes: 0 additions & 33 deletions .eslintrc.js

This file was deleted.

20 changes: 20 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Description

Please include a summary of the changes and the related issue.

## Related Issue

Closes # (issue)

## Type of change

- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update

## Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have made corresponding changes to the documentation
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20
22
27 changes: 27 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"exclude": "node_modules/",
"jsc": {
"parser": {
"syntax": "typescript",
"topLevelAwait": true
},
"target": "esnext",
"baseUrl": ".",
"experimental": {
"plugins": [
[
"@swc/plugin-transform-imports",
{
"^(.*?)(\\.ts)$": {
"skipDefaultConversion": true,
"transform": "{{matches.[1]}}.js"
}
}
]
]
}
},
"module": {
"type": "nodenext"
}
}
76 changes: 76 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
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 [
{
ignores: ["**/dist/"],
},
...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
),
{
plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
globals: {
...Object.fromEntries(
Object.entries(globals.browser).map(([key]) => [key, "off"]),
),
},

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

rules: {
indent: [
"error",
2,
{
offsetTernaryExpressions: true,
},
],

"linebreak-style": ["error", "unix"],
quotes: ["error", "double"],
semi: ["error", "always"],
"comma-dangle": ["error", "always-multiline"],

"@typescript-eslint/no-unused-vars": [
"error",
{
varsIgnorePattern: "^_",
},
],
},
},
{
files: ["**/.eslintrc.{js,cjs}"],

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

ecmaVersion: 5,
sourceType: "commonjs",
},
},
];
13 changes: 12 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import type { JestConfigWithTsJest } from "ts-jest";

const jestConfig: JestConfigWithTsJest = {
preset: "ts-jest",
preset: "ts-jest/presets/default-esm", // Use ESM-compatible preset
extensionsToTreatAsEsm: [".ts"], // Treat these extensions as ESM
transform: {
"^.+\\.ts$": ["ts-jest", { useESM: true }], // Use ts-jest to handle TypeScript files with ESM
},
testEnvironment: "node", // Use Node.js environment
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1", // Map module paths correctly
},
transformIgnorePatterns: [
"/node_modules/(?!chalk|ansi-escapes)", // Ensure node_modules are transformed correctly
],
};

export default jestConfig;
Loading

0 comments on commit df66073

Please sign in to comment.