Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const {replaceWithMultiple} = require('putout').operate;
module.exports.report = () => 'Nested blocks should not be used';
module.exports.fix = (path) => {
replaceWithMultiple(path, path.node.body);
};
module.exports.traverse = ({push}) => {
return {
BlockStatement(path) {
if (!path.parentPath.isBlockStatement())
return;
push(path);
},
};
'use strict';
const {replaceWith} = require('putout').operate;
module.exports.report = () => `Destructuring should be used in the head of for-of`;
module.exports.fix = ({path, varPath}) => {
replaceWith(varPath, path.node.id);
path.remove();
};
module.exports.traverse = ({push}) => {
return {
'for (const __ of __) __'(path) {
const leftPath = path.get('left');
const varPath = leftPath.get('declarations.0.id');
if (!varPath.isIdentifier())
return;
'use strict';
const {replaceWith} = require('putout').operate;
const {traverseClass} = require('../common');
module.exports.report = ({name}) => `should be used "${name}" instead of "this.${name}"`;
module.exports.fix = ({path}) => {
replaceWith(path, path.get('property'));
};
module.exports.find = (ast, {push, traverse}) => {
traverseClass(traverse, ast, {
ThisExpression(path) {
const {parentPath} = path;
const propertyPath = parentPath.get('property');
const {name} = propertyPath.node;
'use strict';
const {replaceWithMultiple} = require('putout').operate;
const {template} = require('putout');
const buildHooks = template(`
SETTER(VALUE);
`);
module.exports = (path) => {
const {properties} = path.node.arguments[0];
const nodes = [];
for (const {key, value} of properties) {
const {name} = key;
const SETTER = getSetter(name);
const VALUE = String(value.value);
'use strict';
const {replaceWith} = require('putout').operate;
module.exports.report = () => `Useless spread should be avoided`;
module.exports.fix = (path) => {
const [element] = path.node.elements;
replaceWith(path, element.argument);
};
module.exports.include = () => [
'[...__]',
];
module.exports.exclude= () => [
'[...__].__()',
'return [...__]',
];