eslint-plugin-perfectionist 2.10.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,6 +25,9 @@ const sortClasses = createEslintRule.createEslintRule({
25
25
  {
26
26
  type: "object",
27
27
  properties: {
28
+ "custom-groups": {
29
+ type: "object"
30
+ },
28
31
  type: {
29
32
  enum: [
30
33
  index.SortType.alphabetical,
@@ -68,12 +71,15 @@ const sortClasses = createEslintRule.createEslintRule({
68
71
  type: index.SortType.alphabetical,
69
72
  order: index.SortOrder.asc,
70
73
  "ignore-case": false,
71
- groups: ["property", "constructor", "method", "unknown"]
74
+ groups: ["property", "constructor", "method", "unknown"],
75
+ "custom-groups": {}
72
76
  });
73
77
  let nodes = node.body.map((member) => {
74
78
  var _a;
75
79
  let name;
76
- let { getGroup, defineGroup } = useGroups.useGroups(options.groups);
80
+ let { getGroup, defineGroup, setCustomGroups } = useGroups.useGroups(
81
+ options.groups
82
+ );
77
83
  if (member.type === "StaticBlock") {
78
84
  name = "static";
79
85
  } else if (member.type === "TSIndexSignature") {
@@ -145,6 +151,9 @@ const sortClasses = createEslintRule.createEslintRule({
145
151
  }
146
152
  defineGroup("property");
147
153
  }
154
+ setCustomGroups(options["custom-groups"], name, {
155
+ override: true
156
+ });
148
157
  return {
149
158
  size: rangeToDiff.rangeToDiff(member.range),
150
159
  group: getGroup(),
@@ -23,6 +23,9 @@ const sortClasses = createEslintRule({
23
23
  {
24
24
  type: "object",
25
25
  properties: {
26
+ "custom-groups": {
27
+ type: "object"
28
+ },
26
29
  type: {
27
30
  enum: [
28
31
  SortType.alphabetical,
@@ -66,12 +69,15 @@ const sortClasses = createEslintRule({
66
69
  type: SortType.alphabetical,
67
70
  order: SortOrder.asc,
68
71
  "ignore-case": false,
69
- groups: ["property", "constructor", "method", "unknown"]
72
+ groups: ["property", "constructor", "method", "unknown"],
73
+ "custom-groups": {}
70
74
  });
71
75
  let nodes = node.body.map((member) => {
72
76
  var _a;
73
77
  let name;
74
- let { getGroup, defineGroup } = useGroups(options.groups);
78
+ let { getGroup, defineGroup, setCustomGroups } = useGroups(
79
+ options.groups
80
+ );
75
81
  if (member.type === "StaticBlock") {
76
82
  name = "static";
77
83
  } else if (member.type === "TSIndexSignature") {
@@ -143,6 +149,9 @@ const sortClasses = createEslintRule({
143
149
  }
144
150
  defineGroup("property");
145
151
  }
152
+ setCustomGroups(options["custom-groups"], name, {
153
+ override: true
154
+ });
146
155
  return {
147
156
  size: rangeToDiff(member.range),
148
157
  group: getGroup(),
@@ -3,12 +3,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const minimatch = require("minimatch");
4
4
  let useGroups = (groups) => {
5
5
  let group;
6
- let defineGroup = (value) => {
7
- if (!group && groups.flat().includes(value)) {
6
+ let defineGroup = (value, override = false) => {
7
+ if ((!group || override) && groups.flat().includes(value)) {
8
8
  group = value;
9
9
  }
10
10
  };
11
- let setCustomGroups = (customGroups, name) => {
11
+ let setCustomGroups = (customGroups, name, params = {}) => {
12
12
  if (customGroups) {
13
13
  for (let [key, pattern] of Object.entries(customGroups)) {
14
14
  if (Array.isArray(pattern) && pattern.some(
@@ -16,12 +16,12 @@ let useGroups = (groups) => {
16
16
  nocomment: true
17
17
  })
18
18
  )) {
19
- defineGroup(key);
19
+ defineGroup(key, params.override);
20
20
  }
21
21
  if (typeof pattern === "string" && minimatch.minimatch(name, pattern, {
22
22
  nocomment: true
23
23
  })) {
24
- defineGroup(key);
24
+ defineGroup(key, params.override);
25
25
  }
26
26
  }
27
27
  }
@@ -1,12 +1,12 @@
1
1
  import { minimatch } from "minimatch";
2
2
  let useGroups = (groups) => {
3
3
  let group;
4
- let defineGroup = (value) => {
5
- if (!group && groups.flat().includes(value)) {
4
+ let defineGroup = (value, override = false) => {
5
+ if ((!group || override) && groups.flat().includes(value)) {
6
6
  group = value;
7
7
  }
8
8
  };
9
- let setCustomGroups = (customGroups, name) => {
9
+ let setCustomGroups = (customGroups, name, params = {}) => {
10
10
  if (customGroups) {
11
11
  for (let [key, pattern] of Object.entries(customGroups)) {
12
12
  if (Array.isArray(pattern) && pattern.some(
@@ -14,12 +14,12 @@ let useGroups = (groups) => {
14
14
  nocomment: true
15
15
  })
16
16
  )) {
17
- defineGroup(key);
17
+ defineGroup(key, params.override);
18
18
  }
19
19
  if (typeof pattern === "string" && minimatch(name, pattern, {
20
20
  nocomment: true
21
21
  })) {
22
- defineGroup(key);
22
+ defineGroup(key, params.override);
23
23
  }
24
24
  }
25
25
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-plugin-perfectionist",
3
3
  "description": "ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.",
4
- "version": "2.10.0",
4
+ "version": "2.11.0",
5
5
  "homepage": "https://eslint-plugin-perfectionist.azat.io",
6
6
  "repository": "https://github.com/azat-io/eslint-plugin-perfectionist",
7
7
  "author": "Azat S. <to@azat.io>",
@@ -52,10 +52,10 @@
52
52
  }
53
53
  },
54
54
  "peerDependencies": {
55
- "astro-eslint-parser": "^0.16.0",
55
+ "astro-eslint-parser": "^1.0.2",
56
56
  "eslint": ">=8.0.0",
57
57
  "svelte": ">=3.0.0",
58
- "svelte-eslint-parser": "^0.33.0",
58
+ "svelte-eslint-parser": "^0.37.0",
59
59
  "vue-eslint-parser": ">=9.0.0"
60
60
  },
61
61
  "dependencies": {