Skip to content

Commit

Permalink
feat: add mixed-esm-and-cjs config for eslint.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add committed Aug 22, 2023
1 parent fff9ae0 commit ec28267
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions configs/mixed-esm-and-cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @fileoverview the `mixed-esm-and-cjs` config for `eslint.config.js`
* @author 唯然<weiran.zsd@outlook.com>
*/

"use strict"

const getPackageJson = require("../lib/util/get-package-json")
const esmConfig = require("./recommended-module.js")
const cjsConfig = require("./recommended-script.js")

const packageJson = getPackageJson()
const isESM = packageJson.type === "module"

module.exports = [
{
files: ["**/*.js"],
...(isESM ? esmConfig : cjsConfig),
},
{
files: ["**/*.mjs"],
esmConfig,
},
{
files: ["**/*.cjs"],
cjsConfig,
},
]

0 comments on commit ec28267

Please sign in to comment.