Skip to content

Commit f27d936

Browse files
authored
Merge pull request #2585 from nschonni/eslint-setup
chore: add ESLint setup
2 parents 0183403 + 575bc16 commit f27d936

6 files changed

Lines changed: 830 additions & 8 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check JavaScript formatting
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**/*.{js,mjs,cjs}'
7+
- 'package*.json'
8+
- .github/workflows/lint-javascript.yml
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
eslint:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check out repo
19+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
20+
- name: Set up Node.js
21+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
22+
with:
23+
node-version-file: .node-version
24+
cache: npm
25+
- name: Install dependencies
26+
run: npm ci
27+
- name: Run ESLint
28+
run: npm run format:javascript:check

CONTRIBUTING.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ npm run lint:fix
9191

9292
Alternatively use any of the following commands to call one of the underlying linting utilities:
9393

94-
| Command | Purpose |
95-
| ------------------------------- | --------------------------------------- |
96-
| `npm run format:toc` | Reformats any Table of Contents |
97-
| `npm run format:toc:check` | Read-only Table of Contents check |
98-
| `npm run format:prettier` | Reformats multiple types of source code |
99-
| `npm run format:prettier:check` | Read-only prettier check |
94+
| Command | Purpose |
95+
| --------------------------------- | --------------------------------------- |
96+
| `npm run format:toc` | Reformats any Table of Contents |
97+
| `npm run format:toc:check` | Read-only Table of Contents check |
98+
| `npm run format:prettier` | Reformats multiple types of source code |
99+
| `npm run format:prettier:check` | Read-only prettier check |
100+
| `npm run format:javascript` | Reformats JavaScript source code |
101+
| `npm run format:javascript:check` | Read-only ESLint check |
100102

101103
## Link checks
102104

build-automation.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const checkIfThereAreNewVersions = async (github) => {
5050
if (latestSupportedVersions[availableMajor] == null) {
5151
continue;
5252
}
53+
// eslint-disable-next-line no-unused-vars
5354
const [_latestMajor, latestMinor, latestPatch] =
5455
latestSupportedVersions[availableMajor].fullVersion.split('.');
5556
if (

eslint.config.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import { defineConfig } from 'eslint/config';
4+
5+
export default defineConfig([
6+
{
7+
files: ['**/*.{js,mjs,cjs}'],
8+
plugins: { js },
9+
extends: ['js/recommended'],
10+
languageOptions: { globals: globals.node },
11+
},
12+
]);

0 commit comments

Comments
 (0)