eslint-plugin-perfectionist
Advanced tools
Comparing version 4.0.2 to 4.0.3
@@ -9,2 +9,3 @@ 'use strict' | ||
const getCommentsBefore = require('../utils/get-comments-before.js') | ||
const getNodeDecorators = require('../utils/get-node-decorators.js') | ||
const createEslintRule = require('../utils/create-eslint-rule.js') | ||
@@ -129,15 +130,31 @@ const getDecoratorName = require('../utils/get-decorator-name.js') | ||
options.sortOnProperties | ||
? sortDecorators$1(context, options, propertyDefinition.decorators) | ||
? sortDecorators$1( | ||
context, | ||
options, | ||
getNodeDecorators.getNodeDecorators(propertyDefinition), | ||
) | ||
: null, | ||
AccessorProperty: accessorDefinition => | ||
options.sortOnAccessors | ||
? sortDecorators$1(context, options, accessorDefinition.decorators) | ||
? sortDecorators$1( | ||
context, | ||
options, | ||
getNodeDecorators.getNodeDecorators(accessorDefinition), | ||
) | ||
: null, | ||
MethodDefinition: methodDefinition => | ||
options.sortOnMethods | ||
? sortDecorators$1(context, options, methodDefinition.decorators) | ||
? sortDecorators$1( | ||
context, | ||
options, | ||
getNodeDecorators.getNodeDecorators(methodDefinition), | ||
) | ||
: null, | ||
ClassDeclaration: Declaration => | ||
ClassDeclaration: declaration => | ||
options.sortOnClasses | ||
? sortDecorators$1(context, options, Declaration.decorators) | ||
? sortDecorators$1( | ||
context, | ||
options, | ||
getNodeDecorators.getNodeDecorators(declaration), | ||
) | ||
: null, | ||
@@ -144,0 +161,0 @@ } |
@@ -10,2 +10,3 @@ 'use strict' | ||
const getLinesBetween = require('../utils/get-lines-between.js') | ||
const getEnumMembers = require('../utils/get-enum-members.js') | ||
const getSourceCode = require('../utils/get-source-code.js') | ||
@@ -34,3 +35,3 @@ const toSingleLine = require('../utils/to-single-line.js') | ||
TSEnumDeclaration: node => { | ||
let members = node.body.members ?? node.members ?? [] | ||
let members = getEnumMembers.getEnumMembers(node) | ||
if ( | ||
@@ -37,0 +38,0 @@ !isSortable.isSortable(members) || |
@@ -81,3 +81,3 @@ 'use strict' | ||
let sortHeritageClauses$1 = (context, options, heritageClauses) => { | ||
if (!isSortable.isSortable(heritageClauses)) { | ||
if (!heritageClauses || !isSortable.isSortable(heritageClauses)) { | ||
return | ||
@@ -84,0 +84,0 @@ } |
@@ -17,5 +17,7 @@ 'use strict' | ||
const getCommentsBefore = require('../utils/get-comments-before.js') | ||
const getNodeDecorators = require('../utils/get-node-decorators.js') | ||
const createEslintRule = require('../utils/create-eslint-rule.js') | ||
const getLinesBetween = require('../utils/get-lines-between.js') | ||
const getGroupNumber = require('../utils/get-group-number.js') | ||
const getEnumMembers = require('../utils/get-enum-members.js') | ||
const getSourceCode = require('../utils/get-source-code.js') | ||
@@ -243,3 +245,5 @@ const toSingleLine = require('../utils/to-single-line.js') | ||
...dependencies, | ||
...extractDependencies(nodeToParse.body), | ||
...getEnumMembers | ||
.getEnumMembers(nodeToParse) | ||
.flatMap(extractDependencies), | ||
] | ||
@@ -250,6 +254,7 @@ break | ||
name = (_b2 = nodeToParse.id) == null ? void 0 : _b2.name | ||
if (nodeToParse.decorators.length > 0) { | ||
let nodeDecorators = getNodeDecorators.getNodeDecorators(nodeToParse) | ||
if (nodeDecorators.length > 0) { | ||
modifiers.push('decorated') | ||
} | ||
for (let decorator of nodeToParse.decorators) { | ||
for (let decorator of nodeDecorators) { | ||
if (decorator.expression.type === 'Identifier') { | ||
@@ -499,5 +504,2 @@ decorators.push(decorator.expression.name) | ||
} | ||
if ('members' in nodeValue) { | ||
traverseNode(nodeValue.members) | ||
} | ||
if ('initializer' in nodeValue && nodeValue.initializer) { | ||
@@ -504,0 +506,0 @@ checkNode(nodeValue.initializer) |
{ | ||
"name": "eslint-plugin-perfectionist", | ||
"version": "4.0.2", | ||
"version": "4.0.3", | ||
"description": "ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
271281
70
7460