securityos/node_modules/eslint-plugin-unicorn/rules/fix/remove-spaces-after.js

15 lines
453 B
JavaScript
Raw Permalink Normal View History

2024-09-06 15:32:35 +00:00
'use strict';
function removeSpacesAfter(indexOrNodeOrToken, sourceCode, fixer) {
let index = indexOrNodeOrToken;
if (typeof indexOrNodeOrToken === 'object' && Array.isArray(indexOrNodeOrToken.range)) {
index = indexOrNodeOrToken.range[1];
}
const textAfter = sourceCode.text.slice(index);
const [leadingSpaces] = textAfter.match(/^\s*/);
return fixer.removeRange([index, index + leadingSpaces.length]);
}
module.exports = removeSpacesAfter;