-
Notifications
You must be signed in to change notification settings - Fork 473
Feat provide eslint prettier modify config #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wenmine
merged 14 commits into
opentiny:develop
from
rhlin:feat-provide-eslint-prettier-modify-config
Apr 16, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
723f3d9
fix(monaco-eslint): 修复eslint-worker支持问题
rhlin aaa9e83
fix(linter): 解决cdn后eslint worker相对路径问题
rhlin dcb2668
fix: 移除多余的包
rhlin 5daf784
feat(controller): eslint、prettier新增配置文件,worker文件打包从主应用改为随着分应用打包
rhlin 4e5db65
fix(controller): 修复eslint worker地址
rhlin 8d00f6e
feat(controller): eslint-linter-browserify 降版本
rhlin e0d66ae
build: 去掉define process.env设置为空对象(旧版tinyVue库需要),当前引起eslint-linter-bro…
rhlin f7c6f40
fix(controller): 去掉多余注释和测试代码注释
rhlin 1164b4d
fix: 解决代码检视问题, 去掉注释,补充包引用去掉external,去掉多余的新增依赖
rhlin 48d1b1e
feat: 单页预览格式化统一引用prettierrc文件配置
rhlin 4b187a2
Merge branch 'develop' into feat-provide-eslint-prettier-modify-config
rhlin 5bec5bd
fix: 解决子包的js没有打包为入口的问题
rhlin d316501
fix(controller): 修复因目录结构改变需要worker打包为相对地址
rhlin 39bd362
Merge remote-tracking branch 'upstream/develop' into feat-provide-esl…
rhlin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import eslintRecommended from '@eslint/js/src/configs/eslint-recommended.js' | ||
| export default { | ||
| ...eslintRecommended.rules, | ||
| 'no-console': 'error', | ||
| 'no-debugger': 'error', | ||
| 'space-before-function-paren': 'off', | ||
| 'no-use-before-define': 'error' | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| export default { | ||
| semi: false, | ||
| singleQuote: true, | ||
| printWidth: 120, | ||
| trailingComma: 'none', | ||
| endOfLine: 'auto', | ||
| tabWidth: 2 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /** | ||
| * Copyright (c) 2023 - present TinyEngine Authors. | ||
| * Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd. | ||
| * | ||
| * Use of this source code is governed by an MIT-style license. | ||
| * | ||
| * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, | ||
| * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR | ||
| * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. | ||
| * | ||
| */ | ||
|
|
||
| import { Linter } from 'eslint-linter-browserify' | ||
| import eslintRule from '../config-files/eslint-rule' | ||
|
|
||
| const defaultConfig = { | ||
| env: { | ||
| browser: true, | ||
| es6: true | ||
| }, | ||
| parserOptions: { | ||
| ecmaFeatures: { | ||
| jsx: true | ||
| }, | ||
| ecmaVersion: 'latest', | ||
| sourceType: 'module' | ||
| } | ||
| } | ||
|
|
||
| const config = { | ||
| ...defaultConfig, | ||
| rules: { | ||
| ...eslintRule, | ||
| // JS 面板中,仅定义 function,但可能不使用该方法 | ||
| 'no-unused-vars': 'off', | ||
| 'no-alert': 'off', | ||
| 'no-console': 'off' | ||
| }, | ||
| settings: {} | ||
| } | ||
|
|
||
| // 错误的等级,ESLint 与 monaco 的存在差异,做一层映射 | ||
| const severityMap = { | ||
| 2: 'Error', | ||
| 1: 'Warning' | ||
| } | ||
| const linter = new Linter() | ||
|
|
||
| self.addEventListener('message', (event) => { | ||
| const { code, version } = event.data | ||
|
|
||
| const ruleDefines = linter.getRules() | ||
| const errs = linter.verify(code, config) | ||
|
|
||
| const markers = errs.map(({ ruleId = '', line, endLine, column, endColumn, message, severity }) => ({ | ||
| code: { | ||
| value: ruleId || '', | ||
| target: ruleDefines.get(ruleId)?.meta?.docs?.url || '' | ||
| }, | ||
| startLineNumber: line, | ||
| endLineNumber: endLine, | ||
| startColumn: column, | ||
| endColumn: endColumn, | ||
| message: message, | ||
| severity: severityMap[severity], | ||
| source: 'ESLint' | ||
| })) | ||
|
|
||
| // ESLint 静态检查结果,发回主线程 | ||
| self.postMessage({ markers, version }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
packages/design-core/public/monaco-linter/eslint.worker.js
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.