New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-putout

Package Overview
Dependencies
Maintainers
1
Versions
281
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-putout - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

2

package.json
{
"name": "eslint-plugin-putout",
"version": "1.3.1",
"version": "1.3.2",
"description": "eslint plagin for putout",

@@ -5,0 +5,0 @@ "release": false,

'use strict';
const message = 'Keep curly braces on one line when you use destructuring as function argument';
const traverse = (context) => (node) => {
const text = context
.getSourceCode()
.getText(node);
if (!/\n/.test(text))
return;
context.report({
node,
message,
fix: getFix(node, text),
});
};
const getFix = (node, text) => (fixer) => {
const fixed = text
.replace(/\n/g, '')
.replace(/ /g, '')
.replace(/,/g, ', ')
.replace(', }', '}');
return [
fixer.replaceText(node, fixed),
];
};
module.exports = {

@@ -7,3 +36,3 @@ meta: {

docs: {
description: 'Keep curly braces on one line when you use destructuring as function argument',
description: message,
category: 'destructuring',

@@ -16,28 +45,9 @@ recommended: true,

create(context) {
// can't use because of an error
// ':has(ArrowFunctionExpression, FunctionExpression, FunctionDeclaration) > .params[type=ObjectPattern]'
// Error: Unknown node type JSXElement
return {
':has(ArrowFunctionExpression, FunctionExpression, FunctionDeclaration) > .params[type=ObjectPattern]'(node) {
const text = context
.getSourceCode()
.getText(node);
if (!/\n/.test(text))
return;
context.report({
node,
message: 'Keep curly braces on one line when you use destructuring as function argument',
fix(fixer) {
const fixed =text
.replace(/\n/g, '')
.replace(/ /g, '')
.replace(/,/g, ', ')
.replace(', }', '}');
return [
fixer.replaceText(node, fixed),
];
},
});
},
'ArrowFunctionExpression > .params[type=ObjectPattern]': traverse(context),
'FunctionExpression > .params[type=ObjectPattern]': traverse(context),
'FunctionDeclaration > .params[type=ObjectPattern]': traverse(context),
};

@@ -44,0 +54,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc