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

eslint-plugin-perfectionist

Package Overview
Dependencies
Maintainers
0
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-perfectionist - npm Package Compare versions

Comparing version 4.4.0 to 4.5.0

dist/rules/sort-array-includes/does-custom-group-match.js

3

dist/alphabet.d.ts

@@ -42,4 +42,3 @@ /**

* Alphabet.generateFrom('aAbBcdCD')
* .prioritizeCase('uppercase')
* // Returns 'AaBbCDcd'
* .prioritizeCase('uppercase') // Returns 'AaBbCDcd'.
*/

@@ -46,0 +45,0 @@ prioritizeCase(casePriority: 'lowercase' | 'uppercase'): this

@@ -8,13 +8,13 @@ 'use strict'

const validateGeneratedGroupsConfiguration = require('../utils/validate-generated-groups-configuration.js')
const types = require('./sort-array-includes/types.js')
const getCustomGroupsCompareOptions = require('../utils/get-custom-groups-compare-options.js')
const doesCustomGroupMatch = require('./sort-array-includes/does-custom-group-match.js')
const getMatchingContextOptions = require('../utils/get-matching-context-options.js')
const generatePredefinedGroups = require('../utils/generate-predefined-groups.js')
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
const sortArrayIncludes_types = require('./sort-array-includes.types.js')
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const createNodeIndexMap = require('../utils/create-node-index-map.js')
const sortNodesByGroups = require('../utils/sort-nodes-by-groups.js')
const getCommentsBefore = require('../utils/get-comments-before.js')
const sortArrayIncludesUtils = require('./sort-array-includes-utils.js')
const createEslintRule = require('../utils/create-eslint-rule.js')

@@ -61,4 +61,3 @@ const getLinesBetween = require('../utils/get-lines-between.js')

customGroups: commonJsonSchemas.buildCustomGroupsArrayJsonSchema({
singleCustomGroupJsonSchema:
sortArrayIncludes_types.singleCustomGroupJsonSchema,
singleCustomGroupJsonSchema: types.singleCustomGroupJsonSchema,
}),

@@ -152,3 +151,3 @@ useConfigurationIf: commonJsonSchemas.buildUseConfigurationIfJsonSchema(),

customGroups: options.customGroups,
selectors: sortArrayIncludes_types.allSelectors,
selectors: types.allSelectors,
groups: options.groups,

@@ -188,3 +187,3 @@ modifiers: [],

