Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const {
insertAfter,
replaceWith,
} = operate;
const {
Identifier,
ObjectProperty,
} = types;
module.exports.report = () => {
return `"operate.replaceWithMultiple" should be called instead of "path.replaceWithMultiple"`;
};
const replaceWithAST = template.ast(`
const {replaceWithMultiple} = require('putout').operate;
`);
module.exports.fix = ({path, calleePath, property, object, program, isInserted}) => {
const strictModePath = program.get('body.0');
const {bindings} = strictModePath.scope;
replaceWith(calleePath, property);
path.node.arguments.unshift(object);
if (bindings.replaceWithMultiple)
return;
if (isInserted())
return;
replaceWith,
insertAfter,
} = operate;
const {
Identifier,
ObjectProperty,
} = types;
const fullstore = require('fullstore');
module.exports.report = () => {
return `"operate.replaceWith" should be called instead of "path.replaceWith"`;
};
const replaceWithAST = template.ast(`
const {replaceWith} = require('putout').operate;
`);
module.exports.fix = ({path, calleePath, property, object, program, isInserted}) => {
replaceWith(calleePath, property);
const strictModePath = program.get('body.0');
const {bindings} = strictModePath.scope;
path.node.arguments.unshift(object);
if (bindings.replaceWith || isInserted())
return;
if (!bindings.replaceWithMultiple && !bindings.insertAfter && !isInserted()) {
isInserted(true);
insertAfter(strictModePath, replaceWithAST);
types,
operate,
template,
} = require('putout');
const {replaceWithMultiple} = operate;
const {
isIdentifier,
isLiteral,
isStringLiteral,
ObjectProperty,
StringLiteral,
} = types;
const fixLintScript = template.ast(`
() => run('lint', '--fix')
`);
module.exports.report = () => `fix:lint should exist`;
module.exports.fix = (path) => {
replaceWithMultiple(path, [
path.node,
ObjectProperty(StringLiteral('fix:lint'), fixLintScript),
]);
};
module.exports.traverse = ({push}) => {
return {
'module.exports = __object'(path) {
const propertiesPaths = path.get('right.properties');
'use strict';
const {
operate,
template,
} = require('putout');
const {replaceWith} = operate;
const astRequire = template.ast(`
require('putout').types
`);
module.exports.report = () => {
return `"putout.types" should be used instead of "@babel/types"`;
};
function isRequire(path) {
return path
.get('callee')
.isIdentifier({name: 'require'});
}
function isBabelTypes(path) {
return path
.get('arguments.0')
'use strict';
const {
operate,
template,
types,
} = require('putout');
const {isProgram} = types;
const {findBinding} = operate;
const node = template.ast(`const {run} = require('madrun')`);
module.exports.report = () => 'run should be declared';
module.exports.fix = (path) => {
path.node.body.unshift(node);
};
module.exports.traverse = ({push}) => {
let added = false;
return {
'run(__args)'(path) {
if (added)
return;
if (findBinding(path, 'run'))