-
Notifications
You must be signed in to change notification settings - Fork 947
Closed
Labels
Description
The order of the current extends resolution is counterintuitive, extends are usually resolved from left to right, but it is currently resolved from right to left.
Expected Behavior
extends should be resolved from left to right.
Current Behavior
extends is currently resolved from right to left.
Affected packages
-
@commitlint/resolve-extends
Possible Solution
Change the order of the extends resolution.
Steps to Reproduce (for bugs)
Add the following test case to /@commitlint/resolve-extends/src/index.test.ts:
test('extends rules from left to right with overlap', () => {
const input = {extends: ['left', 'right']};
const require = (id: string) => {
switch (id) {
case 'left':
return {rules: {a: true}};
case 'right':
return {rules: {a: false, b: true}};
default:
return {};
}
};
const ctx = {resolve: id, require: jest.fn(require)} as ResolveExtendsContext;
const actual = resolveExtends(input, ctx);
const expected = {
extends: ['left', 'right'],
rules: {
a: false,
b: true,
},
};
expect(actual).toEqual(expected);
});● extends rules from left to right with overlap
expect(received).toEqual(expected) // deep equality
- Expected - 1
+ Received + 1
@@ -2,9 +2,9 @@
"extends": Array [
"left",
"right",
],
"rules": Object {
- "a": false,
+ "a": true,
"b": true,
},
}Context
I'd like to have a base config and extend it as needed, for example I want to use the base config most of the time:
{"extends": ["my-config"]}and override it if the repository has some sharable special requirements:
{"extends": ["my-config", "my-config/special-requirements"]}Your Environment
| Executable | Version |
|---|---|
commitlint --version |
9.1.2 |