@kununu/eslint-config 7.4.1 → 7.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -45
- package/package.json +10 -5
- package/.github/workflows/auto_assign_owner.yml +0 -13
- package/.github/workflows/release.yml +0 -278
- package/.nvmrc +0 -1
package/README.md
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
# @kununu/eslint-config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@kununu/eslint-config)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
apps, BFFs, and shared libraries. It bundles the parsers and plugins it needs, so
|
|
7
|
-
consumers only install this one package.
|
|
5
|
+
> kununu's shared [ESLint](https://eslint.org/) configuration (ESLint v9, flat config)
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
Shared linting rules that keep JavaScript, JSX, TypeScript and TSX consistent
|
|
8
|
+
across kununu's frontend apps, BFFs and shared libraries. `eslint`, every plugin
|
|
9
|
+
and the TypeScript parser are direct dependencies of this package, so consumers
|
|
10
|
+
install a single package and never wire up parsers or plugins themselves.
|
|
11
|
+
|
|
12
|
+
> **Flat config only.** Version 6.0.0 and later publish an `eslint.config.mjs`
|
|
13
|
+
> for ESLint v9's flat config. There is no legacy `.eslintrc` export; version 5
|
|
14
|
+
> and earlier used that format.
|
|
12
15
|
|
|
13
16
|
## 📦 Installation
|
|
14
17
|
|
|
@@ -16,23 +19,26 @@ consumers only install this one package.
|
|
|
16
19
|
npm install --save-dev @kununu/eslint-config
|
|
17
20
|
```
|
|
18
21
|
|
|
19
|
-
`typescript` is
|
|
20
|
-
type-aware TypeScript rules
|
|
22
|
+
`typescript` is the only peer dependency (`>=6.0.0`), and it is optional: you
|
|
23
|
+
need it for the type-aware TypeScript rules described below. The package pins
|
|
24
|
+
Node `24.13.1` and npm `11.8.0` in `engines`, matching the toolchain kununu's
|
|
25
|
+
repos run on.
|
|
21
26
|
|
|
22
27
|
## 💻 Usage
|
|
23
28
|
|
|
24
|
-
Create an
|
|
29
|
+
Create an `eslint.config.mjs` in the project root. The config is published as an
|
|
30
|
+
ES module and exports an array of flat-config objects, so spread it:
|
|
25
31
|
|
|
26
32
|
```javascript
|
|
27
33
|
import kununuConfig from '@kununu/eslint-config';
|
|
28
34
|
|
|
29
35
|
export default [
|
|
30
36
|
...kununuConfig,
|
|
31
|
-
//
|
|
37
|
+
// Project-specific overrides go here.
|
|
32
38
|
];
|
|
33
39
|
```
|
|
34
40
|
|
|
35
|
-
|
|
41
|
+
Then add a lint script to `package.json`:
|
|
36
42
|
|
|
37
43
|
```json
|
|
38
44
|
{
|
|
@@ -42,19 +48,21 @@ Add a lint script to `package.json`:
|
|
|
42
48
|
}
|
|
43
49
|
```
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
The [ESLint documentation](https://eslint.org/docs/latest/use/getting-started)
|
|
52
|
+
covers the remaining command-line and configuration options.
|
|
47
53
|
|
|
48
|
-
### TypeScript
|
|
54
|
+
### TypeScript
|
|
49
55
|
|
|
50
|
-
The
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
The TypeScript rules are scoped to `.ts` and `.tsx` files and run through
|
|
57
|
+
`@typescript-eslint/parser` with `projectService` enabled, which discovers your
|
|
58
|
+
`tsconfig.json` automatically. The project therefore needs a `tsconfig.json` at
|
|
59
|
+
its root; without one, the type-aware rules fail. `.js` and `.jsx` files are
|
|
60
|
+
parsed by ESLint's default parser, Espree, with JSX support enabled.
|
|
53
61
|
|
|
54
|
-
###
|
|
62
|
+
### Overrides
|
|
55
63
|
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
Add your own flat-config objects after the spread, and scope them with `files`
|
|
65
|
+
when they should not apply everywhere. The last matching entry wins:
|
|
58
66
|
|
|
59
67
|
```javascript
|
|
60
68
|
import kununuConfig from '@kununu/eslint-config';
|
|
@@ -69,18 +77,20 @@ export default [
|
|
|
69
77
|
{
|
|
70
78
|
files: ['**/*.spec.*'],
|
|
71
79
|
rules: {
|
|
72
|
-
//
|
|
80
|
+
// Test-only adjustments.
|
|
73
81
|
},
|
|
74
82
|
},
|
|
75
83
|
];
|
|
76
84
|
```
|
|
77
85
|
|
|
86
|
+
Flat config replaces a rule's options instead of merging them, so changing a
|
|
87
|
+
single option of an already configured rule means restating that rule's full
|
|
88
|
+
option object.
|
|
89
|
+
|
|
78
90
|
## 🎨 What's included
|
|
79
91
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
`@typescript-eslint/parser` (with `projectService`), **`.js`/`.jsx`** use
|
|
83
|
-
`@babel/eslint-parser`.
|
|
92
|
+
The config is built on `@eslint/js`, `typescript-eslint` and the React
|
|
93
|
+
ecosystem, with kununu's own conventions layered on top.
|
|
84
94
|
|
|
85
95
|
| Area | Plugins |
|
|
86
96
|
| --- | --- |
|
|
@@ -91,33 +101,36 @@ conventions. Parsers are wired up automatically: **`.ts`/`.tsx`** use
|
|
|
91
101
|
| Code smells | `eslint-plugin-sonarjs` |
|
|
92
102
|
| Imports / ordering | `eslint-plugin-perfectionist` |
|
|
93
103
|
| Tests (`*.spec.*`) | `eslint-plugin-jest`, `eslint-plugin-jest-dom`, `eslint-plugin-testing-library` |
|
|
94
|
-
| kununu-specific | `eslint-plugin-lodash`, `eslint-plugin-granular-selectors
|
|
104
|
+
| kununu-specific | `eslint-plugin-lodash`, `eslint-plugin-granular-selectors` |
|
|
95
105
|
|
|
96
106
|
### Notable conventions
|
|
97
107
|
|
|
98
|
-
- **No default React import
|
|
99
|
-
named hooks
|
|
100
|
-
- **Per-method lodash imports
|
|
101
|
-
`import {debounce} from 'lodash'`.
|
|
102
|
-
- **Import ordering** (`perfectionist/sort-imports`): `react
|
|
103
|
-
builtins
|
|
104
|
-
|
|
105
|
-
- **
|
|
106
|
-
|
|
107
|
-
- **
|
|
108
|
-
|
|
109
|
-
- **
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
- **No default React import.** `import React from 'react'` is disallowed; import
|
|
109
|
+
the named hooks and types instead, as in `import {useState} from 'react'`.
|
|
110
|
+
- **Per-method lodash imports.** Use `import debounce from 'lodash/debounce'`
|
|
111
|
+
rather than `import {debounce} from 'lodash'`.
|
|
112
|
+
- **Import ordering** (`perfectionist/sort-imports`): `react`, then types, then
|
|
113
|
+
builtins and externals, then `@kununu/*` internals, then path aliases, then
|
|
114
|
+
relative imports.
|
|
115
|
+
- **Granular Redux selectors** are enforced for `use*Selector*` and `use*Store*`
|
|
116
|
+
hooks.
|
|
117
|
+
- **Formatting** comes from `@stylistic`: 120-character lines (ignoring
|
|
118
|
+
comments, strings and URLs), semicolons and single quotes, among others.
|
|
119
|
+
- **React Compiler rules** such as `react-hooks/refs` and
|
|
120
|
+
`react-hooks/set-state-in-effect` report as warnings, not errors.
|
|
121
|
+
- **Test files** matching `**/*.spec.*` get the Jest globals and the jest,
|
|
122
|
+
jest-dom and testing-library rule sets automatically. A few source-only rules,
|
|
123
|
+
such as `react/prop-types` and `sonarjs/no-hardcoded-passwords`, are relaxed
|
|
124
|
+
there.
|
|
112
125
|
|
|
113
126
|
## ⚡️ Editor integration
|
|
114
127
|
|
|
115
|
-
Linting runs in CI
|
|
116
|
-
recommend the
|
|
128
|
+
Linting runs in CI, and in pre-commit hooks where they are configured, but
|
|
129
|
+
catching problems in the editor is faster. We recommend the
|
|
117
130
|
[ESLint VS Code extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).
|
|
118
131
|
|
|
119
|
-
Recent versions
|
|
120
|
-
legacy format, enable it in `.vscode/settings.json`:
|
|
132
|
+
Recent versions detect flat config on their own. If your editor still falls back
|
|
133
|
+
to the legacy format, enable it explicitly in `.vscode/settings.json`:
|
|
121
134
|
|
|
122
135
|
```json
|
|
123
136
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kununu/eslint-config",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.2",
|
|
4
4
|
"description": "kununu's ESLint config",
|
|
5
5
|
"main": "eslint.config.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -16,8 +16,13 @@
|
|
|
16
16
|
"javascript",
|
|
17
17
|
"typescript"
|
|
18
18
|
],
|
|
19
|
+
"files": [
|
|
20
|
+
"eslint.config.mjs",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
19
23
|
"scripts": {
|
|
20
|
-
"beta": "npm publish --tag=beta"
|
|
24
|
+
"beta": "npm publish --tag=beta",
|
|
25
|
+
"test": "node test/config-loads.mjs"
|
|
21
26
|
},
|
|
22
27
|
"author": "kununu",
|
|
23
28
|
"license": "MIT",
|
|
@@ -32,10 +37,10 @@
|
|
|
32
37
|
"dependencies": {
|
|
33
38
|
"@eslint/js": "9.39.5",
|
|
34
39
|
"@stylistic/eslint-plugin": "5.10.0",
|
|
35
|
-
"@typescript-eslint/parser": "8.
|
|
40
|
+
"@typescript-eslint/parser": "8.67.0",
|
|
36
41
|
"eslint": "9.39.5",
|
|
37
42
|
"eslint-plugin-granular-selectors": "1.5.0",
|
|
38
|
-
"eslint-plugin-jest": "29.16.
|
|
43
|
+
"eslint-plugin-jest": "29.16.1",
|
|
39
44
|
"eslint-plugin-jest-dom": "5.7.0",
|
|
40
45
|
"eslint-plugin-jsx-a11y": "6.10.2",
|
|
41
46
|
"eslint-plugin-lodash": "8.0.0",
|
|
@@ -44,7 +49,7 @@
|
|
|
44
49
|
"eslint-plugin-react-hooks": "7.1.1",
|
|
45
50
|
"eslint-plugin-sonarjs": "4.2.0",
|
|
46
51
|
"eslint-plugin-testing-library": "7.16.2",
|
|
47
|
-
"typescript-eslint": "8.
|
|
52
|
+
"typescript-eslint": "8.67.0"
|
|
48
53
|
},
|
|
49
54
|
"peerDependencies": {
|
|
50
55
|
"typescript": ">=6.0.0"
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
name: Auto assign owner when opening PRs
|
|
2
|
-
on:
|
|
3
|
-
pull_request:
|
|
4
|
-
types: [ opened ]
|
|
5
|
-
jobs:
|
|
6
|
-
auto-assign-owner:
|
|
7
|
-
if: ${{ !startsWith(github.head_ref, 'dependabot/') && !startsWith(github.head_ref, 'release/') }}
|
|
8
|
-
runs-on: ubuntu-latest
|
|
9
|
-
steps:
|
|
10
|
-
- name: Auto assign owner
|
|
11
|
-
uses: danielswensson/auto-assign-owner-action@v1.0.2
|
|
12
|
-
with:
|
|
13
|
-
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
name: Release
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_dispatch:
|
|
5
|
-
inputs:
|
|
6
|
-
version:
|
|
7
|
-
description: "Semver version (major / minor / patch)"
|
|
8
|
-
|
|
9
|
-
required: true
|
|
10
|
-
type: choice
|
|
11
|
-
options:
|
|
12
|
-
- patch
|
|
13
|
-
- minor
|
|
14
|
-
- major
|
|
15
|
-
issue_comment:
|
|
16
|
-
types: [created]
|
|
17
|
-
|
|
18
|
-
env:
|
|
19
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
20
|
-
|
|
21
|
-
permissions:
|
|
22
|
-
id-token: write # Required for OIDC
|
|
23
|
-
contents: write
|
|
24
|
-
pull-requests: write
|
|
25
|
-
|
|
26
|
-
jobs:
|
|
27
|
-
release:
|
|
28
|
-
name: Release
|
|
29
|
-
if: github.event_name == 'workflow_dispatch'
|
|
30
|
-
runs-on: ubuntu-latest
|
|
31
|
-
|
|
32
|
-
steps:
|
|
33
|
-
- name: Generate GitHub App Token
|
|
34
|
-
id: generate_token
|
|
35
|
-
env:
|
|
36
|
-
GITHUB_APP_ID: ${{ secrets.GH_APPS_APP_ID }}
|
|
37
|
-
GITHUB_INST_ID: ${{ secrets.GH_APPS_INSTALLATION_ID }}
|
|
38
|
-
GITHUB_KEY_VALUE: ${{ secrets.GH_APPS_PRIVATE_KEY }}
|
|
39
|
-
run: |
|
|
40
|
-
GO_GITHUB_VERSION="1.0.1"
|
|
41
|
-
wget -O ghapps https://github.com/kununu/go-github/releases/download/v${GO_GITHUB_VERSION}/go-github_${GO_GITHUB_VERSION}_linux_amd64 && chmod +x ghapps
|
|
42
|
-
|
|
43
|
-
echo "GH_APPS_TOKEN=$(./ghapps)" >> $GITHUB_ENV
|
|
44
|
-
echo "GH_TOKEN=$(./ghapps)" >> $GITHUB_ENV
|
|
45
|
-
|
|
46
|
-
- name: Checkout Source
|
|
47
|
-
uses: actions/checkout@v7
|
|
48
|
-
with:
|
|
49
|
-
fetch-depth: 0
|
|
50
|
-
token: ${{ env.GH_APPS_TOKEN }}
|
|
51
|
-
|
|
52
|
-
- name: Setup Node
|
|
53
|
-
uses: actions/setup-node@v6
|
|
54
|
-
with:
|
|
55
|
-
node-version-file: '.nvmrc'
|
|
56
|
-
cache: "npm"
|
|
57
|
-
|
|
58
|
-
- name: Setup git
|
|
59
|
-
run: |
|
|
60
|
-
git config user.name "github-actions[bot]"
|
|
61
|
-
git config user.email "technik@kununu.com"
|
|
62
|
-
|
|
63
|
-
- name: Install Packages
|
|
64
|
-
run: npm ci
|
|
65
|
-
|
|
66
|
-
# avoid npm version to auto-commit, so we can update the version in the changelog in the same commit
|
|
67
|
-
- name: Bump Package Version
|
|
68
|
-
run: |
|
|
69
|
-
npm version ${{ github.event.inputs.version }} --git-tag-version false
|
|
70
|
-
|
|
71
|
-
- name: Get package.json version
|
|
72
|
-
run: |
|
|
73
|
-
PACKAGE_VERSION=$(node -p "require('./package.json').version")
|
|
74
|
-
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
|
|
75
|
-
|
|
76
|
-
- name: Create Release Branch
|
|
77
|
-
run: |
|
|
78
|
-
BRANCH_NAME="release/$PACKAGE_VERSION"
|
|
79
|
-
git checkout -b $BRANCH_NAME
|
|
80
|
-
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
|
|
81
|
-
|
|
82
|
-
- name: Commit Version Changes
|
|
83
|
-
run: |
|
|
84
|
-
git add package.json
|
|
85
|
-
git add package-lock.json
|
|
86
|
-
git commit -m "chore: release $PACKAGE_VERSION"
|
|
87
|
-
git push origin $BRANCH_NAME
|
|
88
|
-
|
|
89
|
-
- name: Create Pull Request
|
|
90
|
-
run: |
|
|
91
|
-
gh pr create \
|
|
92
|
-
--title "chore: release $PACKAGE_VERSION" \
|
|
93
|
-
--body "Automated release PR for version $PACKAGE_VERSION" \
|
|
94
|
-
--base master \
|
|
95
|
-
--head $BRANCH_NAME
|
|
96
|
-
PR_NUMBER=$(gh pr view $BRANCH_NAME --json number --jq '.number')
|
|
97
|
-
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
|
|
98
|
-
|
|
99
|
-
- name: Wait for passed checks
|
|
100
|
-
run: |
|
|
101
|
-
TIMEOUT=300 # 5 minutes
|
|
102
|
-
INTERVAL=10 # 10 seconds
|
|
103
|
-
ELAPSED=0
|
|
104
|
-
sleep $INTERVAL # Initial wait before first check
|
|
105
|
-
while [[ $ELAPSED -lt $TIMEOUT ]]; do
|
|
106
|
-
echo "Waiting for status checks... ($ELAPSED of $TIMEOUT seconds)"
|
|
107
|
-
CHECKS_STATUS=$(gh pr checks "$PR_NUMBER" --json state --jq '.[].state')
|
|
108
|
-
ALL_PASSED=true
|
|
109
|
-
ALL_EXECUTED=true
|
|
110
|
-
|
|
111
|
-
for state in $CHECKS_STATUS; do
|
|
112
|
-
if [[ "$state" == "PENDING" || "$state" == "QUEUED" || "$state" == "IN_PROGRESS" ]]; then
|
|
113
|
-
ALL_EXECUTED=false
|
|
114
|
-
ALL_PASSED=false
|
|
115
|
-
break
|
|
116
|
-
fi
|
|
117
|
-
if [[ "$state" != "SUCCESS" && "$state" != "COMPLETED" && "$state" != "SKIPPED" ]]; then
|
|
118
|
-
ALL_PASSED=false
|
|
119
|
-
fi
|
|
120
|
-
done
|
|
121
|
-
|
|
122
|
-
if $ALL_EXECUTED && $ALL_PASSED; then
|
|
123
|
-
echo "All checks passed for PR #$PR_NUMBER."
|
|
124
|
-
exit 0
|
|
125
|
-
fi
|
|
126
|
-
|
|
127
|
-
if $ALL_EXECUTED; then
|
|
128
|
-
if $ALL_PASSED; then
|
|
129
|
-
echo "All checks passed for PR #$PR_NUMBER."
|
|
130
|
-
exit 0
|
|
131
|
-
else
|
|
132
|
-
echo "All checks executed but some failed for PR #$PR_NUMBER."
|
|
133
|
-
exit 1
|
|
134
|
-
fi
|
|
135
|
-
fi
|
|
136
|
-
|
|
137
|
-
sleep $INTERVAL
|
|
138
|
-
ELAPSED=$((ELAPSED + INTERVAL))
|
|
139
|
-
done
|
|
140
|
-
echo "Timeout: Checks did not pass within $TIMEOUT seconds for PR #$PR_NUMBER."
|
|
141
|
-
exit 1
|
|
142
|
-
|
|
143
|
-
- name: Merge PR
|
|
144
|
-
run: |
|
|
145
|
-
gh pr merge $PR_NUMBER --squash --delete-branch --admin
|
|
146
|
-
|
|
147
|
-
- name: Checkout Master and Tag
|
|
148
|
-
run: |
|
|
149
|
-
git fetch origin
|
|
150
|
-
git checkout master
|
|
151
|
-
git pull origin master
|
|
152
|
-
git tag $PACKAGE_VERSION
|
|
153
|
-
git push origin --tags
|
|
154
|
-
|
|
155
|
-
# leave npm publish to the end, so we avoid publishing a version that did not finish the entire flow
|
|
156
|
-
- name: Publish
|
|
157
|
-
run: |
|
|
158
|
-
npm publish
|
|
159
|
-
|
|
160
|
-
- name: Create Github Release
|
|
161
|
-
run: |
|
|
162
|
-
gh release create $PACKAGE_VERSION --generate-notes
|
|
163
|
-
|
|
164
|
-
release-beta:
|
|
165
|
-
name: Release Beta version
|
|
166
|
-
# check if the comment comes from a pull request and contains the command `/release-beta`
|
|
167
|
-
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '/release-beta')
|
|
168
|
-
runs-on: ubuntu-latest
|
|
169
|
-
|
|
170
|
-
steps:
|
|
171
|
-
- name: Generate GitHub App Token
|
|
172
|
-
id: generate_token
|
|
173
|
-
env:
|
|
174
|
-
GITHUB_APP_ID: ${{ secrets.GH_APPS_APP_ID }}
|
|
175
|
-
GITHUB_INST_ID: ${{ secrets.GH_APPS_INSTALLATION_ID }}
|
|
176
|
-
GITHUB_KEY_VALUE: ${{ secrets.GH_APPS_PRIVATE_KEY }}
|
|
177
|
-
run: |
|
|
178
|
-
GO_GITHUB_VERSION="1.0.1"
|
|
179
|
-
wget -O ghapps https://github.com/kununu/go-github/releases/download/v${GO_GITHUB_VERSION}/go-github_${GO_GITHUB_VERSION}_linux_amd64 && chmod +x ghapps
|
|
180
|
-
|
|
181
|
-
echo "GH_APPS_TOKEN=$(./ghapps)" >> $GITHUB_ENV
|
|
182
|
-
echo "GH_TOKEN=$(./ghapps)" >> $GITHUB_ENV
|
|
183
|
-
|
|
184
|
-
- name: Checkout Source
|
|
185
|
-
uses: actions/checkout@v7
|
|
186
|
-
with:
|
|
187
|
-
fetch-depth: 0
|
|
188
|
-
token: ${{ env.GH_APPS_TOKEN }}
|
|
189
|
-
|
|
190
|
-
- name: Checkout to PR branch
|
|
191
|
-
run: |
|
|
192
|
-
PR_NUMBER=${{ github.event.issue.number }}
|
|
193
|
-
gh pr checkout $PR_NUMBER
|
|
194
|
-
BRANCH_NAME=$(gh pr view $PR_NUMBER --json headRefName --jq '.headRefName')
|
|
195
|
-
echo "BRANCH_NAME=$BRANCH_NAME" >> "$GITHUB_ENV"
|
|
196
|
-
|
|
197
|
-
- name: Setup Node
|
|
198
|
-
uses: actions/setup-node@v6
|
|
199
|
-
with:
|
|
200
|
-
node-version-file: '.nvmrc'
|
|
201
|
-
cache: "npm"
|
|
202
|
-
|
|
203
|
-
- name: Setup git
|
|
204
|
-
run: |
|
|
205
|
-
git config user.name "github-actions[bot]"
|
|
206
|
-
git config user.email "technik@kununu.com"
|
|
207
|
-
|
|
208
|
-
- name: Install Packages
|
|
209
|
-
run: npm ci
|
|
210
|
-
|
|
211
|
-
- name: Set beta version and publish
|
|
212
|
-
run: |
|
|
213
|
-
# Get the current branch name
|
|
214
|
-
current_branch=${{ env.BRANCH_NAME }}
|
|
215
|
-
echo "Current branch name: $current_branch"
|
|
216
|
-
|
|
217
|
-
# Sanitize the branch name to the semver prerelease-legal charset [0-9A-Za-z-]
|
|
218
|
-
# so branch names containing e.g. "/" do not produce an invalid version
|
|
219
|
-
SAFE_BRANCH=$(printf '%s' "$current_branch" | sed 's/[^0-9A-Za-z-]/-/g')
|
|
220
|
-
echo "Sanitized branch name: $SAFE_BRANCH"
|
|
221
|
-
|
|
222
|
-
# Get the current version from package.json
|
|
223
|
-
current_version=$(npm pkg get version --json | tr -d '"')
|
|
224
|
-
echo "Current package.json version: $current_version"
|
|
225
|
-
|
|
226
|
-
# Check if the current version does not contain beta
|
|
227
|
-
if echo "$current_version" | grep -q "-beta."; then
|
|
228
|
-
# If the current version contains beta,
|
|
229
|
-
# increment the pre-release version
|
|
230
|
-
npm --no-git-tag-version version prerelease -f
|
|
231
|
-
else
|
|
232
|
-
# If the current version does not contain beta,
|
|
233
|
-
# set the pre-release version to beta including the branch name and increment the version
|
|
234
|
-
npm --no-git-tag-version version prepatch --preid=${SAFE_BRANCH}-beta -f
|
|
235
|
-
fi
|
|
236
|
-
|
|
237
|
-
# Publish the package with the beta tag
|
|
238
|
-
npm publish --tag beta
|
|
239
|
-
|
|
240
|
-
- name: Get package.json version
|
|
241
|
-
run: |
|
|
242
|
-
PACKAGE_VERSION=$(node -p "require('./package.json').version")
|
|
243
|
-
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
|
|
244
|
-
|
|
245
|
-
- name: Commit changes
|
|
246
|
-
run: |
|
|
247
|
-
git add .
|
|
248
|
-
if ! git diff --cached --quiet; then
|
|
249
|
-
git commit -m "Update beta version to ${PACKAGE_VERSION}"
|
|
250
|
-
else
|
|
251
|
-
echo "No changes to commit"
|
|
252
|
-
fi
|
|
253
|
-
git push
|
|
254
|
-
|
|
255
|
-
- name: Create comment in PR
|
|
256
|
-
uses: actions/github-script@v9
|
|
257
|
-
env:
|
|
258
|
-
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
|
|
259
|
-
with:
|
|
260
|
-
script: |
|
|
261
|
-
github.rest.issues.createComment({
|
|
262
|
-
issue_number: context.issue.number,
|
|
263
|
-
owner: context.repo.owner,
|
|
264
|
-
repo: context.repo.repo,
|
|
265
|
-
body: `## New beta version released
|
|
266
|
-
|
|
267
|
-
The new beta version **\`${process.env.PACKAGE_VERSION}\`** of \`@kununu/eslint-config\` has been released.
|
|
268
|
-
|
|
269
|
-
Install the new version in your app
|
|
270
|
-
|
|
271
|
-
\`\`\`
|
|
272
|
-
npm install @kununu/eslint-config@${process.env.PACKAGE_VERSION}
|
|
273
|
-
\`\`\`
|
|
274
|
-
|
|
275
|
-
> [!IMPORTANT]
|
|
276
|
-
>
|
|
277
|
-
> **Don't forget to remove the beta version in the \`package.json\` and \`package-lock.json\` before merging**`
|
|
278
|
-
})
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
v24.13.1
|