if (
sortArrayIncludesUtils.customGroupMatches({
doesCustomGroupMatch.doesCustomGroupMatch({
selectors: [selector],

@@ -215,9 +214,9 @@ elementName: name,

if (
isPartitionComment.hasPartitionComment(
options.partitionByComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
node: element,
sourceCode,
}),
) ||
partitionByComment: options.partitionByComment,
}) ||
(options.partitionByNewLine &&

@@ -224,0 +223,0 @@ lastSortingNode &&

@@ -6,10 +6,11 @@ 'use strict'

const validateGeneratedGroupsConfiguration = require('../utils/validate-generated-groups-configuration.js')
const sortClasses_types = require('./sort-classes.types.js')
const types = require('./sort-classes/types.js')
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
const sortClassesUtils = require('./sort-classes-utils.js')
const getCustomGroupsCompareOptions = require('../utils/get-custom-groups-compare-options.js')
const getOverloadSignatureGroups = require('./sort-classes/get-overload-signature-groups.js')
const generatePredefinedGroups = require('../utils/generate-predefined-groups.js')
const doesCustomGroupMatch = require('./sort-classes/does-custom-group-match.js')
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const sortNodesByGroups = require('../utils/sort-nodes-by-groups.js')

@@ -87,4 +88,4 @@ const getCommentsBefore = require('../utils/get-comments-before.js')

customGroups: options.customGroups,
modifiers: sortClasses_types.allModifiers,
selectors: sortClasses_types.allSelectors,
modifiers: types.allModifiers,
selectors: types.allSelectors,
groups: options.groups,

@@ -233,5 +234,4 @@ },

}
let overloadSignatureGroups = sortClassesUtils.getOverloadSignatureGroups(
node.body,
)
let overloadSignatureGroups =
getOverloadSignatureGroups.getOverloadSignatureGroups(node.body)
let formattedNodes = node.body.reduce(

@@ -411,3 +411,3 @@ (accumulator, member) => {

if (
sortClassesUtils.customGroupMatches({
doesCustomGroupMatch.doesCustomGroupMatch({
elementValue: memberValue,

@@ -467,9 +467,9 @@ elementName: name,

)) ||
isPartitionComment.hasPartitionComment(
options.partitionByComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
node: member,
sourceCode,
}),
)
partitionByComment: options.partitionByComment,
})
) {

@@ -597,4 +597,3 @@ accumulator.push([])

customGroups: commonJsonSchemas.buildCustomGroupsArrayJsonSchema({
singleCustomGroupJsonSchema:
sortClasses_types.singleCustomGroupJsonSchema,
singleCustomGroupJsonSchema: types.singleCustomGroupJsonSchema,
}),

@@ -601,0 +600,0 @@ partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,

@@ -7,3 +7,4 @@ 'use strict'

const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const getDecoratorName = require('./sort-decorators/get-decorator-name.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const createNodeIndexMap = require('../utils/create-node-index-map.js')

@@ -14,3 +15,2 @@ const sortNodesByGroups = require('../utils/sort-nodes-by-groups.js')

const createEslintRule = require('../utils/create-eslint-rule.js')
const getDecoratorName = require('../utils/get-decorator-name.js')
const getGroupNumber = require('../utils/get-group-number.js')

@@ -183,9 +183,9 @@ const getSourceCode = require('../utils/get-source-code.js')

if (
isPartitionComment.hasPartitionComment(
options.partitionByComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
node: decorator,
sourceCode,
}),
)
partitionByComment: options.partitionByComment,
})
) {

@@ -192,0 +192,0 @@ accumulator.push([])

@@ -7,3 +7,3 @@ 'use strict'

const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const createNodeIndexMap = require('../utils/create-node-index-map.js')

@@ -113,9 +113,9 @@ const getCommentsBefore = require('../utils/get-comments-before.js')

if (
isPartitionComment.hasPartitionComment(
options.partitionByComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
node: member,
sourceCode,
}),
) ||
partitionByComment: options.partitionByComment,
}) ||
(options.partitionByNewLine &&

@@ -143,3 +143,3 @@ lastSortingNode &&

let compareOptions = {
// Get the enum value rather than the name if needed
// Get the enum value rather than the name if needed.
nodeValueGetter:

@@ -146,0 +146,0 @@ options.sortByValue || (isNumericEnum && options.forceNumericSort)

@@ -6,4 +6,4 @@ 'use strict'

const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const createNodeIndexMap = require('../utils/create-node-index-map.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const getCommentsBefore = require('../utils/get-comments-before.js')

@@ -62,9 +62,9 @@ const createEslintRule = require('../utils/create-eslint-rule.js')

(partitionComment &&
isPartitionComment.hasPartitionComment(
partitionComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
sourceCode,
node,
}),
)) ||
partitionByComment: options.partitionByComment,
})) ||
(options.partitionByNewLine &&

@@ -71,0 +71,0 @@ lastNode &&

@@ -6,10 +6,10 @@ 'use strict'

const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
const readClosestTsConfigByPath = require('./sort-imports/read-closest-ts-config-by-path.js')
const validateGroupsConfiguration = require('../utils/validate-groups-configuration.js')
const readClosestTsConfigByPath = require('../utils/read-closest-ts-config-by-path.js')
const getOptionsWithCleanGroups = require('../utils/get-options-with-clean-groups.js')
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
const getTypescriptImport = require('./sort-imports/get-typescript-import.js')
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const getTypescriptImport = require('../utils/get-typescript-import.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const createNodeIndexMap = require('../utils/create-node-index-map.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const sortNodesByGroups = require('../utils/sort-nodes-by-groups.js')

@@ -148,3 +148,5 @@ const getCommentsBefore = require('../utils/get-comments-before.js')

let [cleanedValue] = value.split('?')
return styleExtensions.some(extension => cleanedValue.endsWith(extension))
return styleExtensions.some(extension =>
cleanedValue == null ? void 0 : cleanedValue.endsWith(extension),
)
}

@@ -199,6 +201,8 @@ let flatGroups = new Set(options.groups.flat())

let builtinPrefixOnlyModules = ['sea', 'sqlite', 'test']
let valueToCheck = value.startsWith('node:')
? value.split('node:')[1]
: value
return (
node_module.builtinModules.includes(
value.startsWith('node:') ? value.split('node:')[1] : value,
) ||
(!!valueToCheck &&
node_module.builtinModules.includes(valueToCheck)) ||
builtinPrefixOnlyModules.some(

@@ -353,9 +357,9 @@ module2 => `node:${module2}` === value,

if (
isPartitionComment.hasPartitionComment(
options.partitionByComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
node: sortingNode.node,
sourceCode,
}),
) ||
partitionByComment: options.partitionByComment,
}) ||
(options.partitionByNewLine &&

@@ -417,2 +421,6 @@ lastSortingNode &&

...getNewlinesErrors.getNewlinesErrors({
options: {
...options,
customGroups: [],
},
missedSpacingError: 'missedSpacingBetweenImports',

@@ -423,3 +431,2 @@ extraSpacingError: 'extraSpacingBetweenImports',

sourceCode,
options,
right,

@@ -440,6 +447,9 @@ left,

...makeNewlinesFixes.makeNewlinesFixes({
options: {
...options,
customGroups: [],
},
sortedNodes: sortedNodesExcludingEslintDisabled,
nodes: nodeList,
sourceCode,
options,
fixer,

@@ -446,0 +456,0 @@ }),

@@ -8,4 +8,4 @@ 'use strict'

const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const createNodeIndexMap = require('../utils/create-node-index-map.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const sortNodesByGroups = require('../utils/sort-nodes-by-groups.js')

@@ -148,5 +148,4 @@ const getCommentsBefore = require('../utils/get-comments-before.js')

if (
isPartitionComment.hasPartitionComment(
options.partitionByComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
tokenValueToIgnoreBefore: '&',

@@ -156,3 +155,4 @@ node: type,

}),
) ||
partitionByComment: options.partitionByComment,
}) ||
(options.partitionByNewLine &&

@@ -159,0 +159,0 @@ lastSortingNode &&

@@ -6,4 +6,4 @@ 'use strict'

const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const createNodeIndexMap = require('../utils/create-node-index-map.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const getCommentsBefore = require('../utils/get-comments-before.js')

@@ -99,9 +99,9 @@ const createEslintRule = require('../utils/create-eslint-rule.js')

if (
isPartitionComment.hasPartitionComment(
options.partitionByComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
node: element,
sourceCode,
}),
) ||
partitionByComment: options.partitionByComment,
}) ||
(options.partitionByNewLine &&

@@ -108,0 +108,0 @@ lastSortingNode &&

@@ -7,10 +7,11 @@ 'use strict'

const validateGeneratedGroupsConfiguration = require('../utils/validate-generated-groups-configuration.js')
const sortModules_types = require('./sort-modules.types.js')
const types = require('./sort-modules/types.js')
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
const getCustomGroupsCompareOptions = require('../utils/get-custom-groups-compare-options.js')
const generatePredefinedGroups = require('../utils/generate-predefined-groups.js')
const doesCustomGroupMatch = require('./sort-modules/does-custom-group-match.js')
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const createNodeIndexMap = require('../utils/create-node-index-map.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const sortNodesByGroups = require('../utils/sort-nodes-by-groups.js')

@@ -25,3 +26,2 @@ const getNewlinesErrors = require('../utils/get-newlines-errors.js')

const getEnumMembers = require('../utils/get-enum-members.js')
const sortModulesUtils = require('./sort-modules-utils.js')
const getSourceCode = require('../utils/get-source-code.js')

@@ -74,4 +74,3 @@ const toSingleLine = require('../utils/to-single-line.js')

customGroups: commonJsonSchemas.buildCustomGroupsArrayJsonSchema({
singleCustomGroupJsonSchema:
sortModules_types.singleCustomGroupJsonSchema,
singleCustomGroupJsonSchema: types.singleCustomGroupJsonSchema,
}),

@@ -121,4 +120,4 @@ partitionByNewLine: commonJsonSchemas.partitionByNewLineJsonSchema,

customGroups: options.customGroups,
modifiers: sortModules_types.allModifiers,
selectors: sortModules_types.allSelectors,
modifiers: types.allModifiers,
selectors: types.allSelectors,
groups: options.groups,

@@ -279,3 +278,3 @@ })

