Skip to content

Commit c446ec7

Browse files
authored
Merge pull request #615 from KristjanESPERANTO/eslint
chore: modernize linting setup
2 parents bbce7b5 + 3df9f0d commit c446ec7

7 files changed

Lines changed: 92 additions & 42 deletions

File tree

.eslintignore

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

.eslintrc.yml

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

.github/workflows/ci.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ name: CI
55

66
on:
77
push:
8-
branches: [ master ]
8+
branches: [master]
99
pull_request:
10-
branches: [ master ]
10+
branches: [master]
1111
workflow_dispatch:
1212
inputs:
1313
ref:
14-
description: 'Tag, or commit SHA to checkout (optional)'
14+
description: "Tag, or commit SHA to checkout (optional)"
1515
required: false
1616

1717
env:
@@ -22,15 +22,17 @@ jobs:
2222
runs-on: ubuntu-latest
2323
strategy:
2424
matrix:
25-
node: [ 24 ]
25+
node: [24]
2626
name: Node ${{ matrix.node }}
2727
steps:
28-
- uses: actions/checkout@v4
28+
- uses: actions/checkout@v6
2929
with:
3030
ref: ${{ github.event.inputs.ref || github.ref }}
3131
- name: Setup Node ${{ matrix.node }}
32-
uses: actions/setup-node@v4
32+
uses: actions/setup-node@v6
3333
with:
3434
node-version: ${{ matrix.node }}
3535
- run: npm install --ignore-scripts
36+
- run: npm run yaml
37+
- run: npm run lint
3638
- run: npm run ci

eslint.config.mjs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { defineConfig, globalIgnores } from 'eslint/config'
2+
import js from '@eslint/js'
3+
import globals from 'globals'
4+
import { flatConfigs as importX } from 'eslint-plugin-import-x'
5+
import n from 'eslint-plugin-n'
6+
import promise from 'eslint-plugin-promise'
7+
import { configs as ymlConfigs } from 'eslint-plugin-yml'
8+
9+
export default defineConfig([
10+
globalIgnores([
11+
'coverage/**',
12+
'dist/**',
13+
'lib/**',
14+
'src/data.js'
15+
]),
16+
{
17+
files: ['**/*.js', '**/*.mjs'],
18+
languageOptions: {
19+
globals: {
20+
...globals.browser,
21+
...globals.node,
22+
...globals.mocha
23+
},
24+
ecmaVersion: 'latest',
25+
sourceType: 'module'
26+
},
27+
extends: [
28+
js.configs.recommended,
29+
n.configs['flat/recommended'],
30+
promise.configs['flat/recommended'],
31+
importX.recommended
32+
]
33+
},
34+
{
35+
files: ['**/*.cjs'],
36+
languageOptions: {
37+
globals: {
38+
...globals.node,
39+
...globals.mocha
40+
},
41+
ecmaVersion: 'latest',
42+
sourceType: 'commonjs'
43+
},
44+
extends: [
45+
js.configs.recommended,
46+
n.configs['flat/recommended'],
47+
promise.configs['flat/recommended'],
48+
importX.recommended
49+
],
50+
rules: {
51+
'n/no-unsupported-features/es-syntax': 'off'
52+
}
53+
},
54+
{
55+
// Tooling and example files follow different constraints than runtime code.
56+
// Relax strict n/* checks here to avoid non-actionable lint noise.
57+
files: ['eslint.config.mjs', 'examples/**', 'scripts/**'],
58+
rules: {
59+
'n/no-unpublished-import': 'off',
60+
'n/no-missing-require': 'off',
61+
'n/no-unsupported-features/es-syntax': 'off',
62+
'n/no-process-exit': 'off',
63+
'n/hashbang': 'off'
64+
}
65+
},
66+
{
67+
files: ['**/*.yaml', '**/*.yml'],
68+
extends: [ymlConfigs['flat/standard']],
69+
rules: {
70+
'yml/plain-scalar': 'off'
71+
}
72+
}
73+
])

examples/browser/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
Object.entries(options).reduce((a, [value, label]) => {
7575
a.push(h(
7676
'option',
77-
{ value, selected: value == selected }, // eslint-disable-line eqeqeq
77+
{ value, selected: value == selected },
7878
label
7979
))
8080
return a
@@ -156,7 +156,7 @@
156156
const filename = [g.year, n.country, n.state, n.region, g.language].filter(Boolean).join('-') + '.ics'
157157
download(filename, g.holidays, isFullDay)
158158
}
159-
const handleFullday = (ev) => {
159+
const handleFullday = () => {
160160
g.isFullDay = isFullDay = !isFullDay
161161
}
162162
return h('p',

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@
208208
"clean:modules": "rimraf node_modules",
209209
"doc:attrib": "node scripts/attributions.cjs",
210210
"doc:tree": "node scripts/addtree.cjs",
211-
"lint": "eslint --fix --ext .js,.cjs,.yaml .",
211+
"lint": "eslint",
212+
"lint:fix": "eslint --fix",
212213
"prepublishOnly": "npm run all",
213214
"fixtures": "mocha test/all.mocha.js --writetests --countries",
214215
"test": "npm-run-all test:*",
@@ -273,14 +274,15 @@
273274
"@babel/preset-env": "^7.29.5",
274275
"@commitlint/cli": "^18.6.1",
275276
"@commitlint/config-conventional": "^18.6.3",
277+
"@eslint/js": "^10.0.1",
276278
"@mocha/contributors": "git+https://github.com/commenthol/contributors.git#semver:1.1.0-0",
277279
"babel-loader": "^9.2.1",
278-
"eslint": "^8.57.1",
279-
"eslint-config-standard": "^17.1.0",
280-
"eslint-plugin-import": "^2.32.0",
281-
"eslint-plugin-n": "^16.6.2",
282-
"eslint-plugin-promise": "^6.6.0",
283-
"eslint-plugin-yml": "^0.15.0",
280+
"eslint": "^10.3.0",
281+
"eslint-plugin-import-x": "^4.16.2",
282+
"eslint-plugin-n": "^18.0.1",
283+
"eslint-plugin-promise": "^7.3.0",
284+
"eslint-plugin-yml": "^3.3.2",
285+
"globals": "^17.6.0",
284286
"husky": "^9.1.7",
285287
"mocha": "^11.7.5",
286288
"npm-run-all": "^4.1.5",
@@ -296,7 +298,6 @@
296298
"node": ">=12.0.0"
297299
},
298300
"c4uIgnore": {
299-
"eslint-plugin-yml": "^0.15.0 // newer versions do too much checking",
300301
"rollup": "^2.79.1 // v3 changed exports; needs refactoring first."
301302
},
302303
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0"

scripts/attributions.cjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#!/usr/bin/env node
22

3-
/* eslint
4-
key-spacing: 0
5-
*/
6-
73
const fs = require('fs')
84
const path = require('path')
95

0 commit comments

Comments
 (0)