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

bump versions and migrate cjs to esm #98

Merged
merged 2 commits into from
Mar 10, 2024
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
24 changes: 0 additions & 24 deletions buildScripts/fixbarrels.cjs

This file was deleted.

18 changes: 18 additions & 0 deletions buildScripts/fixbarrels.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Build script to fix barrelsby for ESM
import fs from "node:fs/promises";
import path from "node:path";
import config from ".././.barrelsby.json" with { "type": "json" };
import { fileURLToPath } from "node:url";

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const existsPromises = config.directory
.map(barrel => path.join(__dirname, "../", barrel + "/index.ts"))
.map(filePath =>
fs.access(filePath, fs.constants.F_OK)
.then(() => fs.readFile(filePath, {encoding: "utf8"}))
.then(data => data.replace(/";/g, ".js\";"))
.then(result => fs.writeFile(filePath, result, "utf8"))
.catch(err => console.error("Error:", err))
);
await Promise.all(existsPromises);
90 changes: 50 additions & 40 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,54 @@
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";

export default tseslint.config({
files: ['**/*.ts'],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
],
ignores: ["src/migrations/**/*"],
rules: {
// common
"no-return-await": "error",
"no-unreachable-loop": "error",
"no-promise-executor-return": "off",
"no-unsafe-optional-chaining": "error",
"no-useless-backreference": "error",
"require-atomic-updates": "off",
"require-await": "error",
"no-await-in-loop": "off",
"spaced-comment": "error",
"no-unused-vars": "off",
"curly": "error",
"semi": "error",
"camelcase": "off",
// TypeScript
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-loss-of-precision": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/ban-types": "warn",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
"accessibility": "explicit"
}
]
export default tseslint.config(
{
ignores: ["src/migrations/**/*", "**/*.mjs"],
},
});
{
plugins: {
"@typescript-eslint": tseslint.plugin,
},
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: true,
},
},
extends: [eslint.configs.recommended, ...tseslint.configs.recommended],
files: ["**/*.ts"],
rules: {
// common
"no-return-await": "error",
"no-unreachable-loop": "error",
"no-promise-executor-return": "off",
"no-unsafe-optional-chaining": "error",
"no-useless-backreference": "error",
"require-atomic-updates": "off",
"require-await": "error",
"no-await-in-loop": "off",
"spaced-comment": "error",
"no-unused-vars": "off",
curly: "error",
semi: "error",
camelcase: "off",
// TypeScript
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-loss-of-precision": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/ban-types": "warn",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
accessibility: "explicit",
},
],
},
},
);
Loading