Skip to content

Commit

Permalink
refactor: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyunhe committed Feb 11, 2024
1 parent 9907540 commit df5806b
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 44 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ build
coverage
dist
es
fixtures
lib
template
templates
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ coverage
dist
docs
es
fixtures
lib
template
templates
Expand Down
11 changes: 1 addition & 10 deletions packages/commitlint-config-ali/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
],
},
};
17 changes: 0 additions & 17 deletions packages/eslint-config-ali/.editorconfig

This file was deleted.

2 changes: 1 addition & 1 deletion packages/eslint-plugin-ali/src/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ module.exports = {
'ali/no-http-url': 'warn',
'ali/no-secret-info': 'error',
},
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ module.exports = {
return {};
}

const cwd = context.getCwd();

return {
Property: function handleRequires(node) {
if (
Expand Down
12 changes: 9 additions & 3 deletions packages/eslint-plugin-ali/src/rules/no-js-in-ts-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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('|')})$`);

Expand Down
19 changes: 9 additions & 10 deletions packages/eslint-plugin-ali/src/rules/no-secret-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/stylelint-config-ali/test/rules-validate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down

0 comments on commit df5806b

Please sign in to comment.