Skip to content

Commit 7171565

Browse files
committedJun 29, 2023
fix: remove mjs support from eslint-config, because it breaks the package.json type module with eslint
removed mjs files in the eslint-config package to fix support issues. Also, adjusted eslint-config postinstall script and tsup.config to reflect the changes made. These changes were to run eslint config with the package.json type module Signed-off-by: prisis <d.bannert@anolilab.de>
1 parent 4b5922e commit 7171565

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed
 

‎packages/eslint-config/package.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,15 @@
8888
"exports": {
8989
".": {
9090
"types": "./dist/index.d.ts",
91-
"require": "./dist/index.js",
92-
"import": "./dist/index.mjs"
91+
"require": "./dist/index.js"
9392
},
9493
"./typescript-type-checking": {
95-
"require": "./dist/typescript-type-checking.js",
96-
"import": "./dist/typescript-type-checking.mjs"
94+
"types": "./dist/typescript-type-checking.d.ts",
95+
"require": "./dist/typescript-type-checking.js"
9796
},
9897
"./package.json": "./package.json"
9998
},
10099
"main": "dist/index.js",
101-
"module": "dist/index.mjs",
102100
"types": "dist/index.d.ts",
103101
"files": [
104102
"dist",
@@ -184,6 +182,7 @@
184182
"eslint-plugin-zod": "^1.4.0",
185183
"jest": "^29.5.0",
186184
"react": "^18.2.0",
185+
"rimraf": "^5.0.1",
187186
"semantic-release": "^21.0.5",
188187
"tsup": "^7.1.0",
189188
"type-fest": "^3.12.0",

‎packages/eslint-config/src/postinstall.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const configFile = ".eslintrc";
2121
// eslint-disable-next-line sonarjs/cognitive-complexity
2222
const writeEslintRc = () => {
2323
// eslint-disable-next-line no-restricted-syntax
24-
for (const filename of [configFile, `${configFile}.js`, `${configFile}.cjs`, `${configFile}.mjs`, `${configFile}.json`, `${configFile}.yaml`, `${configFile}.yml`]) {
24+
for (const filename of [configFile, `${configFile}.js`, `${configFile}.cjs`, `${configFile}.json`, `${configFile}.yaml`, `${configFile}.yml`]) {
2525
if (existsSync(join(projectPath, filename))) {
2626
console.warn(`⚠️ ${filename} already exists;
2727
Make sure that it includes the following for @anolilab/eslint-config'
@@ -31,7 +31,7 @@ to work as it should: { extends: ["@anolilab/eslint-config"] }.`);
3131
}
3232
}
3333

34-
const eslintPath = join(projectPath, ".eslintrc.js");
34+
const eslintPath = join(projectPath, `.eslintrc.${packageIsTypeModule ? "c" : ""}js`);
3535

3636
let pluginExtends = "";
3737
let parserOptions = `
@@ -67,7 +67,7 @@ to work as it should: { extends: ["@anolilab/eslint-config"] }.`);
6767

6868
const content = `/** @ts-check */
6969
/** @type {import('eslint').Linter.Config} */
70-
${packageIsTypeModule ? "export default" : "module.exports ="} {
70+
module.exports = {
7171
root: true,
7272
extends: ["@anolilab/eslint-config"${pluginExtends}],
7373
ignorePatterns: ["!**/*"],

‎packages/eslint-config/tsup.config.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { createConfig } from "../../tsup.config";
22

3-
const config = createConfig();
3+
const config = createConfig({
4+
format: ["cjs"],
5+
});
46

57
export default config;

0 commit comments

Comments
 (0)
Please sign in to comment.