-
Notifications
You must be signed in to change notification settings - Fork 929
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
Bump cosmiconfig version and conditionally support mjs config #3747
Changes from 11 commits
2d567b3
6dcec0c
b9cd734
145ca9d
df34d80
b8c0c00
1fad45a
9e04c19
ff2541f
b233fbd
b160218
2a545c5
919e056
88416b9
fdecba0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
extends: | ||
- './first-extended' | ||
rules: | ||
zero: [0, 'never'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: [0, 'never'], | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ module.exports = { | |
rules: { | ||
zero: [0, 'never'], | ||
}, | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
"rules": { | ||
"zero": [0, "never"] | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: [0, 'never'], | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
extends: | ||
- './first-extended' | ||
rules: | ||
zero: [0, 'never'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
extends: | ||
- './first-extended' | ||
rules: | ||
zero: [0, 'never'] | ||
zero: [0, 'never'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: [0, 'never'], | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: [0, 'never'], | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
extends: ['./first-extended'], | ||
rules: { | ||
zero: [0, 'never'], | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ | |
] | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,12 @@ jest.mock('@scope/commitlint-plugin-example', () => scopedPlugin, { | |
}); | ||
|
||
import path from 'path'; | ||
import {readFileSync, writeFileSync} from 'fs'; | ||
import resolveFrom from 'resolve-from'; | ||
import {fix, git, npm} from '@commitlint/test'; | ||
|
||
import load from './load'; | ||
import {isDynamicAwaitSupported} from './utils/load-config'; | ||
|
||
const fixBootstrap = (name: string) => fix.bootstrap(name, __dirname); | ||
const gitBootstrap = (name: string) => git.bootstrap(name, __dirname); | ||
|
@@ -186,24 +188,30 @@ test('respects cwd option', async () => { | |
}); | ||
}); | ||
|
||
test('recursive extends', async () => { | ||
const cwd = await gitBootstrap('fixtures/recursive-extends'); | ||
const actual = await load({}, {cwd}); | ||
|
||
expect(actual).toMatchObject({ | ||
formatter: '@commitlint/format', | ||
extends: ['./first-extended'], | ||
plugins: {}, | ||
rules: { | ||
zero: [0, 'never'], | ||
one: [1, 'always'], | ||
two: [2, 'never'], | ||
}, | ||
}); | ||
}); | ||
const mjsConfigFiles = isDynamicAwaitSupported() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New set of tests for each config type. I removed the older tests and their fixture data, but verified they were still passing in an older commit. |
||
? ['commitlint.config.mjs', '.commitlintrc.mjs'] | ||
: []; | ||
|
||
test.each( | ||
[ | ||
'commitlint.config.cjs', | ||
'commitlint.config.js', | ||
'package.json', | ||
'.commitlintrc', | ||
'.commitlintrc.cjs', | ||
'.commitlintrc.js', | ||
'.commitlintrc.json', | ||
'.commitlintrc.yml', | ||
'.commitlintrc.yaml', | ||
...mjsConfigFiles, | ||
].map((configFile) => [configFile]) | ||
)('recursive extends with %s', async (configFile) => { | ||
const cwd = await gitBootstrap(`fixtures/recursive-extends-js-template`); | ||
const configPath = path.join(__dirname, `../fixtures/config/${configFile}`); | ||
const config = readFileSync(configPath); | ||
|
||
writeFileSync(path.join(cwd, configFile), config); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test.each writes a config file from fixtures/config to the template directory and then loads the found config from the current working directory. Everything except ts files should be supported by the template directory. |
||
|
||
test('recursive extends with json file', async () => { | ||
const cwd = await gitBootstrap('fixtures/recursive-extends-json'); | ||
const actual = await load({}, {cwd}); | ||
|
||
expect(actual).toMatchObject({ | ||
|
@@ -218,63 +226,13 @@ test('recursive extends with json file', async () => { | |
}); | ||
}); | ||
|
||
test('recursive extends with yaml file', async () => { | ||
const cwd = await gitBootstrap('fixtures/recursive-extends-yaml'); | ||
const actual = await load({}, {cwd}); | ||
|
||
expect(actual).toMatchObject({ | ||
formatter: '@commitlint/format', | ||
extends: ['./first-extended'], | ||
plugins: {}, | ||
rules: { | ||
zero: [0, 'never'], | ||
one: [1, 'never'], | ||
two: [2, 'always'], | ||
}, | ||
}); | ||
}); | ||
|
||
test('recursive extends with js file', async () => { | ||
const cwd = await gitBootstrap('fixtures/recursive-extends-js'); | ||
const actual = await load({}, {cwd}); | ||
|
||
expect(actual).toMatchObject({ | ||
formatter: '@commitlint/format', | ||
extends: ['./first-extended'], | ||
plugins: {}, | ||
rules: { | ||
zero: [0, 'never'], | ||
one: [1, 'never'], | ||
two: [2, 'always'], | ||
}, | ||
}); | ||
}); | ||
|
||
test('recursive extends with package.json file', async () => { | ||
const cwd = await gitBootstrap('fixtures/recursive-extends-package'); | ||
const actual = await load({}, {cwd}); | ||
|
||
expect(actual).toMatchObject({ | ||
formatter: '@commitlint/format', | ||
extends: ['./first-extended'], | ||
plugins: {}, | ||
rules: { | ||
zero: [0, 'never'], | ||
one: [1, 'never'], | ||
two: [2, 'never'], | ||
}, | ||
}); | ||
}); | ||
|
||
// fails since a jest update: https://github.com/conventional-changelog/commitlint/pull/3362 | ||
// eslint-disable-next-line jest/no-disabled-tests | ||
test.skip('recursive extends with ts file', async () => { | ||
test('recursive extends with ts file', async () => { | ||
const cwd = await gitBootstrap('fixtures/recursive-extends-ts'); | ||
const actual = await load({}, {cwd}); | ||
|
||
expect(actual).toMatchObject({ | ||
formatter: '@commitlint/format', | ||
extends: ['./first-extended'], | ||
extends: ['./first-extended/index.ts'], | ||
plugins: {}, | ||
rules: { | ||
zero: [0, 'never', 'zero'], | ||
|
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.
Simplified this with the build matrix so they all run the same steps, but @escapedcat do I need to keep the original checks around temporarily?
I did this to take advantage of the fact that the setup node action pulls down node 20.9.0, whereas the original job pulled down only 20.5.x and I didn't see a way to configure it.
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.
I think pulling latest v20 is fine.
Thanks for introducing the matrix. Simplifies things in the future.
I might need to adjust the required checks in the settings. Will check.