Skip to content

Commit f457004

Browse files
authored
Merge pull request #63 from trojs/feature/trojs-lint
Use TroJS lint rules
2 parents 556c00b + 7ad157f commit f457004

14 files changed

Lines changed: 2086 additions & 5533 deletions

.github/workflows/cpd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88

99
steps:
1010
- uses: actions/checkout@v4
11-
- name: Use Node.js 20
11+
- name: Use Node.js 24
1212
uses: actions/setup-node@v4
1313
with:
14-
node-version: 20
14+
node-version: 24
1515
cache: "npm"
1616
- name: npm cpd
1717
run: |

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88

99
steps:
1010
- uses: actions/checkout@v4
11-
- name: Use Node.js 20
11+
- name: Use Node.js 24
1212
uses: actions/setup-node@v4
1313
with:
14-
node-version: 20
14+
node-version: 24
1515
cache: "npm"
1616
- name: npm lint
1717
run: |

.github/workflows/npm-publish.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3-
41
name: Node.js Package
52

63
on:
@@ -14,7 +11,7 @@ jobs:
1411
- uses: actions/checkout@v4
1512
- uses: actions/setup-node@v4
1613
with:
17-
node-version: 20
14+
node-version: 24
1815
- run: npm ci
1916
- run: npm test
2017

@@ -23,12 +20,27 @@ jobs:
2320
runs-on: ubuntu-latest
2421
steps:
2522
- uses: actions/checkout@v4
23+
with:
24+
token: ${{ secrets.GH_PAT }} # Use your PAT here!
2625
- uses: actions/setup-node@v4
2726
with:
28-
node-version: 20
27+
node-version: 24
2928
registry-url: https://registry.npmjs.org/
3029
- run: npm ci
30+
- name: Set version from tag
31+
run: |
32+
git config user.name "github-actions[bot]"
33+
git config user.email "github-actions[bot]@users.noreply.github.com"
34+
TAG=${GITHUB_REF#refs/tags/}
35+
TAG=${TAG#v}
36+
git fetch origin main
37+
git checkout main
38+
git pull
39+
npm version $TAG --no-git-tag-version
40+
git add package.json package-lock.json
41+
git commit -m "ci: set version to $TAG [skip ci]" || true
42+
git push origin main
3143
- run: npm run build --if-present
3244
- run: npm publish --access public
3345
env:
34-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
46+
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}

.github/workflows/sonarcloud.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88

99
steps:
1010
- uses: actions/checkout@v4
11-
- name: Use Node.js 20
11+
- name: Use Node.js 24
1212
uses: actions/setup-node@v4
1313
with:
14-
node-version: 20
14+
node-version: 24
1515
cache: "npm"
1616
- name: npm install, lint, and test
1717
run: |

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
strategy:
1010
matrix:
11-
node-version: [18.x, 20.x, 21.x, 22.x]
11+
node-version: [20.x, 21.x, 22.x, 23.x, 24.x]
1212

1313
steps:
1414
- uses: actions/checkout@v4

.github/workflows/vulnerabilities.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88

99
steps:
1010
- uses: actions/checkout@v4
11-
- name: Use Node.js 20
11+
- name: Use Node.js 24
1212
uses: actions/setup-node@v4
1313
with:
14-
node-version: 20
14+
node-version: 24
1515
cache: "npm"
1616
- name: npm vulnerabilities
1717
run: |

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22.11.0
1+
24

coverage/.gitkeep

Whitespace-only changes.

eslint.config.js

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,27 @@
1-
import globals from 'globals';
2-
import pluginJs from '@eslint/js';
3-
import jsdoc from 'eslint-plugin-jsdoc';
4-
import stylisticJs from '@stylistic/eslint-plugin-js'
5-
import sonarjs from 'eslint-plugin-sonarjs';
1+
import globals from 'globals'
2+
import { plugins, rules } from '@trojs/lint'
63

74
export default [
8-
sonarjs.configs.recommended,
95
{
10-
11-
files: ['**/*.js'],
12-
languageOptions: { globals: globals.node },
13-
6+
languageOptions: {
7+
ecmaVersion: 'latest',
8+
sourceType: 'module',
9+
globals: {
10+
...globals.node,
11+
...globals.es2024
12+
}
13+
},
14+
settings: {
15+
jsdoc: {
16+
mode: 'typescript'
17+
}
18+
},
1419
plugins: {
15-
'@stylistic/js': stylisticJs,
16-
jsdoc: jsdoc
20+
...plugins
1721
},
1822
rules: {
19-
'@stylistic/js/indent': ['error', 2],
20-
'consistent-return': [
21-
'error'
22-
],
23-
'no-param-reassign': [
24-
'error',
25-
{
26-
'props': true,
27-
'ignorePropertyModificationsFor': [
28-
'acc',
29-
'accumulator',
30-
'e',
31-
'req',
32-
'request',
33-
'res',
34-
'response'
35-
]
36-
}
37-
],
38-
'quotes': [
39-
'error',
40-
'single',
41-
{
42-
'avoidEscape': true,
43-
'allowTemplateLiterals': true
44-
}
45-
],
46-
}
47-
},
48-
pluginJs.configs.recommended,
49-
];
23+
...rules.all
24+
},
25+
files: ['**/*.js']
26+
}
27+
]

0 commit comments

Comments
 (0)