Skip to content

Commit 40d31ba

Browse files
authored
feat!: Support basePath property in config objects (eslint#223)
1 parent d0e5570 commit 40d31ba

File tree

8 files changed

+3036
-221
lines changed

8 files changed

+3036
-221
lines changed

packages/config-array/README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const configs = new ConfigArray(rawConfigs, {
7676
});
7777
```
7878

79-
This example reads in an object or array from `my.config.js` and passes it into the `ConfigArray` constructor as the first argument. The second argument is an object specifying the `basePath` (the directory in which `my.config.js` is found) and a `schema` to define the additional properties of a config object beyond `files`, `ignores`, and `name`.
79+
This example reads in an object or array from `my.config.js` and passes it into the `ConfigArray` constructor as the first argument. The second argument is an object specifying the `basePath` (the directory in which `my.config.js` is found) and a `schema` to define the additional properties of a config object beyond `files`, `ignores`, `basePath`, and `name`.
8080

8181
### Specifying a Schema
8282

@@ -165,6 +165,16 @@ export default [
165165
js: false,
166166
},
167167
},
168+
169+
// specific settings for files inside `src` directory
170+
{
171+
name: "Source files",
172+
basePath: "src",
173+
files: ["**/*"],
174+
settings: {
175+
source: true,
176+
},
177+
},
168178
];
169179
```
170180

@@ -284,7 +294,7 @@ The config array always returns an object, even if there are no configs matching
284294
A few things to keep in mind:
285295

286296
- If a filename is not an absolute path, it will be resolved relative to the base path directory.
287-
- The returned config object never has `files`, `ignores`, or `name` properties; the only properties on the object will be the other configuration options specified.
297+
- The returned config object never has `files`, `ignores`, `basePath`, or `name` properties; the only properties on the object will be the other configuration options specified.
288298
- The config array caches configs, so subsequent calls to `getConfig()` with the same filename will return in a fast lookup rather than another calculation.
289299
- A config will only be generated if the filename matches an entry in a `files` key. A config will not be generated without matching a `files` key (configs without a `files` key are only applied when another config with a `files` key is applied; configs without `files` are never applied on their own). Any config with a `files` key entry that is `*` or ends with `/**` or `/*` will only be applied if another entry in the same `files` key matches or another config matches.
290300

packages/config-array/src/base-schema.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export const baseSchema = Object.freeze({
4646
}
4747
},
4848
},
49+
basePath: NOOP_STRATEGY,
4950
files: NOOP_STRATEGY,
5051
ignores: NOOP_STRATEGY,
5152
});

0 commit comments

Comments
 (0)