Skip to content

Commit

Permalink
feat(javascript): 添加lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ZvonimirSun committed Dec 18, 2023
1 parent 6b3c893 commit ffebd57
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@codemirror/commands": "^6.3.2",
"@codemirror/lang-javascript": "^6.2.1",
"@codemirror/lang-xml": "^6.0.2",
"@codemirror/lint": "^6.4.2",
"@codemirror/state": "^6.3.3",
"@codemirror/view": "^6.22.3",
"@geoman-io/leaflet-geoman-free": "^2.15.0",
Expand All @@ -34,6 +35,7 @@
"dayjs": "^1.11.10",
"dom-to-image": "^2.6.0",
"element-plus": "^2.4.4",
"eslint-linter-browserify": "^8.56.0",
"esri-leaflet": "^3.0.12",
"file-saver": "^2.0.5",
"highlight.js": "^11.9.0",
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

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

23 changes: 21 additions & 2 deletions src/components/editor/javascript.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
import { javascript } from '@codemirror/lang-javascript'
import { javascript, esLint } from '@codemirror/lang-javascript'
import { linter, lintGutter } from '@codemirror/lint'
import basic from './basic'
import { EditorPlugin } from './editor'

// Uses linter.mjs
import * as eslint from 'eslint-linter-browserify'

const config = {
// eslint configuration
parserOptions: {
ecmaVersion: 15,
sourceType: 'module'
},
env: {
browser: true,
node: true
}
}

const plugin: EditorPlugin = {
...basic,
extensions: [
...basic.extensions,
javascript()
javascript(),
lintGutter(),
// eslint-disable-next-line
linter(esLint(new eslint.Linter(), config)),
]
}

Expand Down
18 changes: 0 additions & 18 deletions src/views/test.vue

This file was deleted.

0 comments on commit ffebd57

Please sign in to comment.