@kununu/eslint-config 7.3.1 → 7.3.3-test-verify-sanitize-beta.0

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.
@@ -12,19 +12,23 @@ on:
12
12
  - patch
13
13
  - minor
14
14
  - major
15
+ issue_comment:
16
+ types: [created]
15
17
 
16
18
  env:
17
19
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18
20
 
21
+ permissions:
22
+ id-token: write # Required for OIDC
23
+ contents: write
24
+ pull-requests: write
25
+
19
26
  jobs:
20
27
  release:
28
+ name: Release
29
+ if: github.event_name == 'workflow_dispatch'
21
30
  runs-on: ubuntu-latest
22
31
 
23
- permissions:
24
- id-token: write # Required for OIDC
25
- contents: write
26
- pull-requests: write
27
-
28
32
  steps:
29
33
  - name: Generate GitHub App Token
30
34
  id: generate_token
@@ -40,7 +44,7 @@ jobs:
40
44
  echo "GH_TOKEN=$(./ghapps)" >> $GITHUB_ENV
41
45
 
42
46
  - name: Checkout Source
43
- uses: actions/checkout@v6
47
+ uses: actions/checkout@v7
44
48
  with:
45
49
  fetch-depth: 0
46
50
  token: ${{ env.GH_APPS_TOKEN }}
@@ -51,10 +55,6 @@ jobs:
51
55
  node-version-file: '.nvmrc'
52
56
  cache: "npm"
53
57
 
54
- # Ensure npm 11.5.1 or later is installed
55
- - name: Update npm
56
- run: npm install -g npm@latest
57
-
58
58
  - name: Setup git
59
59
  run: |
60
60
  git config user.name "github-actions[bot]"
@@ -68,9 +68,10 @@ jobs:
68
68
  run: |
69
69
  npm version ${{ github.event.inputs.version }} --git-tag-version false
70
70
 
71
- - name: Read NPM package version from package.json
71
+ - name: Get package.json version
72
72
  run: |
73
- echo "PACKAGE_VERSION=$(sed -n 's/.*\"version\": \"\([^\"]*\)\".*/\1/p' package.json)" >> "$GITHUB_ENV"
73
+ PACKAGE_VERSION=$(node -p "require('./package.json').version")
74
+ echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
74
75
 
75
76
  - name: Create Release Branch
76
77
  run: |
@@ -159,3 +160,119 @@ jobs:
159
160
  - name: Create Github Release
160
161
  run: |
161
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/eslint.config.mjs CHANGED
@@ -1,5 +1,3 @@
1
- import babelParser from '@babel/eslint-parser';
2
- import babelPlugin from '@babel/eslint-plugin';
3
1
  import js from '@eslint/js';
4
2
  import stylistic from '@stylistic/eslint-plugin';
5
3
  import typescriptParser from '@typescript-eslint/parser';
@@ -25,8 +23,8 @@ export default defineConfig([
25
23
  reactPlugin.configs.flat['jsx-runtime'],
26
24
  sonarjs.configs.recommended,
27
25
  stylistic.configs.recommended,
28
- // Scope the TypeScript rules to TS files only; .js/.jsx use the Babel parser
29
- // below and would otherwise run type-aware rules under the wrong parser.
26
+ // Scope the TypeScript rules to TS files only; .js/.jsx use ESLint's default
27
+ // parser (Espree) and would otherwise run type-aware rules under the wrong parser.
30
28
  ...tseslint.configs.recommended.map(config => ({
31
29
  ...config,
32
30
  files: ['**/*.ts', '**/*.tsx'],
@@ -69,17 +67,12 @@ export default defineConfig([
69
67
  },
70
68
  },
71
69
 
70
+ // Register .js/.jsx as linted extensions so they run through ESLint's default
71
+ // parser (Espree). ESLint lints .js by default but only picks up .jsx when a
72
+ // config's `files` names it; the global ecmaFeatures.jsx setting below lets
73
+ // Espree parse the JSX.
72
74
  {
73
75
  files: ['**/*.js', '**/*.jsx'],
74
- languageOptions: {
75
- parser: babelParser,
76
- parserOptions: {
77
- requireConfigFile: false,
78
- },
79
- },
80
- plugins: {
81
- babel: babelPlugin,
82
- },
83
76
  },
84
77
 
85
78
  // Test-only configs. Spread as separate entries so their plugins/rules
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kununu/eslint-config",
3
- "version": "7.3.1",
3
+ "version": "7.3.3-test-verify-sanitize-beta.0",
4
4
  "description": "kununu's ESLint config",
5
5
  "main": "eslint.config.mjs",
6
6
  "type": "module",
@@ -30,9 +30,6 @@
30
30
  },
31
31
  "homepage": "https://github.com/kununu/eslint-config#readme",
32
32
  "dependencies": {
33
- "@babel/core": "8.0.1",
34
- "@babel/eslint-parser": "8.0.1",
35
- "@babel/eslint-plugin": "8.0.1",
36
33
  "@eslint/js": "9.39.4",
37
34
  "@stylistic/eslint-plugin": "5.10.0",
38
35
  "@typescript-eslint/parser": "8.63.0",
@@ -50,7 +47,7 @@
50
47
  "typescript-eslint": "8.63.0"
51
48
  },
52
49
  "peerDependencies": {
53
- "typescript": ">=5.0.0"
50
+ "typescript": ">=6.0.0"
54
51
  },
55
52
  "peerDependenciesMeta": {
56
53
  "typescript": {