forked from opentiny/tiny-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat provide eslint prettier modify config (opentiny#385)
* fix(monaco-eslint): 修复eslint-worker支持问题 * fix(linter): 解决cdn后eslint worker相对路径问题 * fix: 移除多余的包 * feat(controller): eslint、prettier新增配置文件,worker文件打包从主应用改为随着分应用打包 * fix(controller): 修复eslint worker地址 * feat(controller): eslint-linter-browserify 降版本 * build: 去掉define process.env设置为空对象(旧版tinyVue库需要),当前引起eslint-linter-browserify脚本(已经处理过process的包)构建报错,且主应用有nodePollyfill可以处理process场景重复了 * fix(controller): 去掉多余注释和测试代码注释 * fix: 解决代码检视问题, 去掉注释,补充包引用去掉external,去掉多余的新增依赖 * feat: 单页预览格式化统一引用prettierrc文件配置 * fix: 解决子包的js没有打包为入口的问题 * fix(controller): 修复因目录结构改变需要worker打包为相对地址
- Loading branch information
Showing
16 changed files
with
130 additions
and
116 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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