-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
feat: Support basePath
property in config objects
#131
base: main
Are you sure you want to change the base?
Conversation
basePath
` property in config objectsbasePath
property in config objects
- `filesAndIgnoresSchema` will be updated to validate that the new `basePath` property, if present, has a string value. | ||
- `normalizeConfigPatterns()` will be updated to normalize the `basePath` property value to an equivalent namespace-prefixed path, for consistency with the config array's `basePath` property value. | ||
- `META_FIELDS` will be updated to include `"basePath"`, in order to treat config objects with `basePath` + `ignores` as global ignores. | ||
- `get ignores()` will be updated to return an array of config objects instead of an array of ignore patterns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably this is because we need to combine the basePath
with the ignore patterns to get the correct files/directories to ignore? If so, can you add that detail here?
|
||
## Open Questions | ||
|
||
Should this RFC include the `--basePath` feature (https://github.com/eslint/eslint/issues/19118)? I didn't see a relation between config-level base paths and ability to override config array's base path, so I didn't include it in this RFC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I thought it might be good to include this feature in this RFC is because of how --base-path
might interact with a config basePath
property. Would it just replace the config file base path completely such that any relative basePath
property would now be relative to the value passed as --base-path
?
I'm thinking about the situation where a parent config and an extended config have different base paths. Per the current Maybe relative base paths in extended configs should be joined to the base path of the parent config? |
I'm not sure I understand what you're describing. Can you provide an example? |
Here's an example where the export default defineConfig({
basePath: "packages/foo",
files: ["**/*.js"],
rules: {
rule1: "error"
},
extends: [{
ignores: ["ignored.js"],
rules: {
rule2: "error"
}
}]
}); Using the fork in mdjermanovic/rewrite#1, this will result in the following array: [
{
ignores: ["ignored.js"],
rules: { rule2: "error" },
files: ["**/*.js"],
name: "UserConfig[0] > ExtendedConfig[0]"
},
{
basePath: "packages/foo",
files: ["**/*.js"],
rules: { rule1: "error" }
}
] Basically the merged config object (the first array element) now contains the |
Summary
This RFC proposes supporting
basePath
property in config objects.When present, config object's
basePath
overrides config array'sbasePath
, meaning thatfiles
andignores
patterns in that config object will be treated as relative to the config object'sbasePath
instead of the config array'sbasePath
.Related Issues
eslint/eslint#18948