Skip to content

Commit

Permalink
feat: rename sort-object-keys rule to sort-objects
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io committed Jun 3, 2023
1 parent 57af3a2 commit 3340a9f
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 56 deletions.
4 changes: 2 additions & 2 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ export default defineConfig({
link: '/rules/sort-named-imports',
},
{
text: 'sort-object-keys',
link: '/rules/sort-object-keys',
text: 'sort-objects',
link: '/rules/sort-objects',
},
{
text: 'sort-union-types',
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ title: Rules
| [sort-map-elements](/rules/sort-map-elements) | enforce sorted Map elements | 🔧 |
| [sort-named-exports](/rules/sort-named-exports) | enforce sorted named exports | 🔧 |
| [sort-named-imports](/rules/sort-named-imports) | enforce sorted named imports | 🔧 |
| [sort-object-keys](/rules/sort-object-keys) | enforce sorted object keys | 🔧 |
| [sort-objects](/rules/sort-objects) | enforce sorted objects | 🔧 |
| [sort-union-types](/rules/sort-union-types) | enforce sorted union types | 🔧 |

<!-- end auto-generated rules list -->
14 changes: 7 additions & 7 deletions docs/rules/sort-object-keys.md → docs/rules/sort-objects.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: sort-object-keys
title: sort-objects
---

# sort-object-keys
# sort-objects

💼 This rule is enabled in the following [configs](/configs/): `recommended-alphabetical`, `recommended-line-length`, `recommended-natural`.

Expand All @@ -12,7 +12,7 @@ title: sort-object-keys

## 📖 Rule Details

Enforce sorted object keys.
Enforce sorted objects.

By adhering to the rule, developers can ensure that object keys are consistently sorted, leading to cleaner and more maintainable code. It promotes a standardized key ordering across objects, making it easier for developers to navigate and understand the structure of objects within the codebase.

Expand Down Expand Up @@ -103,7 +103,7 @@ Only affects alphabetical and natural sorting. When `true` the rule ignores the
// .eslintrc
{
"rules": {
"perfectionist/sort-object-keys": [
"perfectionist/sort-objects": [
"error",
{
"type": "line-length",
Expand All @@ -126,7 +126,7 @@ export default [
perfectionist,
},
rules: {
'perfectionist/sort-object-keys': [
'perfectionist/sort-objects': [
'error',
{
type: 'line-length',
Expand All @@ -144,5 +144,5 @@ This rule was introduced in v0.6.0.

## 📚 Resources

- [Rule source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/rules/sort-object-keys.ts)
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/sort-object-keys.test.ts)
- [Rule source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/rules/sort-objects.ts)
- [Test source](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/test/sort-objects.test.ts)
6 changes: 3 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import sortJsxProps, { RULE_NAME as sortJsxPropsName } from './rules/sort-jsx-pr
import sortMapElements, { RULE_NAME as sortMapElementsName } from './rules/sort-map-elements'
import sortNamedExports, { RULE_NAME as sortNamedExportsName } from './rules/sort-named-exports'
import sortNamedImports, { RULE_NAME as sortNamedImportsName } from './rules/sort-named-imports'
import sortObjectKeys, { RULE_NAME as sortObjectKeysName } from './rules/sort-object-keys'
import sortObjects, { RULE_NAME as sortObjectsName } from './rules/sort-objects'
import sortUnionTypes, { RULE_NAME as sortUnionTypesName } from './rules/sort-union-types'
import { SortType, SortOrder } from './typings'
import { name } from './package.json'
Expand Down Expand Up @@ -66,7 +66,7 @@ let createConfigWithOptions = (options: {
[sortMapElementsName]: ['error'],
[sortNamedExportsName]: ['error'],
[sortNamedImportsName]: ['error'],
[sortObjectKeysName]: ['error'],
[sortObjectsName]: ['error'],
[sortUnionTypesName]: ['error'],
}
return {
Expand All @@ -91,7 +91,7 @@ export default {
[sortMapElementsName]: sortMapElements,
[sortNamedExportsName]: sortNamedExports,
[sortNamedImportsName]: sortNamedImports,
[sortObjectKeysName]: sortObjectKeys,
[sortObjectsName]: sortObjects,
[sortUnionTypesName]: sortUnionTypes,
},
configs: {
Expand Down
24 changes: 12 additions & 12 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,18 @@ export default [perfectionistPluginRecommendedNatural]

🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).

| Name | Description | 🔧 |
| :------------------------------------------------------------------------------------------- | :------------------------------------------ | :-- |
| [sort-array-includes](https://eslint-plugin-perfectionist.azat.io/rules/sort-array-includes) | enforce sorted arrays before include method | 🔧 |
| [sort-enums](https://eslint-plugin-perfectionist.azat.io/rules/sort-enums) | enforce sorted TypeScript enums | 🔧 |
| [sort-imports](https://eslint-plugin-perfectionist.azat.io/rules/sort-imports) | enforce sorted imports | 🔧 |
| [sort-interfaces](https://eslint-plugin-perfectionist.azat.io/rules/sort-interfaces) | enforce sorted interface properties | 🔧 |
| [sort-jsx-props](https://eslint-plugin-perfectionist.azat.io/rules/sort-jsx-props) | enforce sorted JSX props | 🔧 |
| [sort-map-elements](https://eslint-plugin-perfectionist.azat.io/rules/sort-map-elements) | enforce sorted Map elements | 🔧 |
| [sort-named-exports](https://eslint-plugin-perfectionist.azat.io/rules/sort-named-exports) | enforce sorted named exports | 🔧 |
| [sort-named-imports](https://eslint-plugin-perfectionist.azat.io/rules/sort-named-imports) | enforce sorted named imports | 🔧 |
| [sort-object-keys](https://eslint-plugin-perfectionist.azat.io/rules/sort-object-keys) | enforce sorted object keys | 🔧 |
| [sort-union-types](https://eslint-plugin-perfectionist.azat.io/rules/sort-union-types) | enforce sorted union types | 🔧 |
| Name | Description | 🔧 |
| :------------------------------------------------------------------------------------------- | :------------------------------------------ | :- |
| [sort-array-includes](https://eslint-plugin-perfectionist.azat.io/rules/sort-array-includes) | enforce sorted arrays before include method | 🔧 |
| [sort-enums](https://eslint-plugin-perfectionist.azat.io/rules/sort-enums) | enforce sorted TypeScript enums | 🔧 |
| [sort-imports](https://eslint-plugin-perfectionist.azat.io/rules/sort-imports) | enforce sorted imports | 🔧 |
| [sort-interfaces](https://eslint-plugin-perfectionist.azat.io/rules/sort-interfaces) | enforce sorted interface properties | 🔧 |
| [sort-jsx-props](https://eslint-plugin-perfectionist.azat.io/rules/sort-jsx-props) | enforce sorted JSX props | 🔧 |
| [sort-map-elements](https://eslint-plugin-perfectionist.azat.io/rules/sort-map-elements) | enforce sorted Map elements | 🔧 |
| [sort-named-exports](https://eslint-plugin-perfectionist.azat.io/rules/sort-named-exports) | enforce sorted named exports | 🔧 |
| [sort-named-imports](https://eslint-plugin-perfectionist.azat.io/rules/sort-named-imports) | enforce sorted named imports | 🔧 |
| [sort-objects](https://eslint-plugin-perfectionist.azat.io/rules/sort-objects) | enforce sorted objects | 🔧 |
| [sort-union-types](https://eslint-plugin-perfectionist.azat.io/rules/sort-union-types) | enforce sorted union types | 🔧 |

<!-- end auto-generated rules list -->

Expand Down
10 changes: 5 additions & 5 deletions rules/sort-object-keys.ts → rules/sort-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { complete } from '../utils/complete'
import { pairwise } from '../utils/pairwise'
import { compare } from '../utils/compare'

type MESSAGE_ID = 'unexpectedObjectKeysOrder'
type MESSAGE_ID = 'unexpectedObjectsOrder'

type Options = [
Partial<{
Expand All @@ -22,14 +22,14 @@ type Options = [
}>,
]

export const RULE_NAME = 'sort-object-keys'
export const RULE_NAME = 'sort-objects'

export default createEslintRule<Options, MESSAGE_ID>({
name: RULE_NAME,
meta: {
type: 'suggestion',
docs: {
description: 'enforce sorted object keys',
description: 'enforce sorted objects',
recommended: false,
},
fixable: 'code',
Expand Down Expand Up @@ -58,7 +58,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
},
],
messages: {
unexpectedObjectKeysOrder:
unexpectedObjectsOrder:
'Expected "{{second}}" to come before "{{first}}"',
},
},
Expand Down Expand Up @@ -116,7 +116,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
pairwise(nodes, (first, second) => {
if (compare(first, second, options)) {
context.report({
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: first.name,
second: second.name,
Expand Down
52 changes: 26 additions & 26 deletions test/sort-object-keys.test.ts → test/sort-objects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ESLintUtils } from '@typescript-eslint/utils'
import { describe, it } from 'vitest'
import { dedent } from 'ts-dedent'

import rule, { RULE_NAME } from '../rules/sort-object-keys'
import rule, { RULE_NAME } from '../rules/sort-objects'
import { SortType, SortOrder } from '../typings'

describe(RULE_NAME, () => {
Expand Down Expand Up @@ -59,7 +59,7 @@ describe(RULE_NAME, () => {
],
errors: [
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'hometown',
second: 'eye-color',
Expand Down Expand Up @@ -117,7 +117,7 @@ describe(RULE_NAME, () => {
],
errors: [
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'hunter',
second: 'dog',
Expand Down Expand Up @@ -199,28 +199,28 @@ describe(RULE_NAME, () => {
],
errors: [
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'crime-coefficient',
second: 'age',
},
},
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'crime-coefficient',
second: 'age',
},
},
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'shinya-kogami',
second: 'nobuchika-ginoza',
},
},
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'crime-coefficient',
second: 'age',
Expand Down Expand Up @@ -275,14 +275,14 @@ describe(RULE_NAME, () => {
],
errors: [
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'robots[1]',
second: 'getTestEva()',
},
},
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'getTestEva()',
second: 'eva-02',
Expand Down Expand Up @@ -344,7 +344,7 @@ describe(RULE_NAME, () => {
],
errors: [
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'hometown',
second: 'eye-color',
Expand Down Expand Up @@ -402,7 +402,7 @@ describe(RULE_NAME, () => {
],
errors: [
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'hunter',
second: 'dog',
Expand Down Expand Up @@ -484,28 +484,28 @@ describe(RULE_NAME, () => {
],
errors: [
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'crime-coefficient',
second: 'age',
},
},
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'crime-coefficient',
second: 'age',
},
},
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'shinya-kogami',
second: 'nobuchika-ginoza',
},
},
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'crime-coefficient',
second: 'age',
Expand Down Expand Up @@ -560,14 +560,14 @@ describe(RULE_NAME, () => {
],
errors: [
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'robots[1]',
second: 'getTestEva()',
},
},
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'getTestEva()',
second: 'eva-02',
Expand Down Expand Up @@ -629,7 +629,7 @@ describe(RULE_NAME, () => {
],
errors: [
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'age',
second: 'hometown',
Expand Down Expand Up @@ -687,7 +687,7 @@ describe(RULE_NAME, () => {
],
errors: [
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'dog',
second: 'hunter',
Expand Down Expand Up @@ -769,28 +769,28 @@ describe(RULE_NAME, () => {
],
errors: [
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'age',
second: 'crime-coefficient',
},
},
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'age',
second: 'crime-coefficient',
},
},
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'akane-tsunemori',
second: 'nobuchika-ginoza',
},
},
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'age',
second: 'crime-coefficient',
Expand Down Expand Up @@ -845,14 +845,14 @@ describe(RULE_NAME, () => {
],
errors: [
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'robots[1]',
second: 'getTestEva()',
},
},
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'getTestEva()',
second: 'eva-02',
Expand Down Expand Up @@ -895,7 +895,7 @@ describe(RULE_NAME, () => {
`,
errors: [
{
messageId: 'unexpectedObjectKeysOrder',
messageId: 'unexpectedObjectsOrder',
data: {
first: 'mom',
second: 'daughter',
Expand Down

0 comments on commit 3340a9f

Please sign in to comment.