if (
sortModulesUtils.customGroupMatches({
doesCustomGroupMatch.doesCustomGroupMatch({
selectors: [selector],

@@ -317,9 +316,9 @@ elementName: name,

)) ||
isPartitionComment.hasPartitionComment(
options.partitionByComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
sourceCode,
node,
}),
)
partitionByComment: options.partitionByComment,
})
) {

@@ -326,0 +325,0 @@ formattedNodes.push([])

@@ -6,4 +6,4 @@ 'use strict'

const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const createNodeIndexMap = require('../utils/create-node-index-map.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const getCommentsBefore = require('../utils/get-comments-before.js')

@@ -72,9 +72,9 @@ const createEslintRule = require('../utils/create-eslint-rule.js')

if (
isPartitionComment.hasPartitionComment(
options.partitionByComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
node: specifier,
sourceCode,
}),
) ||
partitionByComment: options.partitionByComment,
}) ||
(options.partitionByNewLine &&

@@ -81,0 +81,0 @@ lastSortingNode &&

@@ -6,4 +6,4 @@ 'use strict'

const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const createNodeIndexMap = require('../utils/create-node-index-map.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const getCommentsBefore = require('../utils/get-comments-before.js')

@@ -81,9 +81,9 @@ const createEslintRule = require('../utils/create-eslint-rule.js')

if (
isPartitionComment.hasPartitionComment(
options.partitionByComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
node: specifier,
sourceCode,
}),
) ||
partitionByComment: options.partitionByComment,
}) ||
(options.partitionByNewLine &&

@@ -90,0 +90,0 @@ lastSortingNode &&

@@ -8,11 +8,13 @@ 'use strict'

const validateNewlinesAndPartitionConfiguration = require('../utils/validate-newlines-and-partition-configuration.js')
const types = require('./sort-object-types/types.js')
const validateGeneratedGroupsConfiguration = require('../utils/validate-generated-groups-configuration.js')
const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
const getCustomGroupsCompareOptions = require('../utils/get-custom-groups-compare-options.js')
const doesCustomGroupMatch = require('./sort-object-types/does-custom-group-match.js')
const getMatchingContextOptions = require('../utils/get-matching-context-options.js')
const generatePredefinedGroups = require('../utils/generate-predefined-groups.js')
const getEslintDisabledLines = require('../utils/get-eslint-disabled-lines.js')
const sortObjectTypes_types = require('./sort-object-types.types.js')
const isMemberOptional = require('./sort-object-types/is-member-optional.js')
const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const isNodeFunctionType = require('../utils/is-node-function-type.js')

@@ -25,4 +27,2 @@ const createNodeIndexMap = require('../utils/create-node-index-map.js')

const createEslintRule = require('../utils/create-eslint-rule.js')
const isMemberOptional = require('../utils/is-member-optional.js')
const sortObjectTypesUtils = require('./sort-object-types-utils.js')
const getLinesBetween = require('../utils/get-lines-between.js')

@@ -84,4 +84,3 @@ const getGroupNumber = require('../utils/get-group-number.js')

commonJsonSchemas.buildCustomGroupsArrayJsonSchema({
singleCustomGroupJsonSchema:
sortObjectTypes_types.singleCustomGroupJsonSchema,
singleCustomGroupJsonSchema: types.singleCustomGroupJsonSchema,
}),

@@ -203,4 +202,4 @@ ],

