Skip to content

Commit 4c0fce8

Browse files
authored
Fix eslint parsing errors, remove eslint-plugin-html (#20323)
Introduce a separate .eslintrc in the Vue components folder to selectively enable vue-eslint-parser there, so that the rest of the files can use eslint's core parser which can deal with hashbangs. The fact that the eslint-disable comments worked in HTML was a unintended side-effect of the files being parsed via vue-eslint-parser, so I had to disable the parsing of these files in .eslintrc.yaml to make it work, and finally decided to remove eslint-plugin-html as it causes more issues than it solves.
1 parent e35a39e commit 4c0fce8

File tree

7 files changed

+18
-90
lines changed

7 files changed

+18
-90
lines changed

.eslintrc.yaml

+1-18
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,20 @@ parserOptions:
1111
plugins:
1212
- eslint-plugin-unicorn
1313
- eslint-plugin-import
14-
- eslint-plugin-vue
15-
- eslint-plugin-html
1614
- eslint-plugin-jquery
1715

18-
extends:
19-
- plugin:vue/recommended
20-
2116
env:
2217
es2022: true
2318
node: true
2419

2520
globals:
2621
__webpack_public_path__: true
2722

28-
settings:
29-
html/html-extensions: [".tmpl"]
30-
3123
overrides:
32-
- files: ["web_src/**/*.js", "web_src/**/*.vue", "templates/**/*.tmpl"]
24+
- files: ["web_src/**/*.js", "docs/**/*.js"]
3325
env:
3426
browser: true
3527
node: false
36-
- files: ["templates/**/*.tmpl"]
37-
rules:
38-
no-tabs: [0]
39-
indent: [2, tab, {SwitchCase: 1}]
4028
- files: ["web_src/**/*worker.js"]
4129
env:
4230
worker: true
@@ -502,11 +490,6 @@ rules:
502490
use-isnan: [2]
503491
valid-typeof: [2, {requireStringLiterals: true}]
504492
vars-on-top: [0]
505-
vue/attributes-order: [0]
506-
vue/component-definition-name-casing: [0]
507-
vue/html-closing-bracket-spacing: [0]
508-
vue/max-attributes-per-line: [0]
509-
vue/one-component-per-file: [0]
510493
wrap-iife: [2, inside]
511494
wrap-regex: [0]
512495
yield-star-spacing: [2, after]

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ lint: lint-frontend lint-backend
310310

311311
.PHONY: lint-frontend
312312
lint-frontend: node_modules
313-
npx eslint --color --max-warnings=0 web_src/js build templates *.config.js docs/assets/js
313+
npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js docs/assets/js
314314
npx stylelint --color --max-warnings=0 web_src/less
315315
npx spectral lint -q -F hint $(SWAGGER_SPEC)
316316

package-lock.json

-68
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"@happy-dom/jest-environment": "4.0.1",
4848
"@stoplight/spectral-cli": "6.4.1",
4949
"eslint": "8.15.0",
50-
"eslint-plugin-html": "6.2.0",
5150
"eslint-plugin-import": "2.26.0",
5251
"eslint-plugin-jquery": "1.5.1",
5352
"eslint-plugin-unicorn": "42.0.0",

templates/base/head_script.tmpl

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ If you are customizing Gitea, please do not change this file.
44
If you introduce mistakes in it, Gitea JavaScript code wouldn't run correctly.
55
*/}}
66
<script>
7-
<!-- /* eslint-disable */ -->
87
window.addEventListener('error', function(e) {window._globalHandlerErrors=window._globalHandlerErrors||[]; window._globalHandlerErrors.push(e);});
98
window.config = {
109
appVer: '{{AppVer}}',

templates/repo/issue/view_content/pull.tmpl

-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@
340340
{{end}}
341341
<div class="ui divider"></div>
342342
<script>
343-
<!-- /* eslint-disable */ -->
344343
(() => {
345344
const defaultMergeTitle = {{.DefaultMergeMessage}};
346345
const defaultSquashMergeTitle = {{.DefaultSquashMergeMessage}};

web_src/js/components/.eslintrc.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
plugins:
2+
- eslint-plugin-vue
3+
4+
extends:
5+
- ../../../.eslintrc.yaml
6+
- plugin:vue/recommended
7+
8+
env:
9+
browser: true
10+
11+
rules:
12+
vue/attributes-order: [0]
13+
vue/component-definition-name-casing: [0]
14+
vue/html-closing-bracket-spacing: [0]
15+
vue/max-attributes-per-line: [0]
16+
vue/one-component-per-file: [0]

0 commit comments

Comments
 (0)