Skip to content

Commit

Permalink
style: use no-object-expression-in-arguments
Browse files Browse the repository at this point in the history
Используем общий no-object-expression-in-arguments, вместо внутреннего
  • Loading branch information
SevereCloud committed Jul 28, 2023
1 parent 29c5b59 commit d5f33a4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 60 deletions.
2 changes: 1 addition & 1 deletion packages/vkui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = {
'react/react-in-jsx-scope': 'off',
'react/no-unknown-property': ['error'],

'@project-tools/vkui/no-object-expression-in-arguments': [
'@vkontakte/no-object-expression-in-arguments': [
'error',
{
onlyForFunctionsWithNames: ['classNames'],
Expand Down
60 changes: 1 addition & 59 deletions tools/eslint-plugin-vkui/index.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,3 @@
/** @type {import('eslint').Rule.RuleModule} */
const noObjectExpressionInArguments = {
meta: {
schema: [
{
type: 'object',
properties: {
onlyForFunctionsWithNames: {
oneOf: [
{
type: 'array',
items: {
type: 'string',
},
},
{
type: 'string',
},
],
},
},
},
],
},
create(context) {
const options = context.options;
let onlyForFunctionsWithNames = null;

options.forEach((option) => {
if ('onlyForFunctionsWithNames' in option) {
onlyForFunctionsWithNames = option.onlyForFunctionsWithNames;
}
});

return {
/** @param node {import('estree').CallExpression} */
CallExpression(node) {
if (onlyForFunctionsWithNames && !onlyForFunctionsWithNames.includes(node.callee.name)) {
return;
}
const args = node.arguments;
for (let i = 0; i < args.length; i += 1) {
const arg = args[i];
if (arg.type === 'ObjectExpression') {
context.report({
node,
message: 'Do not use object expression in arguments.',
});
break;
}
}
},
};
},
};

module.exports = {
rules: {
'no-object-expression-in-arguments': noObjectExpressionInArguments,
},
rules: {},
};

0 comments on commit d5f33a4

Please sign in to comment.