Skip to content

Commit

Permalink
Fix eslint parsing errors, remove eslint-plugin-html (go-gitea#20323)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
silverwind authored and Sysoev, Vladimir committed Aug 10, 2022
1 parent 2a15bd5 commit a398d20
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 90 deletions.
19 changes: 1 addition & 18 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,20 @@ parserOptions:
plugins:
- eslint-plugin-unicorn
- eslint-plugin-import
- eslint-plugin-vue
- eslint-plugin-html
- eslint-plugin-jquery

extends:
- plugin:vue/recommended

env:
es2022: true
node: true

globals:
__webpack_public_path__: true

settings:
html/html-extensions: [".tmpl"]

overrides:
- files: ["web_src/**/*.js", "web_src/**/*.vue", "templates/**/*.tmpl"]
- files: ["web_src/**/*.js", "docs/**/*.js"]
env:
browser: true
node: false
- files: ["templates/**/*.tmpl"]
rules:
no-tabs: [0]
indent: [2, tab, {SwitchCase: 1}]
- files: ["web_src/**/*worker.js"]
env:
worker: true
Expand Down Expand Up @@ -502,11 +490,6 @@ rules:
use-isnan: [2]
valid-typeof: [2, {requireStringLiterals: true}]
vars-on-top: [0]
vue/attributes-order: [0]
vue/component-definition-name-casing: [0]
vue/html-closing-bracket-spacing: [0]
vue/max-attributes-per-line: [0]
vue/one-component-per-file: [0]
wrap-iife: [2, inside]
wrap-regex: [0]
yield-star-spacing: [2, after]
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ lint: lint-frontend lint-backend

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

Expand Down
68 changes: 0 additions & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"@happy-dom/jest-environment": "4.0.1",
"@stoplight/spectral-cli": "6.4.1",
"eslint": "8.15.0",
"eslint-plugin-html": "6.2.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jquery": "1.5.1",
"eslint-plugin-unicorn": "42.0.0",
Expand Down
1 change: 0 additions & 1 deletion templates/base/head_script.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ If you are customizing Gitea, please do not change this file.
If you introduce mistakes in it, Gitea JavaScript code wouldn't run correctly.
*/}}
<script>
<!-- /* eslint-disable */ -->
window.addEventListener('error', function(e) {window._globalHandlerErrors=window._globalHandlerErrors||[]; window._globalHandlerErrors.push(e);});
window.config = {
appVer: '{{AppVer}}',
Expand Down
1 change: 0 additions & 1 deletion templates/repo/issue/view_content/pull.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@
{{end}}
<div class="ui divider"></div>
<script>
<!-- /* eslint-disable */ -->
(() => {
const defaultMergeTitle = {{.DefaultMergeMessage}};
const defaultSquashMergeTitle = {{.DefaultSquashMergeMessage}};
Expand Down
16 changes: 16 additions & 0 deletions web_src/js/components/.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins:
- eslint-plugin-vue

extends:
- ../../../.eslintrc.yaml
- plugin:vue/recommended

env:
browser: true

rules:
vue/attributes-order: [0]
vue/component-definition-name-casing: [0]
vue/html-closing-bracket-spacing: [0]
vue/max-attributes-per-line: [0]
vue/one-component-per-file: [0]

0 comments on commit a398d20

Please sign in to comment.