Skip to content

Commit f3abfb1

Browse files
committed
add eslinter to workflow, fix linter errors
1 parent f4bd871 commit f3abfb1

4 files changed

Lines changed: 168 additions & 0 deletions

File tree

.github/eslint.config.mjs

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import { defineConfig, globalIgnores } from 'eslint/config';
2+
import globals from 'globals';
3+
import markdown from "@eslint/markdown";
4+
import json from '@eslint/json';
5+
import js from '@eslint/js';
6+
7+
export default defineConfig([
8+
globalIgnores([
9+
'node_modules',
10+
]),
11+
// Markdown
12+
{
13+
files: ["**/*.md"],
14+
plugins: {
15+
markdown,
16+
},
17+
processor: "markdown/markdown",
18+
},
19+
// applies only to JavaScript blocks inside of Markdown files
20+
{
21+
files: ["**/*.md/*.js"],
22+
rules: {
23+
strict: "off",
24+
},
25+
},
26+
// JSON files
27+
{
28+
files: ['**/*.json'],
29+
ignores: ['package-lock.json'],
30+
plugins: { json },
31+
language: 'json/json',
32+
extends: ['json/recommended'],
33+
rules: {
34+
'json/no-duplicate-keys': 'error',
35+
},
36+
},
37+
// JavaScript files
38+
{
39+
files: ['**/*.js'],
40+
language: '@/js',
41+
plugins: { js },
42+
extends: ['js/recommended'],
43+
linterOptions: {
44+
reportUnusedDisableDirectives: "off",
45+
},
46+
languageOptions: {
47+
sourceType: 'script',
48+
ecmaVersion: 2026,
49+
globals: {
50+
...globals.browser,
51+
/* LuCI runtime / cbi exports */
52+
_: 'readonly',
53+
N_: 'readonly',
54+
L: 'readonly',
55+
E: 'readonly',
56+
TR: 'readonly',
57+
cbi_d: 'readonly',
58+
cbi_strings: 'readonly',
59+
cbi_d_add: 'readonly',
60+
cbi_d_check: 'readonly',
61+
cbi_d_checkvalue: 'readonly',
62+
cbi_d_update: 'readonly',
63+
cbi_init: 'readonly',
64+
cbi_update_table: 'readonly',
65+
cbi_validate_form: 'readonly',
66+
cbi_validate_field: 'readonly',
67+
cbi_validate_named_section_add: 'readonly',
68+
cbi_validate_reset: 'readonly',
69+
cbi_row_swap: 'readonly',
70+
cbi_tag_last: 'readonly',
71+
cbi_submit: 'readonly',
72+
cbi_dropdown_init: 'readonly',
73+
isElem: 'readonly',
74+
toElem: 'readonly',
75+
matchesElem: 'readonly',
76+
findParent: 'readonly',
77+
sfh: 'readonly',
78+
renderBadge: 'readonly',
79+
/* modules */
80+
baseclass: 'readonly',
81+
dom: 'readonly',
82+
firewall: 'readonly',
83+
fwtool: 'readonly',
84+
form: 'readonly',
85+
fs: 'readonly',
86+
network: 'readonly',
87+
nettools: 'readonly',
88+
poll: 'readonly',
89+
random: 'readonly',
90+
request: 'readonly',
91+
session: 'readonly',
92+
rpc: 'readonly',
93+
uci: 'readonly',
94+
ui: 'readonly',
95+
uqr: 'readonly',
96+
validation: 'readonly',
97+
view: 'readonly',
98+
widgets: 'readonly',
99+
/* dockerman */
100+
dm2: 'readonly',
101+
jsapi: 'readonly',
102+
},
103+
parserOptions: {
104+
ecmaFeatures: {
105+
globalReturn: true,
106+
},
107+
},
108+
},
109+
rules: {
110+
'strict': 0,
111+
'no-prototype-builtins': 0,
112+
'no-empty': 0,
113+
'no-undef': 'warn',
114+
'no-unused-vars': ['off', { "caughtErrors": "none" }],
115+
'no-regex-spaces': 0,
116+
'no-control-regex': 0,
117+
},
118+
},
119+
]);

.github/workflows/eslint.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: "ESLint"
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
paths:
7+
- '**/*.js'
8+
- '**/*.json'
9+
- '**/*.md'
10+
- '.github/eslint.config.mjs'
11+
12+
pull_request:
13+
branches: ["main"]
14+
paths:
15+
- '**/*.js'
16+
- '**/*.json'
17+
- '**/*.md'
18+
- '.github/eslint.config.mjs'
19+
20+
permissions: {}
21+
22+
jobs:
23+
eslint:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
steps:
28+
- name: Check out repository
29+
uses: actions/checkout@v6
30+
31+
- name: Set up Node.js
32+
uses: actions/setup-node@v6
33+
with:
34+
node-version: latest
35+
36+
- name: Install ESLint
37+
run: |
38+
npm install --no-audit --no-fund --save-dev \
39+
eslint@9 \
40+
globals \
41+
@eslint/json@latest \
42+
@eslint/js@9 \
43+
@eslint/markdown \
44+
eslint-formatter-gha
45+
46+
- name: Run ESLint
47+
run: npx eslint --config .github/eslint.config.mjs .

htdocs/luci-static/resources/view/https-dns-proxy/overview.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"require rpc";
1111
"require view";
1212
"require https-dns-proxy.status as hdp";
13+
/* globals hdp */
1314

1415
var pkg = hdp.pkg;
1516

htdocs/luci-static/resources/view/status/include/71_https-dns-proxy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"require form";
55
"require baseclass";
66
"require https-dns-proxy.status as hdp";
7+
/* globals hdp */
78

89
var pkg = hdp.pkg;
910

0 commit comments

Comments
 (0)