Skip to content

Commit 5d24fc7

Browse files
Run lint on CI (#550)
* Check for lint issues on CI * Check if generated files are up-to-date on CI * Fix step name * Check code formatting on CI * Fix eslint config
1 parent 434aea0 commit 5d24fc7

File tree

4 files changed

+50
-8
lines changed

4 files changed

+50
-8
lines changed

.github/workflows/bundlers.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ jobs:
4040
run: npm install
4141
- name: Bundle code
4242
run: npm run test:prepare ${{ matrix.bundler }}
43-
- name: Run Tests on Browsers
43+
- name: Run Tests on bundler
4444
run: npm run test:bundlers ${{ matrix.bundler }}

.github/workflows/lint.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Lint
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
lint:
10+
name: Node.js
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest]
16+
node-version: [20.x]
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
- name: Use Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
- name: Restore cached dependencies
25+
uses: actions/cache@v3
26+
with:
27+
path: node_modules
28+
key: node-modules-${{ hashFiles('package.json') }}
29+
- name: Install dependencies
30+
run: npm install
31+
- name: Build
32+
run: npm run build
33+
- name: Check generated files
34+
run: |
35+
# Check if diff is empty
36+
git diff --exit-code --stat ${{ github.sha }} -- lib/
37+
- name: Check format
38+
run: npm run test:format
39+
- name: Check for lint issues
40+
run: npm run lint

eslint.config.mjs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { FlatCompat } from '@eslint/eslintrc'
2-
const compat = new FlatCompat()
3-
42
import eslintPluginLocal from './eslint-plugin-local/index.mjs'
53

4+
const compat = new FlatCompat()
5+
66
export default [
77
// standard,
88
...compat.extends('eslint-config-standard'),
99
{
1010
files: ['**/**.js', '**/**.mjs'],
1111
languageOptions: {
1212
sourceType: 'module',
13-
ecmaVersion: 'latest',
13+
ecmaVersion: 'latest'
1414
},
15-
plugins: { 'local': eslintPluginLocal },
15+
plugins: { local: eslintPluginLocal },
1616
rules: {
1717
/*
1818
This is inserted to make this compatible with prettier.
@@ -21,7 +21,7 @@ export default [
2121
'space-before-function-paren': 0,
2222
curly: [2, 'all'],
2323
'local/no-big-int': 'error',
24-
'no-undef': 'warn',
25-
},
26-
},
24+
'no-undef': 'warn'
25+
}
26+
}
2727
]

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"test:readable-stream-only": "node readable-stream-test/runner-prepare.mjs",
4343
"coverage": "c8 -c ./c8.json tap --rcfile=./tap.yml test/parallel/test-*.js test/ours/test-*.js",
4444
"format": "prettier -w src lib test",
45+
"test:format": "prettier -c src lib test",
4546
"lint": "eslint src"
4647
},
4748
"dependencies": {
@@ -55,6 +56,7 @@
5556
"@babel/core": "^7.17.10",
5657
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
5758
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
59+
"@eslint/eslintrc": "^3.2.0",
5860
"@rollup/plugin-commonjs": "^22.0.0",
5961
"@rollup/plugin-inject": "^4.0.4",
6062
"@rollup/plugin-node-resolve": "^13.3.0",

0 commit comments

Comments
 (0)