weiran-zsd / dts-cli

Zero-config CLI for TypeScript package development
MIT License
442 stars 23 forks source link

dts lint: add option to ignore dts' builtin eslint config #219

Open robert-irelan-tiktokusds opened 5 months ago

robert-irelan-tiktokusds commented 5 months ago

Current Behavior

Currently, dts' builtin eslint config is always merged with a user-provided eslint config in .eslintrc.js. This gives me the following error:

Defaulting to "dts lint src test" 
You can override this in the package.json scripts, like "lint": "dts lint src otherDir"
PluginConflictError: Plugin "prettier" was conflicted between "src/.eslintrc.js » eslint-config-fe-mono/.eslintrc.web.js" and "BaseConfig » plugin:prettier/recommended".
    at mergePlugins (/cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:598:19)
    at createConfig (/cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:701:9)
    at ConfigArray.extractConfig (/cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:877:33)
    at FileEnumerator._isIgnoredFile (/cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/eslint@8.57.0/node_modules/eslint/lib/cli-engine/file-enumerator.js:534:24)
    at FileEnumerator._iterateFilesRecursive (/cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/eslint@8.57.0/node_modules/eslint/lib/cli-engine/file-enumerator.js:470:42)
    at _iterateFilesRecursive.next (<anonymous>)
    at FileEnumerator.iterateFiles (/cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/eslint@8.57.0/node_modules/eslint/lib/cli-engine/file-enumerator.js:299:49)
    at iterateFiles.next (<anonymous>)
    at CLIEngine.executeOnFiles (/cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/eslint@8.57.0/node_modules/eslint/lib/cli-engine/cli-engine.js:797:48)
    at ESLint.lintFiles (/cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/eslint@8.57.0/node_modules/eslint/lib/eslint/eslint.js:551:23) {
  messageTemplate: 'plugin-conflict',
  messageData: { pluginId: 'prettier', plugins: [ [Object], [Object] ] }
}

Our project has a custom eslint config that we don't wish to merge with the dts config:

module.exports = {
  root: true,
  extends: ['eslint-config-fe-mono/.eslintrc.node.js'],
};

But there's no way to accomplish this at the moment.

Desired Behavior

Provide a way to tell dts lint to not inject its own eslint config. Similar fixes should also be considered for Babel and Jest.

Suggested Solution

Two options:

Who does this impact? Who is this for?

All users who wish to use their own Eslint config without any config injected by dts.

Describe alternatives you've considered

Nothing is possible at the moment, since there's no way to customize the merge behavior of Object.assign.

Additional context

N/A

aladdin-add commented 5 months ago

I hadn't noticed this, and I agree.

It can be the default (worthy a breaking change).