diff --git a/.eslintignore b/.eslintignore index 34472bc..dcddf74 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,6 +2,7 @@ build coverage dist es +fixtures lib template templates diff --git a/.prettierignore b/.prettierignore index 2d7728c..959529c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,6 +3,7 @@ coverage dist docs es +fixtures lib template templates diff --git a/packages/commitlint-config-ali/index.js b/packages/commitlint-config-ali/index.js index 43395d1..f7eba85 100644 --- a/packages/commitlint-config-ali/index.js +++ b/packages/commitlint-config-ali/index.js @@ -15,16 +15,7 @@ module.exports = { 'type-enum': [ 2, 'always', - [ - 'feat', - 'fix', - 'docs', - 'style', - 'test', - 'refactor', - 'chore', - 'revert', - ], + ['feat', 'fix', 'docs', 'style', 'test', 'refactor', 'chore', 'revert'], ], }, }; diff --git a/packages/eslint-config-ali/.editorconfig b/packages/eslint-config-ali/.editorconfig deleted file mode 100644 index e5ddb58..0000000 --- a/packages/eslint-config-ali/.editorconfig +++ /dev/null @@ -1,17 +0,0 @@ -# http://editorconfig.org -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false - -[makefile] -indent_style = tab -indent_size = 4 diff --git a/packages/eslint-plugin-ali/src/configs/recommended.js b/packages/eslint-plugin-ali/src/configs/recommended.js index 647c8aa..64bcca2 100644 --- a/packages/eslint-plugin-ali/src/configs/recommended.js +++ b/packages/eslint-plugin-ali/src/configs/recommended.js @@ -4,4 +4,4 @@ module.exports = { 'ali/no-http-url': 'warn', 'ali/no-secret-info': 'error', }, -} \ No newline at end of file +}; diff --git a/packages/eslint-plugin-ali/src/rules/no-broad-semantic-versioning.js b/packages/eslint-plugin-ali/src/rules/no-broad-semantic-versioning.js index 0a749a6..61c3c7f 100644 --- a/packages/eslint-plugin-ali/src/rules/no-broad-semantic-versioning.js +++ b/packages/eslint-plugin-ali/src/rules/no-broad-semantic-versioning.js @@ -22,8 +22,6 @@ module.exports = { return {}; } - const cwd = context.getCwd(); - return { Property: function handleRequires(node) { if ( diff --git a/packages/eslint-plugin-ali/src/rules/no-js-in-ts-project.js b/packages/eslint-plugin-ali/src/rules/no-js-in-ts-project.js index f56ec4f..175f423 100644 --- a/packages/eslint-plugin-ali/src/rules/no-js-in-ts-project.js +++ b/packages/eslint-plugin-ali/src/rules/no-js-in-ts-project.js @@ -5,7 +5,12 @@ const RULE_NAME = 'no-js-in-ts-project'; const JS_REG = /\.jsx?$/; -const DEFAULT_WHITE_LIST = ['commitlint.config.js', 'eslintrc.js', 'prettierrc.js', 'stylelintrc.js']; +const DEFAULT_WHITE_LIST = [ + 'commitlint.config.js', + 'eslintrc.js', + 'prettierrc.js', + 'stylelintrc.js', +]; module.exports = { name: RULE_NAME, @@ -24,11 +29,12 @@ module.exports = { const fileName = context.getFilename(); const extName = path.extname(fileName); const ruleOptions = context.options[0] || {}; - let { whiteList = [], autoMerge = true } = ruleOptions; + let { whiteList = [] } = ruleOptions; + const { autoMerge = true } = ruleOptions; if (whiteList.length === 0) { whiteList = DEFAULT_WHITE_LIST; } else if (autoMerge) { - whiteList = [...new Set([...DEFAULT_WHITE_LIST, ...whiteList])] + whiteList = [...new Set([...DEFAULT_WHITE_LIST, ...whiteList])]; } const whiteListReg = new RegExp(`(${whiteList.join('|')})$`); diff --git a/packages/eslint-plugin-ali/src/rules/no-secret-info.js b/packages/eslint-plugin-ali/src/rules/no-secret-info.js index a62a42a..5725160 100644 --- a/packages/eslint-plugin-ali/src/rules/no-secret-info.js +++ b/packages/eslint-plugin-ali/src/rules/no-secret-info.js @@ -18,7 +18,8 @@ module.exports = { create(context) { const ruleOptions = context.options[0] || {}; - let { dangerousKeys = [], autoMerge = true } = ruleOptions; + let { dangerousKeys = [] } = ruleOptions; + const { autoMerge = true } = ruleOptions; if (dangerousKeys.length === 0) { dangerousKeys = DEFAULT_DANGEROUS_KEYS; } else if (autoMerge) { @@ -29,18 +30,16 @@ module.exports = { return { Literal: function handleRequires(node) { if ( - node.value && node.parent && ( - (node.parent.type === 'VariableDeclarator' && - node.parent.id && - node.parent.id.name && - reg.test(node.parent.id.name.toLocaleLowerCase()) - ) || + node.value && + node.parent && + ((node.parent.type === 'VariableDeclarator' && + node.parent.id && + node.parent.id.name && + reg.test(node.parent.id.name.toLocaleLowerCase())) || (node.parent.type === 'Property' && node.parent.key && node.parent.key.name && - reg.test(node.parent.key.name.toLocaleLowerCase()) - ) - ) + reg.test(node.parent.key.name.toLocaleLowerCase()))) ) { context.report({ node, diff --git a/packages/stylelint-config-ali/test/rules-validate.test.ts b/packages/stylelint-config-ali/test/rules-validate.test.ts index 70d9b2d..6a80a2e 100644 --- a/packages/stylelint-config-ali/test/rules-validate.test.ts +++ b/packages/stylelint-config-ali/test/rules-validate.test.ts @@ -29,8 +29,8 @@ describe('test/rules-validate.test.js', () => { }); if (result && result.errored) { + console.log(result.results); } - console.log(result.results); expect(result.results.length).toBeGreaterThan(0); });