Skip to content

Commit c206658

Browse files
Merge pull request #1201 from nextcloud-libraries/dependabot/npm_and_yarn/eslint-9.39.0
2 parents 15216de + 91db337 commit c206658

File tree

11 files changed

+111
-62
lines changed

11 files changed

+111
-62
lines changed

.github/workflows/dependabot-approve-merge.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# https://github.com/nextcloud-libraries/.github
44
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
55
#
6-
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
6+
# SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
77
# SPDX-License-Identifier: MIT
88

9-
name: Dependabot
9+
name: Auto approve Dependabot PRs
1010

1111
on:
1212
pull_request_target: # zizmor: ignore[dangerous-triggers]
@@ -29,6 +29,8 @@ jobs:
2929
permissions:
3030
# for hmarr/auto-approve-action to approve PRs
3131
pull-requests: write
32+
# for alexwilson/enable-github-automerge-action to approve PRs
33+
contents: write
3234

3335
steps:
3436
- name: Disabled on forks
@@ -37,13 +39,20 @@ jobs:
3739
echo 'Can not approve PRs from forks'
3840
exit 1
3941
42+
- uses: mdecoleman/pr-branch-name@55795d86b4566d300d237883103f052125cc7508 # v3.0.0
43+
id: branchname
44+
with:
45+
repo-token: ${{ secrets.GITHUB_TOKEN }}
46+
4047
# GitHub actions bot approve
41-
- uses: hmarr/auto-approve-action@b40d6c9ed2fa10c9a2749eca7eb004418a705501 # v2
48+
- uses: hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363 # v4.0.0
49+
if: startsWith(steps.branchname.outputs.branch, 'dependabot/')
4250
with:
4351
github-token: ${{ secrets.GITHUB_TOKEN }}
4452

45-
# Nextcloud bot approve and merge request
46-
- uses: ahmadnassri/action-dependabot-auto-merge@45fc124d949b19b6b8bf6645b6c9d55f4f9ac61a # v2
53+
# Enable GitHub auto merge
54+
- name: Auto merge
55+
uses: alexwilson/enable-github-automerge-action@56e3117d1ae1540309dc8f7a9f2825bc3c5f06ff # v2.0.0
56+
if: startsWith(steps.branchname.outputs.branch, 'dependabot/')
4757
with:
48-
target: minor
49-
github-token: ${{ secrets.DEPENDABOT_AUTOMERGE_TOKEN }}
58+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/lint-eslint.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,17 @@ jobs:
2929
with:
3030
persist-credentials: false
3131

32+
- name: Read package.json
33+
uses: nextcloud-libraries/parse-package-engines-action@122ae05d4257008180a514e1ddeb0c1b9d094bdd # v0.1.0
34+
id: versions
35+
3236
- name: Set up node
33-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
37+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
3438
with:
35-
node-version-file: 'package.json'
39+
node-version: ${{ steps.versions.outputs.node-version }}
40+
41+
- name: Set up npm
42+
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'
3643

3744
- name: Install dependencies
3845
env:

.github/workflows/node-test.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,17 @@ jobs:
3434
with:
3535
persist-credentials: false
3636

37+
- name: Read package.json
38+
uses: nextcloud-libraries/parse-package-engines-action@122ae05d4257008180a514e1ddeb0c1b9d094bdd # v0.1.0
39+
id: versions
40+
3741
- name: Set up node
38-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
42+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
3943
with:
40-
node-version-file: 'package.json'
44+
node-version: ${{ steps.versions.outputs.node-version }}
45+
46+
- name: Set up npm
47+
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'
4148

4249
- name: Install dependencies & build
4350
env:
@@ -56,3 +63,5 @@ jobs:
5663
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
5764
with:
5865
files: ./coverage/lcov.info
66+
env:
67+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/node.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,23 @@ jobs:
2828
with:
2929
persist-credentials: false
3030

31+
- name: Read package.json
32+
uses: nextcloud-libraries/parse-package-engines-action@122ae05d4257008180a514e1ddeb0c1b9d094bdd # v0.1.0
33+
id: versions
34+
3135
- name: Set up node
32-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
36+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
3337
with:
34-
node-version-file: 'package.json'
38+
node-version: ${{ steps.versions.outputs.node-version }}
39+
40+
- name: Set up npm
41+
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'
42+
43+
- name: Validate package-lock.json # See https://github.com/npm/cli/issues/4460
44+
run: |
45+
46+
npm-package-lock-add-resolved
47+
git --no-pager diff --exit-code
3548
3649
- name: Install dependencies & build
3750
env:

.github/workflows/npm-publish.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,17 @@ jobs:
2727
with:
2828
persist-credentials: false
2929

30+
- name: Read package.json
31+
uses: nextcloud-libraries/parse-package-engines-action@122ae05d4257008180a514e1ddeb0c1b9d094bdd # v0.1.0
32+
id: versions
33+
3034
- name: Set up node
31-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
35+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
3236
with:
33-
node-version-file: 'package.json'
37+
node-version: ${{ steps.versions.outputs.node-version }}
38+
39+
- name: Set up npm
40+
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'
3441

3542
- name: Check tag matches package.json
3643
run: |

