Skip to content

Commit a8bb46a

Browse files
committed
switch lint stack to Oxlint + Oxfmt, add CI lint, address warnings
1 parent 75ab75a commit a8bb46a

16 files changed

Lines changed: 355 additions & 887 deletions

File tree

.github/workflows/lint.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: '🔍️ Lint Code'
2+
on: [pull_request]
3+
4+
jobs:
5+
test:
6+
runs-on: ubuntu-latest
7+
name: Lint code
8+
steps:
9+
- name: '🚚 Checkout'
10+
uses: actions/checkout@v6
11+
- name: '🔧 Setup Node'
12+
uses: actions/setup-node@v6
13+
with:
14+
node-version: ${{ matrix.node }}
15+
- name: '📦️ Install dependencies'
16+
run: yarn
17+
- name: '🔍️ Run lint and format checks'
18+
run: yarn lint

.github/workflows/tests.yml

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,33 @@ jobs:
99
node: [22, 24]
1010
name: Testing on Node ${{ matrix.node }}
1111
steps:
12-
- name: '🚚 Checkout'
13-
uses: actions/checkout@v6
14-
- name: '🔧 Setup Node'
15-
uses: actions/setup-node@v6
16-
with:
17-
node-version: ${{ matrix.node }}
18-
- name: '📦️ Install dependencies'
19-
run: yarn
20-
- name: '🧪 Run Unit tests'
21-
run: yarn test
22-
- name: '⚗️ Run CI Classic test'
23-
uses: ./
24-
with:
25-
path: tests/ci/classic/yarn.lock
26-
token: ${{ secrets.GITHUB_TOKEN }}
27-
- name: '⚗️ Run CI Berry v2 test'
28-
uses: ./
29-
with:
30-
path: tests/ci/berry-v2/yarn.lock
31-
token: ${{ secrets.GITHUB_TOKEN }}
32-
- name: '⚗️ Run CI Berry v3 test'
33-
uses: ./
34-
with:
35-
path: tests/ci/berry-v3/yarn.lock
36-
token: ${{ secrets.GITHUB_TOKEN }}
37-
- name: '⚗️ Run CI Berry v4 test'
38-
uses: ./
39-
with:
40-
path: tests/ci/berry-v4/yarn.lock
41-
token: ${{ secrets.GITHUB_TOKEN }}
12+
- name: '🚚 Checkout'
13+
uses: actions/checkout@v6
14+
- name: '🔧 Setup Node'
15+
uses: actions/setup-node@v6
16+
with:
17+
node-version: ${{ matrix.node }}
18+
- name: '📦️ Install dependencies'
19+
run: yarn
20+
- name: '🧪 Run Unit tests'
21+
run: yarn test
22+
- name: '⚗️ Run CI Classic test'
23+
uses: ./
24+
with:
25+
path: tests/ci/classic/yarn.lock
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
- name: '⚗️ Run CI Berry v2 test'
28+
uses: ./
29+
with:
30+
path: tests/ci/berry-v2/yarn.lock
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
- name: '⚗️ Run CI Berry v3 test'
33+
uses: ./
34+
with:
35+
path: tests/ci/berry-v3/yarn.lock
36+
token: ${{ secrets.GITHUB_TOKEN }}
37+
- name: '⚗️ Run CI Berry v4 test'
38+
uses: ./
39+
with:
40+
path: tests/ci/berry-v4/yarn.lock
41+
token: ${{ secrets.GITHUB_TOKEN }}

.oxfmtrc.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"printWidth": 120,
4+
"tabWidth": 2,
5+
"singleQuote": true,
6+
"bracketSameLine": true,
7+
"trailingComma": "es5",
8+
"arrowParens": "avoid",
9+
"ignorePatterns": ["**/dist"],
10+
"experimentalSortPackageJson": false,
11+
"experimentalSortImports": {
12+
"groups": [
13+
["side-effect"],
14+
["builtin", "external", "external-type"],
15+
["internal", "internal-type"],
16+
["parent", "parent-type"],
17+
["sibling", "sibling-type"],
18+
["index", "index-type"]
19+
]
20+
}
21+
}

