eslint-config
eslint-config copied to clipboard
Clarify monorepo setup where there is a base file
Clear and concise description of the problem
I want to have a root eslint config, and then in apps/libs, be able to set the "type: lib", but when I try this it fails, and it's not obvious from the doc how I should do it?
import config from "../../eslint.config.mjs";
export default config.override({
type: "app",
});
Suggested solution
Add it to the documentation
Alternative
No response
Additional context
No response
Validations
- [x] Follow our Code of Conduct
- [x] Read the Contributing Guide.
- [x] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Same question
I noticed that type: 'lib' and type: 'app' only differ by one rule: ts/explicit-function-return-type.
https://github.com/antfu/eslint-config/blob/56262ef7962ce310d29348060d8941d420f410fc/src/configs/typescript.ts#L165
In fact, we could override this rule
// @ts-check
import { antfu } from '@antfu/eslint-config'
export default antfu(
{
type: 'app',
},
{
files: ['./your-lib-path/**/*.?([cm])ts', './your-lib-path/**/*.?([cm])tsx'],
rules: {
'ts/explicit-function-return-type': 'on',
},
},
)
or override antfu/typescript/rules
// @ts-check
import { antfu, typescript } from '@antfu/eslint-config'
export default antfu(
{
type: 'app',
},
)
.override(
'antfu/typescript/rules',
{
ignores: ['./your-lib-path/**/*'],
},
)
.append(typescript({
type: 'lib',
}).then(configs =>
configs
.filter(c => c.name === 'antfu/typescript/rules')
.map((c) => {
if (c.name)
c.name = `your-lib-name/typescript/rules`
if (c.files)
c.files = ['./your-lib-path/**/*.?([cm])ts', './your-lib-path/**/*.?([cm])tsx']
return c
}),
))