lib/configs/codeStyle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import l10nPlugin from '../plugins/l10n/index.ts'
2020
*
2121
* @param options options defining the config preset flavor
2222
*/
23-
export function codeStyle(options: ConfigOptions): (Linter.Config | Linter.BaseConfig)[] {
23+
export function codeStyle(options: ConfigOptions): Linter.Config[] {
2424
return [
2525
// Nextcloud code style
2626
{

lib/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
5+
6+
import type { Linter } from 'eslint'
57
import type { ConfigOptions } from './types.d.ts'
68

79
import { codeStyle } from './configs/codeStyle.ts'
@@ -18,7 +20,7 @@ import { vue3 } from './configs/vue3.ts'
1820
/**
1921
* Nextcloud shared configuration for projects using Vue 2 with Javascript <script> blocks
2022
*/
21-
export const recommendedVue2Javascript = createConfig({
23+
export const recommendedVue2Javascript: Linter.Config[] = createConfig({
2224
isLibrary: false,
2325
vue2: true,
2426
vueIsTypescript: false,
@@ -27,7 +29,7 @@ export const recommendedVue2Javascript = createConfig({
2729
/**
2830
* Nextcloud shared configuration for projects using Vue 2 with Typescript <script> blocks
2931
*/
30-
export const recommendedVue2 = createConfig({
32+
export const recommendedVue2: Linter.Config[] = createConfig({
3133
isLibrary: false,
3234
vue2: true,
3335
vueIsTypescript: true,
@@ -36,31 +38,31 @@ export const recommendedVue2 = createConfig({
3638
/**
3739
* Nextcloud shared configuration for projects using Vue 3 with Javascript <script> blocks
3840
*/
39-
export const recommendedJavascript = createConfig({
41+
export const recommendedJavascript: Linter.Config[] = createConfig({
4042
isLibrary: false,
4143
vueIsTypescript: false,
4244
})
4345

4446
/**
4547
* Nextcloud shared configuration for projects using Vue 3 with Typescript <script> blocks
4648
*/
47-
export const recommended = createConfig({
49+
export const recommended: Linter.Config[] = createConfig({
4850
isLibrary: false,
4951
vueIsTypescript: true,
5052
})
5153

5254
/**
5355
* Nextcloud shared configuration for projects using Vue 3 with Typescript <script> blocks
5456
*/
55-
export const recommendedLibrary = createConfig({
57+
export const recommendedLibrary: Linter.Config[] = createConfig({
5658
isLibrary: true,
5759
vueIsTypescript: true,
5860
})
5961

6062
/**
6163
* Nextcloud shared configuration for projects using Vue 3 with Typescript <script> blocks
6264
*/
63-
export const recommendedVue2Library = createConfig({
65+
export const recommendedVue2Library: Linter.Config[] = createConfig({
6466
isLibrary: true,
6567
vue2: true,
6668
vueIsTypescript: true,
@@ -75,7 +77,7 @@ export { default as l10nPlugin } from './plugins/l10n/index.ts'
7577
*
7678
* @param options - Configuration options
7779
*/
78-
function createConfig(options: ConfigOptions & { vue2?: boolean }) {
80+
function createConfig(options: ConfigOptions & { vue2?: boolean }): Linter.Config[] {
7981
return [
8082
...filesystem,
8183
...javascript(options),

lib/plugins/packageJson.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6+
import type { JSONRuleDefinition, JSONRuleVisitor } from '@eslint/json/types'
67
import type { ESLint, Rule } from 'eslint'
78

89
import path from 'node:path'
910
import sortPackageJson from 'sort-package-json'
1011
import { packageVersion } from '../version.ts'
1112

12-
const SortPackageJsonRule: Rule.RuleModule = {
13+
const SortPackageJsonRule: JSONRuleDefinition = {
1314
meta: {
1415
fixable: 'code',
1516
docs: {
@@ -33,7 +34,7 @@ const SortPackageJsonRule: Rule.RuleModule = {
3334
],
3435
},
3536

36-
create(context: Rule.RuleContext): Rule.RuleListener {
37+
create(context) {
3738
if (path.basename(context.filename) !== 'package.json') {
3839
return {}
3940
}
@@ -51,12 +52,13 @@ const SortPackageJsonRule: Rule.RuleModule = {
5152
node: body,
5253
message: 'package.json is not sorted correctly',
5354
fix(fixer: Rule.RuleFixer): Rule.Fix {
55+
// @ts-expect-error its always an object node
5456
return fixer.replaceText(body, sortedPackageJsonText)
5557
},
5658
})
5759
}
5860
},
59-
} satisfies Rule.NodeListener
61+
} as JSONRuleVisitor
6062
},
6163
}
6264

@@ -69,6 +71,7 @@ const Plugin: ESLint.Plugin = {
6971
version: packageVersion,
7072
},
7173
rules: {
74+
// @ts-expect-error ESLint is missing some API for language-specific rules
7275
'sort-package-json': SortPackageJsonRule,
7376
},
7477
}

lib/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { Linter } from 'eslint'
1111
* @param configs The configs to restrict
1212
* @param files The glob pattern to assign
1313
*/
14-
export function restrictConfigFiles(configs: Linter.Config[], files: string[]) {
14+
export function restrictConfigFiles(configs: Linter.Config[], files: string[]): Linter.Config[] {
1515
return configs.map((config) => ({
1616
...config,
1717
files: [

0 commit comments

Comments
 (0)