Skip to content

Commit

Permalink
chore: putout: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Jun 27, 2024
1 parent 26dc13c commit 3a4d9a1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {types, operator} from 'putout';

const {compare} = operator;

const {
isNumericLiteral,
isStringLiteral,
Expand Down
12 changes: 6 additions & 6 deletions packages/plugin-for-of/lib/remove-unused-variables/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ module.exports.report = (path) => {
};

module.exports.match = () => ({
'for (const __array of __b) __c': (vars, path) => match(path),
'for (const __object of __b) __c': (vars, path) => match(path),
'for (const __array of __b) __c': matchForOf,
'for (const __object of __b) __c': matchForOf,
});

module.exports.replace = () => ({
'for (const __array of __b) __c': (vars, path) => replace(path),
'for (const __object of __b) __c': (vars, path) => replace(path),
'for (const __array of __b) __c': replaceForOf,
'for (const __object of __b) __c': replaceForOf,
});

function match(path) {
function matchForOf(vars, path) {
const idPath = path.get('left.declarations.0.id');
const elements = getElements(idPath);

return !isAllReferenced(idPath, elements);
}

function replace(path) {
function replaceForOf(vars, path) {
const variables = getVariables(path);

for (const currentPath of variables) {
Expand Down
14 changes: 6 additions & 8 deletions packages/plugin-minify/lib/remove-return-undefined/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
export const report = () => `Avoid 'return undefined'`;

export const match = () => ({
return: check,
return: (vars, {parentPath}) => {
if (!parentPath.isBlockStatement())
return false;

return parentPath.parentPath.isFunction();
},
});

export const replace = () => ({
'return': '',
'return undefined': 'return',
'return void 0': 'return',
});

function check(vars, {parentPath}) {
if (!parentPath.isBlockStatement())
return false;

return parentPath.parentPath.isFunction();
}

0 comments on commit 3a4d9a1

Please sign in to comment.