Skip to content

Commit d98121e

Browse files
author
Ted Weatherly
committed
refactor(order): invert naming
1 parent 5700f01 commit d98121e

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
77
## [Unreleased]
88

99
### Added
10-
- [`order`]: add `orderBySplitPaths` option
10+
- [`order`]: add `orderByFullPathString` option
1111

1212
## [2.32.0] - 2025-06-20
1313

docs/rules/order.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ import index from './';
367367

368368
### `alphabetize`
369369

370-
Valid values: `{ order?: "asc" | "desc" | "ignore", orderImportKind?: "asc" | "desc" | "ignore", caseInsensitive?: boolean, orderBySplitPaths?: boolean }` \
371-
Default: `{ order: "ignore", orderImportKind: "ignore", caseInsensitive: false, orderBySplitPaths: true }`
370+
Valid values: `{ order?: "asc" | "desc" | "ignore", orderImportKind?: "asc" | "desc" | "ignore", caseInsensitive?: boolean, orderByFullPathString?: boolean }` \
371+
Default: `{ order: "ignore", orderImportKind: "ignore", caseInsensitive: false, orderByFullPathString: false }`
372372

373373
Determine the sort order of imports within each [predefined group][18] or [`PathGroup`][8] alphabetically based on specifier.
374374

@@ -385,7 +385,7 @@ Valid properties and their values include:
385385

386386
- **`caseInsensitive`**: use `true` to ignore case and `false` to consider case when sorting
387387

388-
- **`orderBySplitPaths`**: use `true` to split by paths and sort by each one and `false` to sort by the full un-split path string
388+
- **`orderByFullPathString`**: use `false` to split by paths and sort by each one and `true` to sort by the full un-split path string
389389

390390
#### Example
391391

src/rules/order.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ function getSorter(alphabetizeOptions) {
434434
let result = 0;
435435

436436
if (
437-
alphabetizeOptions.orderBySplitPaths === false
437+
alphabetizeOptions.orderByFullPathString === true
438438
|| !includes(importA, '/') && !includes(importB, '/')
439439
) {
440440
result = compareString(importA, importB);
@@ -834,9 +834,9 @@ function getAlphabetizeConfig(options) {
834834
const order = alphabetize.order || 'ignore';
835835
const orderImportKind = alphabetize.orderImportKind || 'ignore';
836836
const caseInsensitive = alphabetize.caseInsensitive || false;
837-
const orderBySplitPaths = alphabetize.orderBySplitPaths || true;
837+
const orderByFullPathString = alphabetize.orderByFullPathString || false;
838838

839-
return { order, orderImportKind, caseInsensitive, orderBySplitPaths };
839+
return { order, orderImportKind, caseInsensitive, orderByFullPathString };
840840
}
841841

842842
// TODO, semver-major: Change the default of "distinctGroup" from true to false
@@ -966,9 +966,9 @@ module.exports = {
966966
enum: ['ignore', 'asc', 'desc'],
967967
default: 'ignore',
968968
},
969-
orderBySplitPaths: {
969+
orderByFullPathString: {
970970
type: 'boolean',
971-
default: true,
971+
default: false,
972972
},
973973
},
974974
additionalProperties: false,

tests/src/rules/order.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -780,37 +780,37 @@ ruleTester.run('order', rule, {
780780
alphabetize: { order: 'desc' },
781781
}],
782782
}),
783-
// Option alphabetize: {order: 'asc'} with orderBySplitPaths: false`
783+
// Option alphabetize: {order: 'asc'} with orderByFullPathString: true`
784784
test({
785785
code: `
786786
import a from "foo";
787787
import b from "foo-bar";
788788
import c from "foo/bar";
789789
import d from "foo/barfoo";
790790
`,
791-
options: [{ alphabetize: { order: 'asc' }, orderBySplitPaths: false }],
791+
options: [{ alphabetize: { order: 'asc' }, orderByFullPathString: true }],
792792
}),
793-
// Option alphabetize: {order: 'asc'} with orderBySplitPaths: false
793+
// Option alphabetize: {order: 'asc'} with orderByFullPathString: true
794794
test({
795795
code: `
796796
import a from "foo";
797797
import b from "foo-bar";
798798
import c from "foo/foobar/bar";
799799
import d from "foo/foobar/barfoo";
800800
`,
801-
options: [{ alphabetize: { order: 'asc' }, orderBySplitPaths: false }],
801+
options: [{ alphabetize: { order: 'asc' }, orderByFullPathString: true }],
802802
}),
803-
// Option alphabetize: {order: 'desc'} with orderBySplitPaths: false
803+
// Option alphabetize: {order: 'desc'} with orderByFullPathString: true
804804
test({
805805
code: `
806806
import d from "foo/barfoo";
807807
import c from "foo/bar";
808808
import b from "foo-bar";
809809
import a from "foo";
810810
`,
811-
options: [{ alphabetize: { order: 'desc' }, orderBySplitPaths: false }],
811+
options: [{ alphabetize: { order: 'desc' }, orderByFullPathString: true }],
812812
}),
813-
// Option alphabetize: {order: 'desc'} with orderBySplitPaths: false and file names having non-alphanumeric characters.
813+
// Option alphabetize: {order: 'desc'} with orderByFullPathString: true and file names having non-alphanumeric characters.
814814
test({
815815
code: `
816816
import d from "foo/barfoo";
@@ -819,7 +819,7 @@ ruleTester.run('order', rule, {
819819
import a from "foo";`,
820820
options: [{
821821
alphabetize: { order: 'desc' },
822-
orderBySplitPaths: false,
822+
orderByFullPathString: true,
823823
}],
824824
}),
825825
// Option alphabetize with newlines-between: {order: 'asc', newlines-between: 'always'}
@@ -2688,7 +2688,7 @@ ruleTester.run('order', rule, {
26882688
message: '`foo-bar` import should occur after import of `foo/barfoo`',
26892689
}],
26902690
}),
2691-
// Option alphabetize: {order: 'asc'} with orderBySplitPaths: false
2691+
// Option alphabetize: {order: 'asc'} with orderByFullPathString: true
26922692
test({
26932693
code: `
26942694
import a from "foo";
@@ -2698,7 +2698,7 @@ ruleTester.run('order', rule, {
26982698
`,
26992699
options: [{
27002700
alphabetize: { order: 'asc' },
2701-
orderBySplitPaths: false,
2701+
orderByFullPathString: true,
27022702
}],
27032703
output: `
27042704
import a from "foo";

0 commit comments

Comments
 (0)