.oxlintrc.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["import", "promise", "unicorn"],
4+
"ignorePatterns": ["**/dist"],
5+
"rules": {
6+
"curly": "error",
7+
"eqeqeq": ["error", "always", { "null": "ignore" }],
8+
"func-style": ["error", "declaration"],
9+
"no-unused-expressions": ["error", { "allowShortCircuit": true, "enforceForJSX": true }],
10+
"no-unused-vars": [
11+
"error",
12+
{
13+
"vars": "all",
14+
"args": "none",
15+
"ignoreRestSiblings": true,
16+
"caughtErrors": "all",
17+
"caughtErrorsIgnorePattern": "^_"
18+
}
19+
],
20+
"no-useless-computed-key": "error",
21+
"no-useless-concat": "error",
22+
"no-useless-constructor": "error",
23+
"no-useless-return": "error",
24+
"no-void": ["error", { "allowAsStatement": true }],
25+
"prefer-promise-reject-errors": "error",
26+
"prefer-rest-params": "error",
27+
"prefer-spread": "error",
28+
"sort-imports": ["error", { "allowSeparatedGroups": true, "ignoreDeclarationSort": true, "ignoreCase": true }],
29+
"import/consistent-type-specifier-style": ["error", "prefer-inline"],
30+
"import/default": "error",
31+
"import/namespace": "error",
32+
"import/no-cycle": ["error", { "maxDepth": 3 }],
33+
"import/no-duplicates": "error",
34+
"import/no-named-as-default": "error",
35+
"import/no-named-as-default-member": "error",
36+
"import/no-self-import": "error",
37+
"promise/always-return": "error",
38+
"promise/no-callback-in-promise": "error",
39+
"unicorn/consistent-date-clone": "error",
40+
"unicorn/consistent-empty-array-spread": "error",
41+
"unicorn/consistent-existence-index-check": "error",
42+
"unicorn/error-message": "error",
43+
"unicorn/no-anonymous-default-export": "error",
44+
"unicorn/no-immediate-mutation": "error",
45+
"unicorn/no-length-as-slice-end": "error",
46+
"unicorn/no-object-as-default-parameter": "error",
47+
"unicorn/no-unnecessary-array-splice-count": "error",
48+
"unicorn/no-useless-collection-argument": "error",
49+
"unicorn/numeric-separators-style": "error",
50+
"unicorn/prefer-array-flat": "error",
51+
"unicorn/prefer-array-flat-map": "error",
52+
"unicorn/prefer-array-some": "error",
53+
"unicorn/prefer-date-now": "error",
54+
"unicorn/prefer-includes": "error",
55+
"unicorn/prefer-keyboard-event-key": "error",
56+
"unicorn/prefer-math-min-max": "error",
57+
"unicorn/prefer-native-coercion-functions": "error",
58+
"unicorn/prefer-node-protocol": "error",
59+
"unicorn/prefer-number-properties": "error",
60+
"unicorn/prefer-regexp-test": "error",
61+
"unicorn/prefer-string-slice": "error",
62+
"unicorn/require-number-to-fixed-digits-argument": "error"
63+
}
64+
}

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ jobs:
3838
3939
> [!note]
4040
> For Node <22 support, you can change the action version tag in your workflow to `v0.12`:
41+
>
4142
> ```yml
4243
> - name: Yarn Lock Changes
4344
> uses: Simek/yarn-lock-changes@v0.12
4445
> ```
4546
>
4647
> For Node <18 support, you can change the action version tag in your workflow to `v0.11`:
48+
>
4749
> ```yml
4850
> - name: Yarn Lock Changes
4951
> uses: Simek/yarn-lock-changes@v0.11
@@ -52,10 +54,10 @@ jobs:
5254
### 🔌 Inputs
5355

5456
| Input | Required | Default | Description |
55-
|------------------------|:------------------:|:-----------:|-------------------------------------------------------------------------------------------------------------------|
57+
| ---------------------- | :----------------: | :---------: | ----------------------------------------------------------------------------------------------------------------- |
5658
| `token` | <ins>**Yes**</ins> | – | Repository `GITHUB_TOKEN` which allows action to make calls to the GitHub API (Octokit). |
5759
| `collapsibleThreshold` | No | `25` | Number of lock changes, which will result in collapsed comment content, and an addition of changes summary table. |
58-
| `failOnDowngrade` | No | `false` | WFail the action when a dependency downgrade is detected. __Comment will still be posted.__ |
60+
| `failOnDowngrade` | No | `false` | WFail the action when a dependency downgrade is detected. **Comment will still be posted.** |
5961
| `path` | No | `yarn.lock` | Path to the `yarn.lock` file in the repository. Default value points to the file at project root. |
6062
| `updateComment` | No | `true` | Update the comment on each new commit. If value is set to `false`, bot will post a new comment on each change. |
6163
| `groupByType` | No | `false` | Group the dependencies in the comment table by the change type. |
@@ -74,9 +76,9 @@ jobs:
7476

7577
### The action fails on the Dependabot pull requests
7678

77-
Due to the security reasons from March 1st, 2021 workflow runs that are triggered by Dependabot have permissions reduced by default:
79+
Due to the security reasons from March 1st, 2021 workflow runs that are triggered by Dependabot have permissions reduced by default:
7880

79-
* [GitHub Actions: Workflows triggered by Dependabot PRs will run with read-only permissions](https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/)
81+
- [GitHub Actions: Workflows triggered by Dependabot PRs will run with read-only permissions](https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/)
8082

8183
To ensure that sufficient permissions for this action are always granted, you will need to add `permissions` entry to the job which runs `yarn-lock-changes`:
8284

@@ -88,13 +90,12 @@ jobs:
8890
permissions:
8991
pull-requests: write
9092
#####
91-
steps:
92-
...
93+
steps: ...
9394
```
9495

