Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@trivago/prettier-plugin-sort-imports

Package Overview
Dependencies
Maintainers
4
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trivago/prettier-plugin-sort-imports - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

8

CHANGELOG.md

@@ -5,4 +5,8 @@ ## Changelog

---
### v4.1.1
#### Revert
- Type imports[#153](https://github.com/trivago/prettier-plugin-sort-imports/pull/153) by [Xenfo](https://github.com/broofa)
### v4.1.0
### New features
#### New features
- Move @babel/core to devDependencies [#200](https://github.com/trivago/prettier-plugin-sort-imports/pull/200) by [yykamei](https://github.com/yykamei)

@@ -14,3 +18,3 @@ - Only preserve directives already at the start of the program [#198](https://github.com/trivago/prettier-plugin-sort-imports/pull/198) by [c-dante](https://github.com/c-dante)

- Change @vue/compiler-sfc to an optional dependency[#189](https://github.com/trivago/prettier-plugin-sort-imports/pull/189) by [transitive-bullshit](https://github.com/transitive-bullshit)
- Keep script directives at top of file [#186](https://github.com/trivago/prettier-plugin-sort-imports/pull/186) by [broofa](https://github.com/broofa)
- Type imports[#153](https://github.com/trivago/prettier-plugin-sort-imports/pull/153) by [Xenfo](https://github.com/broofa)

@@ -17,0 +21,0 @@ ### v4.0.0

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.newLineNode = exports.TYPES_SPECIAL_WORD = exports.THIRD_PARTY_TYPES_SPECIAL_WORD = exports.THIRD_PARTY_MODULES_SPECIAL_WORD = exports.newLineCharacters = exports.jsx = exports.typescript = exports.flow = void 0;
exports.newLineNode = exports.THIRD_PARTY_MODULES_SPECIAL_WORD = exports.newLineCharacters = exports.jsx = exports.typescript = exports.flow = void 0;
var types_1 = require("@babel/types");

@@ -14,5 +14,3 @@ exports.flow = 'flow';

exports.THIRD_PARTY_MODULES_SPECIAL_WORD = '<THIRD_PARTY_MODULES>';
exports.THIRD_PARTY_TYPES_SPECIAL_WORD = '<THIRD_PARTY_TS_TYPES>';
exports.TYPES_SPECIAL_WORD = '<TS_TYPES>';
var PRETTIER_PLUGIN_SORT_IMPORTS_NEW_LINE = 'PRETTIER_PLUGIN_SORT_IMPORTS_NEW_LINE';
exports.newLineNode = (0, types_1.expressionStatement)((0, types_1.stringLiteral)(PRETTIER_PLUGIN_SORT_IMPORTS_NEW_LINE));

@@ -8,3 +8,2 @@ "use strict";

var code = "// first comment\n// second comment\nimport z from 'z';\nimport c, { cD } from 'c';\nimport g from 'g';\nimport { tC, tA, tB } from 't';\nimport k, { kE, kB } from 'k';\nimport * as a from 'a';\nimport * as x from 'x';\nimport BY from 'BY';\nimport Ba from 'Ba';\nimport XY from 'XY';\nimport Xa from 'Xa';\n";
var typeCode = "// first comment\n// second comment\nimport type sm from 'sm';\nimport type xl from './xl';\nimport l from './l';\nimport z from 'z';\nimport c, { cD } from 'c';\nimport g from 'g';\nimport { tC, tA, tB } from 't';\nimport k, { kE, kB } from 'k';\nimport * as a from 'a';\nimport * as x from 'x';\nimport BY from 'BY';\nimport Ba from 'Ba';\nimport XY from 'XY';\nimport Xa from 'Xa';\n";
test('it returns all sorted nodes', function () {

@@ -296,49 +295,1 @@ var result = (0, get_import_nodes_1.getImportNodes)(code);

});
test('it returns all sorted nodes with types', function () {
var result = (0, get_import_nodes_1.getImportNodes)(typeCode, {
plugins: ['typescript'],
});
var sorted = (0, get_sorted_nodes_1.getSortedNodes)(result, {
importOrder: ["<THIRD_PARTY_TS_TYPES>", "^[./]", "<TS_TYPES>^[./]"],
importOrderCaseInsensitive: false,
importOrderSeparation: false,
importOrderGroupNamespaceSpecifiers: false,
importOrderSortSpecifiers: false,
});
expect((0, get_sorted_nodes_names_1.getSortedNodesNames)(sorted)).toEqual([
'BY',
'Ba',
'XY',
'Xa',
'a',
'c',
'g',
'k',
't',
'x',
'z',
'sm',
'./l',
'./xl',
]);
expect(sorted
.filter(function (node) { return node.type === 'ImportDeclaration'; })
.map(function (importDeclaration) {
return (0, get_sorted_nodes_modules_names_1.getSortedNodesModulesNames)(importDeclaration.specifiers);
})).toEqual([
['BY'],
['Ba'],
['XY'],
['Xa'],
['a'],
['c', 'cD'],
['g'],
['k', 'kE', 'kB'],
['tC', 'tA', 'tB'],
['x'],
['z'],
['sm'],
['l'],
['xl'],
]);
});

@@ -13,13 +13,6 @@ "use strict";

group: group,
regExp: group.startsWith(constants_1.TYPES_SPECIAL_WORD)
? new RegExp(group.replace(constants_1.TYPES_SPECIAL_WORD, ''))
: new RegExp(group),
regExp: new RegExp(group),
}); });
for (var _i = 0, groupWithRegExp_1 = groupWithRegExp; _i < groupWithRegExp_1.length; _i++) {
var _a = groupWithRegExp_1[_i], group = _a.group, regExp = _a.regExp;
if ((group.startsWith(constants_1.TYPES_SPECIAL_WORD) &&
node.importKind !== 'type') ||
(!group.startsWith(constants_1.TYPES_SPECIAL_WORD) &&
node.importKind === 'type'))
continue;
var matched = node.source.value.match(regExp) !== null;

@@ -29,7 +22,4 @@ if (matched)

}
return node.importKind === 'type' &&
importOrder.find(function (group) { return group === constants_1.THIRD_PARTY_TYPES_SPECIAL_WORD; })
? constants_1.THIRD_PARTY_TYPES_SPECIAL_WORD
: constants_1.THIRD_PARTY_MODULES_SPECIAL_WORD;
return constants_1.THIRD_PARTY_MODULES_SPECIAL_WORD;
};
exports.getImportNodesMatchedGroup = getImportNodesMatchedGroup;
{
"name": "@trivago/prettier-plugin-sort-imports",
"version": "4.1.0",
"version": "4.1.1",
"description": "A prettier plugins to sort imports in provided RegEx order",

@@ -5,0 +5,0 @@ "main": "lib/src/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc