diff --git a/.gitignore b/.gitignore index ec5b1b0d1..2f9415f0b 100644 --- a/.gitignore +++ b/.gitignore @@ -131,3 +131,6 @@ open_paas_unittest .DS_Store .vscode/ # End of https://www.gitignore.io/api/python + +# lesscode pre-commie +.pre-commit-config.yaml diff --git a/paas-ce/lesscode/.babelrc b/paas-ce/lesscode/.babelrc new file mode 100644 index 000000000..f9bfa61de --- /dev/null +++ b/paas-ce/lesscode/.babelrc @@ -0,0 +1,42 @@ +{ + "presets": [ + [ + "@babel/preset-env", + { + "modules": "commonjs", + "targets": { + "browsers": ["> 1%", "last 2 versions", "not ie <= 8"], + "node": "current" + }, + "debug": false + } + ] + ], + "plugins": [ + "@babel/plugin-transform-runtime", + "@babel/plugin-transform-object-assign", + "lodash", + "@babel/plugin-syntax-dynamic-import", + ["@babel/plugin-proposal-decorators", { "legacy": true }], + "@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" + ], + "env": { + "test": { + "presets": ["@babel/preset-env"], + "plugins": [ + "istanbul", + ["@babel/plugin-proposal-decorators", { "legacy": true }], + "@babel/plugin-proposal-function-sent", + "@babel/plugin-proposal-export-namespace-from", + "@babel/plugin-proposal-numeric-separator", + "@babel/plugin-proposal-throw-expressions" + ] + } + } +} diff --git a/paas-ce/lesscode/.browserslistrc b/paas-ce/lesscode/.browserslistrc new file mode 100644 index 000000000..8b44c0338 --- /dev/null +++ b/paas-ce/lesscode/.browserslistrc @@ -0,0 +1,2 @@ +last 2 versions +maintained node versions diff --git a/paas-ce/lesscode/.eslintignore b/paas-ce/lesscode/.eslintignore new file mode 100644 index 000000000..9339bca89 --- /dev/null +++ b/paas-ce/lesscode/.eslintignore @@ -0,0 +1,2 @@ +static/ +tippy/ diff --git a/paas-ce/lesscode/.eslintrc.js b/paas-ce/lesscode/.eslintrc.js new file mode 100644 index 000000000..4c059beb1 --- /dev/null +++ b/paas-ce/lesscode/.eslintrc.js @@ -0,0 +1,474 @@ +module.exports = { + root: true, + parserOptions: { + parser: 'babel-eslint', + sourceType: 'module' + }, + env: { + browser: true + }, + extends: [ + 'plugin:vue/recommended', + 'standard' + ], + // required to lint *.vue files + plugins: [ + 'vue' + ], + // 代码中的全局变量,key 为全局变量名称,value 为 true 允许被重写,为 false 不允许被重写 + globals: { + NODE_ENV: false, + LOGIN_SERVICE_URL: false, + AJAX_URL_PREFIX: false, + APP_CODE: false, + ENV: false, + monaco: false, + ResizeSensor: false + }, + // add your custom rules hered + rules: { + // https://eslint.org/docs/rules/brace-style + 'brace-style': ['error', '1tbs', { 'allowSingleLine': false }], + + // https://eslint.org/docs/rules/camelcase + 'camelcase': ['error', { 'properties': 'never', 'ignoreDestructuring': true }], + + // 缩进使用 4 个空格,并且 switch 语句中的 Case 需要缩进 + // https://eslint.org/docs/rules/indent + 'indent': ['error', 4, { + 'SwitchCase': 1, + 'flatTernaryExpressions': true + }], + + // 数组的括号内的前后禁止有空格 + // https://eslint.org/docs/rules/array-bracket-spacing + 'array-bracket-spacing': ['error', 'never'], + + // https://eslint.org/docs/rules/operator-linebreak + 'operator-linebreak': ['error', 'before'], + + // 在开发阶段打开调试 + // https://eslint.org/docs/rules/no-debugger + 'no-debugger': 'off', + + // 只有一个参数时,箭头函数体可以省略圆括号 + // https://eslint.org/docs/rules/arrow-parens + 'arrow-parens': 'off', + + // 禁止空语句(可在空语句写注释避免),允许空的 catch 语句 + // https://eslint.org/docs/rules/no-empty + 'no-empty': ['error', { 'allowEmptyCatch': true }], + + // 禁止在语句末尾使用分号 + // https://eslint.org/docs/rules/semi + 'semi': ['error', 'never'], + + // 禁用不必要的分号 + // https://eslint.org/docs/rules/no-extra-semi + 'no-extra-semi': 'error', + + // generator 的 * 前面禁止有空格,后面必须有空格 + // https://eslint.org/docs/rules/generator-star-spacing + 'generator-star-spacing': [ + 'error', + { + before: false, + after: true + } + ], + + // 函数圆括号之前有一个空格 + // https://eslint.org/docs/rules/space-before-function-paren + 'space-before-function-paren': ['error', { + 'anonymous': 'always', // 匿名函数表达式 + 'named': 'always', // 命名的函数表达式 + 'asyncArrow': 'always' // 异步的箭头函数表达式 + }], + + // 禁止行尾有空格 + // https://eslint.org/docs/rules/no-trailing-spaces + 'no-trailing-spaces': ['error', { + 'skipBlankLines': true // 允许在空行使用空白符 + }], + + // 注释的斜线或 * 后必须有空格 + // https://eslint.org/docs/rules/spaced-comment + 'spaced-comment': ['error', 'always', { + 'line': { + 'markers': ['*package', '!', '/', ',', '='] + }, + 'block': { + // 前后空格是否平衡 + 'balanced': false, + 'markers': ['*package', '!', ',', ':', '::', 'flow-include'], + 'exceptions': ['*'] + } + }], + + // https://eslint.org/docs/rules/no-template-curly-in-string + // 禁止在字符串中使用字符串模板。不限制 + 'no-template-curly-in-string': 'off', + + // https://eslint.org/docs/rules/no-useless-escape + // 禁止出现没必要的转义。不限制 + 'no-useless-escape': 'off', + + // https://eslint.org/docs/rules/no-var + // 禁止使用 var + 'no-var': 'error', + + // https://eslint.org/docs/rules/prefer-const + // 如果一个变量不会被重新赋值,必须使用 `const` 进行声明。 + 'prefer-const': 'error', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/array-bracket-spacing.md + 'vue/array-bracket-spacing': ['error', 'never'], + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/arrow-spacing.md + 'vue/arrow-spacing': ['error', { 'before': true, 'after': true }], + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/attribute-hyphenation.md + 'vue/attribute-hyphenation': ['error', 'always'], + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/attributes-order.md + // 属性顺序,不限制 + 'vue/attributes-order': 'off', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/block-spacing.md + 'vue/block-spacing': ['error', 'always'], + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/brace-style.md + 'vue/brace-style': ['error', '1tbs', { 'allowSingleLine': false }], + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/camelcase.md + // 后端数据字段经常不是驼峰,所以不限制 properties,也不限制解构 + 'vue/camelcase': ['error', { 'properties': 'never', 'ignoreDestructuring': true }], + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/comma-dangle.md + // 禁止使用拖尾逗号,如 {demo: 'test',} + 'vue/comma-dangle': ['error', 'never'], + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/comment-directive.md + // vue 文件 template 中允许 eslint-disable eslint-enable eslint-disable-line eslint-disable-next-line + // 行内注释启用/禁用某些规则,配置为 1 即允许 + 'vue/comment-directive': 1, + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/component-name-in-template-casing.md + // 组件 html 标签的形式,连字符形式,所有 html 标签均会检测,如引入第三方不可避免,可通过 ignores 配置,支持正则,不限制 + 'vue/component-name-in-template-casing': 'off', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/dot-location.md + // 等待 https://github.com/vuejs/eslint-plugin-vue/pull/794 合入 + // 'vue/dot-location': ['error', 'property'], + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/eqeqeq.md + 'vue/eqeqeq': ['error', 'always', { 'null': 'ignore' }], + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-closing-bracket-newline.md + // 单行写法不需要换行,多行需要,不限制 + 'vue/html-closing-bracket-newline': 'off', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-closing-bracket-spacing.md + 'vue/html-closing-bracket-spacing': ['error', { + 'startTag': 'never', + 'endTag': 'never', + 'selfClosingTag': 'always' + }], + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-end-tags.md + 'vue/html-end-tags': 'error', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-indent.md + 'vue/html-indent': ['error', 4, { + 'attribute': 1, + 'baseIndent': 1, + 'closeBracket': 0, + 'alignAttributesVertically': false, + 'ignores': [] + }], + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-quotes.md + 'vue/html-quotes': ['error', 'double'], + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-self-closing.md + // html tag 是否自闭和,不限制 + 'vue/html-self-closing': 'off', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/jsx-uses-vars.md + // 当变量在 `JSX` 中被使用了,那么 eslint 就不会报出 `no-unused-vars` 的错误。需要开启 eslint no-unused-vars 规则才适用 + 'vue/jsx-uses-vars': 1, + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/key-spacing.md + 'vue/key-spacing': ['error', { 'beforeColon': false, 'afterColon': true }], + + // 关键字周围空格一致性,在关键字前后保留空格,如 if () else {} + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/keyword-spacing.md + // 等待 https://github.com/vuejs/eslint-plugin-vue/pull/795 合入 + // 'vue/keyword-spacing': ['error', {'before': true, 'after': true}], + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/match-component-file-name.md + // 组件名称属性与其文件名匹配,不限制 + 'vue/match-component-file-name': 'off', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/max-attributes-per-line.md + // 每行属性的最大个数,不限制 + 'vue/max-attributes-per-line': 'off', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/multiline-html-element-content-newline.md + // 在多行元素的内容前后需要换行符,不限制 + 'vue/multiline-html-element-content-newline': 'off', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/mustache-interpolation-spacing.md + // template 中 {{var}},不限制 + 'vue/mustache-interpolation-spacing': 'off', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/name-property-casing.md + 'vue/name-property-casing': 'off', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-async-in-computed-properties.md + 'vue/no-async-in-computed-properties': 'error', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-boolean-default.md + 'vue/no-boolean-default': 'off', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-confusing-v-for-v-if.md + 'vue/no-confusing-v-for-v-if': 'error', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-dupe-keys.md + // 二级属性名禁止重复 + 'vue/no-dupe-keys': 'error', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-duplicate-attributes.md + // 禁止 html 元素中出现重复的属性 + 'vue/no-duplicate-attributes': 'error', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-empty-pattern.md + // 等待 https://github.com/vuejs/eslint-plugin-vue/pull/798 合入 + // 禁止解构中出现空 {} 或 [] + // 'vue/no-empty-pattern': 'error', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-multi-spaces.md + // 删除 html 标签中连续多个不用于缩进的空格 + 'vue/no-multi-spaces': 'error', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-parsing-error.md + // 禁止语法错误 + 'vue/no-parsing-error': 'error', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-reserved-keys.md + // 禁止使用保留字 + 'vue/no-reserved-keys': 'error', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-restricted-syntax.md + // 禁止使用特定的语法 + 'vue/no-restricted-syntax': 'off', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-shared-component-data.md + // data 属性必须是函数 + 'vue/no-shared-component-data': 'error', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-side-effects-in-computed-properties.md + // 禁止在计算属性对属性进行修改,不限制 + 'vue/no-side-effects-in-computed-properties': 'off', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-spaces-around-equal-signs-in-attribute.md + 'vue/no-spaces-around-equal-signs-in-attribute': 'error', + + // https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/no-template-key.md + // 禁止在