9596
### The action fails in a private repository
9697

97-
After one of the GitHub Actions security breaches GitHub decided to trim down the default permission set for actions running in private repositories.
98+
After one of the GitHub Actions security breaches GitHub decided to trim down the default permission set for actions running in private repositories.
9899

99100
If you are trying to run action with default setup in the private repository, you will see the following error during `checkout` step:
100101

@@ -114,12 +115,12 @@ jobs:
114115
permissions:
115116
contents: read
116117
#####
117-
steps:
118-
...
118+
steps: ...
119119
```
120120

121-
If you would like to learn a little bit more about this problem, you can visit this issue in the GitHub Checkout Action repository:
122-
* https://github.com/actions/checkout/issues/254
121+
If you would like to learn a little bit more about this problem, you can visit this issue in the GitHub Checkout Action repository:
122+
123+
- https://github.com/actions/checkout/issues/254
123124

124125
## 🔍️ Debugging
125126

dist/index.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.mjs

Lines changed: 0 additions & 41 deletions
This file was deleted.

package.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"license": "MIT",
88
"scripts": {
99
"build": "esbuild src/action.js --bundle --platform=node --target=node22 --minify --legal-comments=none --outfile=dist/index.js",
10-
"lint": "eslint .",
10+
"lint": "oxlint && oxfmt --check",
11+
"lint:fix": "oxlint --fix && oxfmt",
1112
"optimize": "svgo -f ./assets",
1213
"test": "uvu tests -i .cjs -i testUtils"
1314
},
@@ -19,16 +20,11 @@
1920
"semver": "^7.7.3"
2021
},
2122
"devDependencies": {
22-
"@eslint/js": "^9.39.2",
2323
"@yarnpkg/lockfile": "^1.1.0",
2424
"@yarnpkg/parsers": "^3.0.3",
2525
"esbuild": "^0.27.2",
26-
"eslint": "^9.39.2",
27-
"eslint-config-prettier": "^10.1.8",
28-
"eslint-plugin-n": "^17.23.2",
29-
"eslint-plugin-prettier": "^5.5.5",
30-
"globals": "^17.2.0",
31-
"prettier": "^3.8.1",
26+
"oxfmt": "^0.27.0",
27+
"oxlint": "^1.42.0",
3228
"uvu": "^0.5.6"
3329
},
3430
"volta": {

0 commit comments

Comments
 (0)