@trivago/prettier-plugin-sort-imports
Advanced tools
Comparing version 3.0.0-1 to 3.0.0-2
@@ -23,3 +23,5 @@ "use strict"; | ||
array: true, | ||
default: [{ value: [] }], | ||
// By default, we add ts and jsx as parsers but if users define something | ||
// we take that option | ||
default: [{ value: ['typescript', 'jsx'] }], | ||
description: 'Deprecated! Please use `importOrderParserPlugins` to provide a list of parser plugins for special syntax.', | ||
@@ -37,3 +39,3 @@ }, | ||
category: 'Global', | ||
default: true, | ||
default: false, | ||
description: 'Provide a case sensitivity boolean flag', | ||
@@ -45,3 +47,5 @@ }, | ||
array: true, | ||
default: [{ value: [] }], | ||
// By default, we add ts and jsx as parsers but if users define something | ||
// we take that option | ||
default: [{ value: ['typescript', 'jsx'] }], | ||
description: 'Provide a list of plugins for special syntax', | ||
@@ -48,0 +52,0 @@ }, |
@@ -13,11 +13,5 @@ "use strict"; | ||
var get_experimental_parser_plugins_1 = require("./utils/get-experimental-parser-plugins"); | ||
var lodash_1 = require("lodash"); | ||
function preprocessor(code, options) { | ||
var _a = options.experimentalBabelParserPluginsList, experimentalBabelParserPluginsList = _a === void 0 ? [] : _a, // Deprecated in favor of importOrderParserPlugins | ||
_b = options.importOrderParserPlugins, // Deprecated in favor of importOrderParserPlugins | ||
importOrderParserPlugins = _b === void 0 ? [] : _b, importOrder = options.importOrder, importOrderCaseInsensitive = options.importOrderCaseInsensitive, importOrderSeparation = options.importOrderSeparation, importOrderSortSpecifiers = options.importOrderSortSpecifiers; | ||
var parserPlugins = lodash_1.isEmpty(importOrderParserPlugins) | ||
? experimentalBabelParserPluginsList | ||
: importOrderParserPlugins; | ||
var parsedParserPlugins = get_experimental_parser_plugins_1.getExperimentalParserPlugins(parserPlugins); | ||
var importOrderParserPlugins = options.importOrderParserPlugins, importOrder = options.importOrder, importOrderCaseInsensitive = options.importOrderCaseInsensitive, importOrderSeparation = options.importOrderSeparation, importOrderSortSpecifiers = options.importOrderSortSpecifiers; | ||
var parsedParserPlugins = get_experimental_parser_plugins_1.getExperimentalParserPlugins(importOrderParserPlugins); | ||
var importNodes = []; | ||
@@ -24,0 +18,0 @@ var parserOptions = { |
@@ -15,3 +15,8 @@ "use strict"; | ||
test('it should return ts related plugins', function () { | ||
expect(get_parser_plugins_1.getParserPlugins('typescript')).toEqual(['typescript', 'jsx']); | ||
expect(get_parser_plugins_1.getParserPlugins('typescript')).toEqual([ | ||
'typescript', | ||
'jsx', | ||
'decorators-legacy', | ||
'classProperties', | ||
]); | ||
}); |
@@ -19,5 +19,7 @@ "use strict"; | ||
// In case of typescript as prettier parser, we pass the following | ||
var tsPlugins = [constants_1.typescript, constants_1.jsx]; | ||
// decoratorsLegacy, classProperties are passed in case of angular | ||
// projects. | ||
var tsPlugins = [constants_1.typescript, constants_1.jsx, constants_1.decoratorsLegacy, constants_1.classProperties]; | ||
return __spreadArray(__spreadArray([], (isFlow ? [constants_1.flow] : [])), (isTypescript ? tsPlugins : [])); | ||
}; | ||
exports.getParserPlugins = getParserPlugins; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getSortedImportSpecifiers = void 0; | ||
// we do not have types for javascript-natural-sort | ||
//@ts-ignore | ||
var javascript_natural_sort_1 = __importDefault(require("javascript-natural-sort")); | ||
var natural_sort_1 = require("../natural-sort"); | ||
/** | ||
@@ -21,3 +16,3 @@ * This function returns import nodes with alphabetically sorted module | ||
} | ||
return javascript_natural_sort_1.default(a.local.name, b.local.name); | ||
return natural_sort_1.naturalSort(a.local.name, b.local.name); | ||
}); | ||
@@ -24,0 +19,0 @@ return node; |
@@ -18,10 +18,5 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getSortedNodes = void 0; | ||
// we do not have types for javascript-natural-sort | ||
//@ts-ignore | ||
var javascript_natural_sort_1 = __importDefault(require("javascript-natural-sort")); | ||
var natural_sort_1 = require("../natural-sort"); | ||
var lodash_1 = require("lodash"); | ||
@@ -39,3 +34,3 @@ var types_1 = require("@babel/types"); | ||
var getSortedNodes = function (nodes, options) { | ||
javascript_natural_sort_1.default.insensitive = options.importOrderCaseInsensitive; | ||
natural_sort_1.naturalSort.insensitive = options.importOrderCaseInsensitive; | ||
var importOrder = options.importOrder; | ||
@@ -64,3 +59,3 @@ var importOrderSeparation = options.importOrderSeparation, importOrderSortSpecifiers = options.importOrderSortSpecifiers; | ||
var sortedInsideGroup = groupNodes.sort(function (a, b) { | ||
return javascript_natural_sort_1.default(a.source.value, b.source.value); | ||
return natural_sort_1.naturalSort(a.source.value, b.source.value); | ||
}); | ||
@@ -67,0 +62,0 @@ // Sort the import specifiers |
{ | ||
"name": "@trivago/prettier-plugin-sort-imports", | ||
"version": "3.0.0-1", | ||
"version": "3.0.0-2", | ||
"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
30
1093
398847