Skip to content

Commit

Permalink
lesscode-master: v0.3.0 (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
terlinhe authored Dec 1, 2021
1 parent f68ffb5 commit a8e0184
Show file tree
Hide file tree
Showing 291 changed files with 13,292 additions and 907 deletions.
9 changes: 8 additions & 1 deletion paas-ce/lesscode/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
},
"debug": false
}
],
[
"@vue/babel-preset-jsx",
{
"compositionAPI": true
}
]
],
"plugins": [
Expand All @@ -19,13 +25,14 @@
"@babel/plugin-syntax-dynamic-import",
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose" : true }],
"babel-plugin-parameter-decorator",
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions",
"@babel/plugin-transform-async-to-generator",
["babel-plugin-import-bk-magic-vue", { "baseLibName": "bk-magic-vue" }],
"transform-vue-jsx"
"@babel/plugin-proposal-optional-chaining"
],
"env": {
"test": {
Expand Down
1 change: 1 addition & 0 deletions paas-ce/lesscode/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib/server/model/migrations/
190 changes: 187 additions & 3 deletions paas-ce/lesscode/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint',
parser: '@typescript-eslint/parser',
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true
Expand All @@ -12,11 +12,13 @@ module.exports = {
},
extends: [
'plugin:vue/recommended',
'standard'
'standard',
'@vue/typescript'
],
// required to lint *.vue files
plugins: [
'vue'
'vue',
'@typescript-eslint'
],
// 代码中的全局变量key 为全局变量名称value true 允许被重写 false 不允许被重写
globals: {
Expand All @@ -31,6 +33,188 @@ module.exports = {
},
// add your custom rules hered
rules: {
'@typescript-eslint/adjacent-overload-signatures': 'error',
/**
* 类的只读属性若是一个字面量则必须使用只读属性而不是 getter
*/
'@typescript-eslint/class-literal-property-style': [
'error',
'fields'
],
/**
* 类型断言必须使用 as Type禁止使用 <Type>禁止对对象字面量进行类型断言断言成 any 是允许的
* @reason <Type> 容易被理解为 jsx
*/
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'never'
}
],
/**
* 优先使用 interface 而不是 type
*/
'@typescript-eslint/consistent-type-definitions': 'off',
/**
* 必须设置类的成员的可访问性
* @reason 将不需要公开的成员设为私有的可以增强代码的可理解性对文档输出也很友好
*/
'@typescript-eslint/explicit-member-accessibility': 'off',
/**
* 要求或禁止在函数标识符和其调用之间有空格
*/
'@typescript-eslint/func-call-spacing': [
'error',
'never'
],
/**
* 指定类成员的排序规则
* @reason 优先级
* 1. static > instance
* 2. field > constructor > method
* 3. public > protected > private
*/
'@typescript-eslint/member-ordering': [
'error',
{
default: [
'public-static-field',
'protected-static-field',
'private-static-field',
'static-field',
'public-static-method',
'protected-static-method',
'private-static-method',
'static-method',
'public-instance-field',
'protected-instance-field',
'private-instance-field',
'public-field',
'protected-field',
'private-field',
'instance-field',
'field',
'constructor',
'public-instance-method',
'protected-instance-method',
'private-instance-method',
'public-method',
'protected-method',
'private-method',
'instance-method',
'method'
]
}
],
/**
* 接口中的方法必须用属性的方式定义
*/
'@typescript-eslint/method-signature-style': 'off',
/** JS 规则的 TS 版本 */
'@typescript-eslint/no-array-constructor': 'error',
/** JS 规则的 TS 版本 */
'@typescript-eslint/no-dupe-class-members': 'error',
/**
* 禁止定义空的接口
*/
'@typescript-eslint/no-empty-interface': 'error',
/**
* 禁止给一个初始化时直接赋值为 number, string 的变量显式的声明类型
* @reason 可以简化代码
*/
'@typescript-eslint/no-inferrable-types': 'warn',
/**
* 禁止使用 namespace 来定义命名空间
* @reason 使用 es6 引入模块才是更标准的方式
* 但是允许使用 declare namespace ... {} 来定义外部命名空间
*/
'@typescript-eslint/no-namespace': [
'error',
{
allowDeclarations: true,
allowDefinitionFiles: true
}
],
/**
* 禁止在 optional chaining 之后使用 non-null 断言感叹号
* @reason optional chaining 后面的属性一定是非空的
*/
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
/**
* 禁止给类的构造函数的参数添加修饰符
*/
'@typescript-eslint/no-parameter-properties': 'off',
/**
* 禁止无用的表达式
*/
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTernary: true,
allowTaggedTemplates: true
}
],
/**
* 禁止出现没必要的 constructor
*/
'@typescript-eslint/no-useless-constructor': 'warn',
/**
* 使用函数类型别名替代包含函数调用声明的接口
*/
'@typescript-eslint/prefer-function-type': 'warn',
/**
* 禁止使用 module 来定义命名空间
* @reason module 已成为 js 的关键字
*/
'@typescript-eslint/prefer-namespace-keyword': 'error',
/**
* 使用 optional chaining 替代 &&
*/
/** JS 规则的 TS 版本 */
'@typescript-eslint/quotes': [
'warn',
'single',
{
allowTemplateLiterals: false
}
],
/**
* 禁止使用三斜杠导入文件
* @reason 三斜杠是已废弃的语法但在类型声明文件中还是可以使用的
*/
'@typescript-eslint/triple-slash-reference': [
'error',
{
path: 'never',
types: 'always',
lib: 'always'
}
],
/**
* 在类型注释周围需要一致的间距
*/
'@typescript-eslint/type-annotation-spacing': 'error',
/**
* interface type 定义时必须声明成员的类型
*/
'@typescript-eslint/typedef': [
'error',
{
arrayDestructuring: false,
arrowParameter: false,
memberVariableDeclaration: false,
objectDestructuring: false,
parameter: false,
propertyDeclaration: true,
variableDeclaration: false
}
],
/**
* 函数重载时若能通过联合类型将两个函数的类型声明合为一个则使用联合类型而不是两个函数声明
*/
'@typescript-eslint/unified-signatures': 'error',
// https://eslint.org/docs/rules/brace-style
'brace-style': ['error', '1tbs', { 'allowSingleLine': false }],

Expand Down
3 changes: 3 additions & 0 deletions paas-ce/lesscode/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ upload
!lib/client/src/element-materials/**/upload
temp
npmTemp
downloadTemp
lib/server/conf/data-base.js
lib/server/conf/http.js
lib/server/conf/db-migrate.json
lib/server/conf/npm.js
lib/server/conf/bk-repo.js
lib/server/conf/data-source.js
lib/server/conf/encrypt-secret-key.js

!lib/server/project-template/project-init-code/bin
lib/server/project-template/project-target*
Expand Down
Loading

0 comments on commit a8e0184

Please sign in to comment.