@trivago/prettier-plugin-sort-imports
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -44,3 +44,3 @@ "use strict"; | ||
}; | ||
var code = "// first comment\n// second comment\nimport z from 'z';\nimport c from 'c';\nimport g from 'g';\nimport t from 't';\nimport k from 'k';\nimport a from 'a';\n"; | ||
var code = "// first comment\n// second comment\nimport z from 'z';\nimport c from 'c';\nimport g from 'g';\nimport t from 't';\nimport k from 'k';\n// import a from 'a';\n // import a from 'a';\nimport a from 'a';\n"; | ||
test('it should remove nodes from the original code', function () { | ||
@@ -47,0 +47,0 @@ var importNodes = getImportNodes(code); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeNodesFromOriginalCode = void 0; | ||
/** Escapes a string literal to be passed to new RegExp. See: https://stackoverflow.com/a/6969486/480608. | ||
* @param s the string to escape | ||
*/ | ||
var escapeRegExp = function (s) { return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }; | ||
/** | ||
@@ -16,3 +20,6 @@ * Removes imports from original file | ||
if (Number.isSafeInteger(start) && Number.isSafeInteger(end)) { | ||
text = text.replace(code.substring(start, end), ''); | ||
text = text.replace( | ||
// only replace imports at the beginning of the line (ignoring whitespace) | ||
// otherwise matching commented imports will be replaced | ||
new RegExp('^\\s*' + escapeRegExp(code.substring(start, end)), 'm'), ''); | ||
} | ||
@@ -19,0 +26,0 @@ } |
{ | ||
"name": "@trivago/prettier-plugin-sort-imports", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "A prettier plugins to sort imports in provided RegEx order", | ||
@@ -5,0 +5,0 @@ "main": "lib/src/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
383674
664