Skip to content

Commit 732f0ad

Browse files
committed
feat: upgrade to commitlint v19
BREAKING CHANGE: `commitlint.config.js` is not supported anymore, please use `.mjs` extension
1 parent 9763196 commit 732f0ad

24 files changed

+10637
-21671
lines changed

.dockerignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
node_modules
2-
commitlint.config.js
2+
commitlint.config.mjs
33
action.yml
44
.github
55
CHANGELOG.md

.eslintrc.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,10 @@
1919
"node/no-unpublished-require": "off",
2020
"node/no-unpublished-import": "off",
2121
"node/no-unsupported-features/es-syntax": "off"
22-
}
22+
},
23+
"ignorePatterns": [
24+
".github/tasks/actionYamlUpdater.js",
25+
"rollup.config.js",
26+
"fixtures"
27+
]
2328
}

.github/tasks/actionYamlUpdater.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ const yaml = require('yaml')
33

44
const versionRegex = /\d+\.\d+\.\d+/
55

6-
module.exports.readVersion = (contents) =>
6+
exports.readVersion = (contents) =>
77
yaml.parse(contents).runs.image.match(versionRegex)[0]
88

9-
module.exports.writeVersion = (contents, version) => {
9+
exports.writeVersion = (contents, version) => {
1010
const actionFile = yaml.parse(contents)
1111
actionFile.runs.image = actionFile.runs.image.replace(versionRegex, version)
1212

.github/workflows/ci.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ jobs:
5555
git config user.email '[email protected]'
5656
git config user.name 'GitHub Action'
5757
- name: Update versions and changelog
58-
run: npx commit-and-tag-version
58+
run: |
59+
# remove `"type": "module"` from package.json since `commit-and-tag-version` doesn't support it
60+
sed -i '/"type": "module",/c\' package.json
61+
npx commit-and-tag-version
62+
# bring back `"type": "module"`
63+
sed -i 's/"private": true,/"private": true,\n "type": "module",/' package.json
64+
git commit --amend --no-edit
5965
- name: Set VERSION env var
6066
run: |
6167
version=`node -p "require('./package.json').version"`

.lintstagedrc.js renamed to .lintstagedrc.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
'*.{ts,tsx,vue,css,less,scss,html,htm,md,markdown}': 'prettier --write',
33
'*.{json,yml,yaml}': ['prettier --write', () => 'npm run test'],
44
'*.{js,jsx}': ['eslint --fix', () => 'npm run test'],

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:16.14.2-alpine3.14 as build
1+
FROM node:20.9.0-alpine3.17 as build
22

33
COPY package*.json /
44

@@ -12,7 +12,7 @@ FROM node:20.9.0-alpine3.17
1212

1313
RUN apk --no-cache add git
1414

15-
COPY --from=build dist/run.js /run.js
15+
COPY --from=build dist/run.mjs /run.mjs
1616

1717
COPY package*.json /
1818

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,27 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- uses: actions/checkout@v3
22-
- uses: wagoid/commitlint-github-action@v5
22+
- uses: wagoid/commitlint-github-action@v6
2323
```
2424
2525
Alternatively, you can run on other event types such as `on: [push]`. In that case the action will lint the push event's commit(s) instead of linting commits from a pull request. You can also combine `push` and `pull_request` together in the same workflow.
2626

2727
## Inputs
2828

29-
You can supply these inputs to the `wagoid/commitlint-github-action@v5` step.
29+
You can supply these inputs to the `wagoid/commitlint-github-action@v6` step.
3030

3131
### `configFile`
3232

3333
The path to your commitlint config file.
3434

35-
Default: `commitlint.config.js`
35+
Default: `commitlint.config.mjs`
3636

3737
If the config file doesn't exist, [config-conventional](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional) settings will be loaded as a default fallback.
3838

3939
Details on the configuration file can be found on [the commitlint website](https://commitlint.js.org/#/reference-configuration).
4040

41+
Note: `commitlint.config.js` doesn't work with this action. If you use a JS config file, it's required to be an ES Module (`.mjs` extension)
42+
4143
### `failOnWarnings`
4244

4345
Whether you want to fail on warnings or not.
@@ -149,7 +151,7 @@ jobs:
149151
- run: npm install
150152
# Run the commitlint action, considering its own dependencies and yours as well 🚀
151153
# `github.workspace` is the path to your repository.
152-
- uses: wagoid/commitlint-github-action@v5
154+
- uses: wagoid/commitlint-github-action@v6
153155
env:
154156
NODE_PATH: ${{ github.workspace }}/node_modules
155157
```

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
configFile:
66
description: Commitlint config file. If the file doesn't exist, config-conventional settings will be
77
loaded as a fallback.
8-
default: ./commitlint.config.js
8+
default: ./commitlint.config.mjs
99
required: false
1010
failOnWarnings:
1111
description: Whether you want to fail on warnings or not

commitlint.config.js renamed to commitlint.config.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable import/no-extraneous-dependencies */
2-
const { maxLineLength } = require('@commitlint/ensure')
2+
import { maxLineLength } from '@commitlint/ensure'
33

44
const bodyMaxLineLength = 100
55

@@ -14,7 +14,7 @@ const validateBodyMaxLengthIgnoringDeps = (parsedCommit) => {
1414
]
1515
}
1616

17-
module.exports = {
17+
export default {
1818
extends: ['@commitlint/config-conventional'],
1919
plugins: ['commitlint-plugin-function-rules'],
2020
rules: {

entrypoint.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ set -e
55
if [ -z "$NODE_PATH" ]; then
66
export NODE_PATH=/node_modules
77
else
8-
export NODE_PATH=$NODE_PATH:/node_modules
8+
export NODE_PATH="$NODE_PATH":/node_modules
99
fi
1010

1111
# Since actions/checkout can be setup with a different user ID, we need to set the workspace as safe inside this action
1212
# Info about the vunlerability: https://github.blog/2022-04-12-git-security-vulnerability-announced/
1313
git config --global --add safe.directory "$GITHUB_WORKSPACE"
1414

15-
node /run.js
15+
export NODE_OPTIONS="$NODE_OPTIONS --experimental-vm-modules"
16+
17+
node /run.mjs
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module.exports = {
1+
export default {
22
extends: ['@commitlint/config-conventional'],
33
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
extends: ['@commitlint/config-conventional'],
33
helpUrl: 'https://example.org',
44
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
plugins: ['commitlint-plugin-jira-rules'],
33
extends: ['jira'],
44
}

fixtures/signed-off-by/commitlint.config.js renamed to fixtures/signed-off-by/commitlint.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
extends: ['@commitlint/config-conventional'],
33
rules: {
44
'signed-off-by': [2, 'always', 'Signed-off-by:'],
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
module.exports = {
1+
export default {
22
// Automatically clear mock calls and instances between every test
3-
// preset: 'rollup-jest',
43
clearMocks: true,
54
testEnvironment: '@commitlint/test-environment',
5+
testMatch: [
6+
'**/__tests__/**/*.?(m)[jt]s?(x)',
7+
'**/?(*.)+(spec|test).?(m)[tj]s?(x)',
8+
],
69
transform: {
710
'\\.[jt]sx?$': 'babel-jest',
811
},
9-
transformIgnorePatterns: ['node_modules/(?!dargs)'],
1012
}

0 commit comments

Comments
 (0)