Skip to content

Commit

Permalink
Run lint on CI (#550)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
MattiasBuelens authored Jan 7, 2025
1 parent 434aea0 commit 5d24fc7
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bundlers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ jobs:
run: npm install
- name: Bundle code
run: npm run test:prepare ${{ matrix.bundler }}
- name: Run Tests on Browsers
- name: Run Tests on bundler
run: npm run test:bundlers ${{ matrix.bundler }}
40 changes: 40 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Lint

on: [push, pull_request]

permissions:
contents: read

jobs:
lint:
name: Node.js
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node-version: [20.x]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Restore cached dependencies
uses: actions/cache@v3
with:
path: node_modules
key: node-modules-${{ hashFiles('package.json') }}
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Check generated files
run: |
# Check if diff is empty
git diff --exit-code --stat ${{ github.sha }} -- lib/
- name: Check format
run: npm run test:format
- name: Check for lint issues
run: npm run lint
14 changes: 7 additions & 7 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { FlatCompat } from '@eslint/eslintrc'
const compat = new FlatCompat()

import eslintPluginLocal from './eslint-plugin-local/index.mjs'

const compat = new FlatCompat()

export default [
// standard,
...compat.extends('eslint-config-standard'),
{
files: ['**/**.js', '**/**.mjs'],
languageOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
ecmaVersion: 'latest'
},
plugins: { 'local': eslintPluginLocal },
plugins: { local: eslintPluginLocal },
rules: {
/*
This is inserted to make this compatible with prettier.
Expand All @@ -21,7 +21,7 @@ export default [
'space-before-function-paren': 0,
curly: [2, 'all'],
'local/no-big-int': 'error',
'no-undef': 'warn',
},
},
'no-undef': 'warn'
}
}
]
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"test:readable-stream-only": "node readable-stream-test/runner-prepare.mjs",
"coverage": "c8 -c ./c8.json tap --rcfile=./tap.yml test/parallel/test-*.js test/ours/test-*.js",
"format": "prettier -w src lib test",
"test:format": "prettier -c src lib test",
"lint": "eslint src"
},
"dependencies": {
Expand All @@ -55,6 +56,7 @@
"@babel/core": "^7.17.10",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
"@eslint/eslintrc": "^3.2.0",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-inject": "^4.0.4",
"@rollup/plugin-node-resolve": "^13.3.0",
Expand Down

0 comments on commit 5d24fc7

Please sign in to comment.