Skip to content

Commit 871a7b2

Browse files
committed
chore: add ESLint setup
1 parent e8f6941 commit 871a7b2

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
@@ -90,12 +90,14 @@ npm run lint:fix
9090

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

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

100102
## Link checks
101103

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)