customGroups: options.customGroups,
selectors: sortObjectTypes_types.allSelectors,
modifiers: sortObjectTypes_types.allModifiers,
selectors: types.allSelectors,
modifiers: types.allModifiers,
groups: options.groups,

@@ -272,3 +271,3 @@ })

if (
sortObjectTypesUtils.customGroupMatches({
doesCustomGroupMatch.doesCustomGroupMatch({
elementName: name,

@@ -307,9 +306,9 @@ customGroup,

(options.partitionByComment &&
isPartitionComment.hasPartitionComment(
options.partitionByComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
node: typeElement,
sourceCode,
}),
)) ||
partitionByComment: options.partitionByComment,
})) ||
(options.partitionByNewLine &&

@@ -316,0 +315,0 @@ lastSortingNode &&

@@ -7,3 +7,3 @@ 'use strict'

const validateCustomSortConfiguration = require('../utils/validate-custom-sort-configuration.js')
const getFirstNodeParentWithType = require('../utils/get-first-node-parent-with-type.js')
const getFirstNodeParentWithType = require('./sort-objects/get-first-node-parent-with-type.js')
const validateGroupsConfiguration = require('../utils/validate-groups-configuration.js')

@@ -13,4 +13,4 @@ const getMatchingContextOptions = require('../utils/get-matching-context-options.js')

const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const createNodeIndexMap = require('../utils/create-node-index-map.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const sortNodesByGroups = require('../utils/sort-nodes-by-groups.js')

@@ -282,9 +282,9 @@ const getCommentsBefore = require('../utils/get-comments-before.js')

)) ||
isPartitionComment.hasPartitionComment(
options.partitionByComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
node: property,
sourceCode,
}),
)
partitionByComment: options.partitionByComment,
})
) {

@@ -291,0 +291,0 @@ accumulator.push([])

@@ -8,4 +8,4 @@ 'use strict'

const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const createNodeIndexMap = require('../utils/create-node-index-map.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const sortNodesByGroups = require('../utils/sort-nodes-by-groups.js')

@@ -148,5 +148,4 @@ const getCommentsBefore = require('../utils/get-comments-before.js')

if (
isPartitionComment.hasPartitionComment(
options.partitionByComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
tokenValueToIgnoreBefore: '|',

@@ -156,3 +155,4 @@ node: type,

}),
) ||
partitionByComment: options.partitionByComment,
}) ||
(options.partitionByNewLine &&

@@ -159,0 +159,0 @@ lastSortingNode &&

@@ -7,4 +7,4 @@ 'use strict'

const isNodeEslintDisabled = require('../utils/is-node-eslint-disabled.js')
const hasPartitionComment = require('../utils/has-partition-comment.js')
const createNodeIndexMap = require('../utils/create-node-index-map.js')
const isPartitionComment = require('../utils/is-partition-comment.js')
const getCommentsBefore = require('../utils/get-comments-before.js')

@@ -151,9 +151,9 @@ const createEslintRule = require('../utils/create-eslint-rule.js')

if (
isPartitionComment.hasPartitionComment(
options.partitionByComment,
getCommentsBefore.getCommentsBefore({
hasPartitionComment.hasPartitionComment({
comments: getCommentsBefore.getCommentsBefore({
node: declaration,
sourceCode,
}),
) ||
partitionByComment: options.partitionByComment,
}) ||
(options.partitionByNewLine &&

@@ -160,0 +160,0 @@ lastSortingNode &&

@@ -97,4 +97,3 @@ 'use strict'

* Alphabet.generateFrom('aAbBcdCD')
* .prioritizeCase('uppercase')
* // Returns 'AaBbCDcd'
* .prioritizeCase('uppercase') // Returns 'AaBbCDcd'.
*/

@@ -101,0 +100,0 @@ prioritizeCase(casePriority) {

@@ -82,16 +82,30 @@ 'use strict'

}
let allowedPartitionByCommentJsonSchemas = [
{
items: {
type: 'string',
},
type: 'array',
},
{
type: 'boolean',
},
{
type: 'string',
},
]
let partitionByCommentJsonSchema = {
anyOf: [
oneOf: [
...allowedPartitionByCommentJsonSchemas,
{
items: {
type: 'string',
properties: {
block: {
oneOf: allowedPartitionByCommentJsonSchemas,
},
line: {
oneOf: allowedPartitionByCommentJsonSchemas,
},
},
type: 'array',
type: 'object',
},
{
type: 'boolean',
},
{
type: 'string',
},
],

@@ -105,4 +119,3 @@ }

let newlinesBetweenJsonSchema = {
description:
'Specifies how new lines should be handled between modules members groups.',
description: 'Specifies how new lines should be handled between groups.',
enum: ['ignore', 'always', 'never'],

@@ -139,2 +152,10 @@ type: 'string',

}
let customGroupNewlinesInsideJsonSchema = {
newlinesInside: {
description:
'Specifies how new lines should be handled between members of the custom group.',
enum: ['always', 'never'],
type: 'string',
},
}
let buildCustomGroupsArrayJsonSchema = ({ singleCustomGroupJsonSchema }) => ({

@@ -147,2 +168,3 @@ items: {

...customGroupSortJsonSchema,
...customGroupNewlinesInsideJsonSchema,
anyOf: {

@@ -168,2 +190,3 @@ items: {

...customGroupSortJsonSchema,
...customGroupNewlinesInsideJsonSchema,
...singleCustomGroupJsonSchema,

@@ -170,0 +193,0 @@ },

@@ -68,3 +68,4 @@ 'use strict'

let bValue = formatString(nodeValueGetter(bNode))
for (let i = 0; i < aValue.length; i++) {
let minLength = Math.min(aValue.length, bValue.length)
for (let i = 0; i < minLength; i++) {
let aCharacter = aValue[i]

@@ -82,3 +83,8 @@ let bCharacter = bValue[i]

}
return 0
if (aValue.length === bValue.length) {
return 0
}
return convertBooleanToSign.convertBooleanToSign(
aValue.length - bValue.length > 0,
)
}

@@ -85,0 +91,0 @@ }

@@ -31,6 +31,8 @@ 'use strict'

let disabledRulesMatch = trimmedCommentValue.match(regexp)
if (!disabledRulesMatch) {
let disableRulesMatchValue =
disabledRulesMatch == null ? void 0 : disabledRulesMatch[1]
if (!disableRulesMatchValue) {
return null
}
return disabledRulesMatch[1]
return disableRulesMatchValue
.split(',')

@@ -37,0 +39,0 @@ .map(rule => rule.trim())

'use strict'
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
const getNewlinesBetweenOption = require('./get-newlines-between-option.js')
const getLinesBetween = require('./get-lines-between.js')

@@ -14,3 +15,10 @@ let getNewlinesErrors = ({

}) => {
let errors = []
let newlinesBetween = getNewlinesBetweenOption.getNewlinesBetweenOption({
nextSortingNode: right,
sortingNode: left,
options,
})
if (leftNum > rightNum) {
return []
}
let numberOfEmptyLinesBetween = getLinesBetween.getLinesBetween(

@@ -21,17 +29,16 @@ sourceCode,

)
if (options.newlinesBetween === 'never' && numberOfEmptyLinesBetween > 0) {
errors.push(extraSpacingError)
switch (newlinesBetween) {
case 'ignore':
return []
case 'never':
return numberOfEmptyLinesBetween > 0 ? [extraSpacingError] : []
case 'always':
if (numberOfEmptyLinesBetween === 0) {
return [missedSpacingError]
} else if (numberOfEmptyLinesBetween > 1) {
return [extraSpacingError]
}
}
if (options.newlinesBetween === 'always') {
if (leftNum < rightNum && numberOfEmptyLinesBetween === 0) {
errors.push(missedSpacingError)
} else if (
numberOfEmptyLinesBetween > 1 ||
(leftNum === rightNum && numberOfEmptyLinesBetween > 0)
) {
errors.push(extraSpacingError)
}
}
return errors
return []
}
exports.getNewlinesErrors = getNewlinesErrors

@@ -39,6 +39,7 @@ 'use strict'

if (
isPartitionComment.isPartitionComment(
(options == null ? void 0 : options.partitionByComment) ?? false,
comment.value,
) ||
isPartitionComment.isPartitionComment({
partitionByComment:
(options == null ? void 0 : options.partitionByComment) ?? false,
comment,
}) ||
(eslintDisabledRules == null

@@ -45,0 +46,0 @@ ? void 0

@@ -12,3 +12,3 @@ 'use strict'

let getCleanedNestedGroups = nestedGroup =>
nestedGroup.length === 1 ? nestedGroup[0] : nestedGroup
nestedGroup.length === 1 && nestedGroup[0] ? nestedGroup[0] : nestedGroup
exports.getOptionsWithCleanGroups = getOptionsWithCleanGroups
'use strict'
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
let getSettings = (settings = {}) => {
if (!settings.perfectionist) {
if (!settings['perfectionist']) {
return {}

@@ -21,3 +21,3 @@ }

}
let perfectionistSettings = settings.perfectionist
let perfectionistSettings = settings['perfectionist']
let invalidOptions = getInvalidOptions(perfectionistSettings)

@@ -29,4 +29,4 @@ if (invalidOptions.length) {

}
return settings.perfectionist
return settings['perfectionist']
}
exports.getSettings = getSettings
'use strict'
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
const types = require('@typescript-eslint/types')
const getEslintDisabledRules = require('./get-eslint-disabled-rules.js')
const matches = require('./matches.js')
let isPartitionComment = (partitionComment, comment) => {
let isPartitionComment = ({ partitionByComment, comment }) => {
if (
getEslintDisabledRules.getEslintDisabledRules(comment) ||
!partitionComment
getEslintDisabledRules.getEslintDisabledRules(comment.value) ||
!partitionByComment
) {
return false
}
let trimmedComment = comment.value.trim()
if (
Array.isArray(partitionByComment) ||
typeof partitionByComment === 'boolean' ||
typeof partitionByComment === 'string'
) {
return isTrimmedCommentPartitionComment({
partitionByComment,
trimmedComment,
})
}
let relevantPartitionByComment =
comment.type === types.AST_TOKEN_TYPES.Block
? partitionByComment.block
: partitionByComment.line
return (
(Array.isArray(partitionComment) &&
partitionComment.some(pattern =>
matches.matches(comment.trim(), pattern),
)) ||
(typeof partitionComment === 'string' &&
matches.matches(comment.trim(), partitionComment)) ||
partitionComment === true
// eslint-disable-next-line no-undefined
relevantPartitionByComment !== void 0 &&
isTrimmedCommentPartitionComment({
partitionByComment: relevantPartitionByComment,
trimmedComment,
})
)
}
let hasPartitionComment = (partitionComment, comments) =>
comments.some(comment => isPartitionComment(partitionComment, comment.value))
exports.hasPartitionComment = hasPartitionComment
let isTrimmedCommentPartitionComment = ({
partitionByComment,
trimmedComment,
}) => {
if (typeof partitionByComment === 'boolean') {
return partitionByComment
}
if (typeof partitionByComment === 'string') {
return matches.matches(trimmedComment.trim(), partitionByComment)
}
return partitionByComment.some(pattern =>
matches.matches(trimmedComment.trim(), pattern),
)
}
exports.isPartitionComment = isPartitionComment
'use strict'
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
const getNewlinesBetweenOption = require('./get-newlines-between-option.js')
const getLinesBetween = require('./get-lines-between.js')
const getGroupNumber = require('./get-group-number.js')
const getNodeRange = require('./get-node-range.js')

@@ -14,18 +14,17 @@ let makeNewlinesFixes = ({

let fixes = []
for (let max = sortedNodes.length, i = 0; i < max; i++) {
let sortingNode = sortedNodes.at(i)
let nextSortingNode = sortedNodes.at(i + 1)
if (options.newlinesBetween === 'ignore' || !nextSortingNode) {
for (let i = 0; i < sortedNodes.length - 1; i++) {
let sortingNode = nodes.at(i)
let nextSortingNode = nodes.at(i + 1)
let sortedSortingNode = sortedNodes.at(i)
let nextSortedSortingNode = sortedNodes.at(i + 1)
let newlinesBetween = getNewlinesBetweenOption.getNewlinesBetweenOption({
nextSortingNode: nextSortedSortingNode,
sortingNode: sortedSortingNode,
options,
})
if (newlinesBetween === 'ignore') {
continue
}
let nodeGroupNumber = getGroupNumber.getGroupNumber(
options.groups,
sortingNode,
)
let nextNodeGroupNumber = getGroupNumber.getGroupNumber(
options.groups,
nextSortingNode,
)
let currentNodeRange = getNodeRange.getNodeRange({
node: nodes.at(i).node,
node: sortingNode.node,
sourceCode,

@@ -35,3 +34,3 @@ })

.getNodeRange({
node: nodes.at(i + 1).node,
node: nextSortingNode.node,
sourceCode,

@@ -47,19 +46,10 @@ })

sourceCode,
nodes.at(i),
nodes.at(i + 1),
sortingNode,
nextSortingNode,
)
let rangeReplacement
if (
(options.newlinesBetween === 'always' &&
nodeGroupNumber === nextNodeGroupNumber &&
linesBetweenMembers !== 0) ||
(options.newlinesBetween === 'never' && linesBetweenMembers > 0)
) {
if (newlinesBetween === 'never' && linesBetweenMembers !== 0) {
rangeReplacement = getStringWithoutInvalidNewlines(textBetweenNodes)
}
if (
options.newlinesBetween === 'always' &&
nodeGroupNumber !== nextNodeGroupNumber &&
linesBetweenMembers !== 1
) {
if (newlinesBetween === 'always' && linesBetweenMembers !== 1) {
rangeReplacement = addNewlineBeforeFirstNewline(

@@ -72,3 +62,3 @@ linesBetweenMembers > 1

linesBetweenMembers === 0 &&
nodes.at(i).node.loc.end.line === nodes.at(i + 1).node.loc.start.line
sortingNode.node.loc.end.line === nextSortingNode.node.loc.start.line
if (isOnSameLine) {

@@ -75,0 +65,0 @@ rangeReplacement = addNewlineBeforeFirstNewline(rangeReplacement)

@@ -36,12 +36,8 @@ 'use strict'

: options
let nodesToPush = nodesByNonIgnoredGroupNumber[Number(groupNumber)]
if (!compareOptions) {
sortedNodes.push(...nodesByNonIgnoredGroupNumber[Number(groupNumber)])
sortedNodes.push(...nodesToPush)
continue
}
sortedNodes.push(
...sortNodes.sortNodes(
nodesByNonIgnoredGroupNumber[Number(groupNumber)],
compareOptions,
),
)
sortedNodes.push(...sortNodes.sortNodes(nodesToPush, compareOptions))
}

@@ -48,0 +44,0 @@ for (let ignoredIndex of ignoredNodeIndices) {

{
"name": "eslint-plugin-perfectionist",
"version": "4.4.0",
"version": "4.5.0",
"description": "ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.",

@@ -30,4 +30,4 @@ "keywords": [

"dependencies": {
"@typescript-eslint/types": "^8.18.1",
"@typescript-eslint/utils": "^8.18.1",
"@typescript-eslint/types": "^8.19.0",
"@typescript-eslint/utils": "^8.19.0",
"natural-orderby": "^5.0.0"

@@ -34,0 +34,0 @@ },

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