diff --git a/rules/sort-array-includes.ts b/rules/sort-array-includes.ts index 9b5d18c0..e49a21f5 100644 --- a/rules/sort-array-includes.ts +++ b/rules/sort-array-includes.ts @@ -46,7 +46,7 @@ export default createEslintRule({ SortType.natural, SortType['line-length'], ], - default: SortType.natural, + default: SortType.alphabetical, }, order: { enum: [SortOrder.asc, SortOrder.desc], diff --git a/rules/sort-classes.ts b/rules/sort-classes.ts index a62b2ef2..598e5559 100644 --- a/rules/sort-classes.ts +++ b/rules/sort-classes.ts @@ -58,7 +58,7 @@ export default createEslintRule({ SortType.natural, SortType['line-length'], ], - default: SortType.natural, + default: SortType.alphabetical, }, 'ignore-case': { type: 'boolean', diff --git a/rules/sort-enums.ts b/rules/sort-enums.ts index 530a8fa1..89153b9b 100644 --- a/rules/sort-enums.ts +++ b/rules/sort-enums.ts @@ -43,7 +43,7 @@ export default createEslintRule({ SortType.natural, SortType['line-length'], ], - default: SortType.natural, + default: SortType.alphabetical, }, 'ignore-case': { type: 'boolean', diff --git a/rules/sort-exports.ts b/rules/sort-exports.ts index 7bfbc81b..6a417595 100644 --- a/rules/sort-exports.ts +++ b/rules/sort-exports.ts @@ -44,7 +44,7 @@ export default createEslintRule({ SortType.natural, SortType['line-length'], ], - default: SortType.natural, + default: SortType.alphabetical, }, order: { enum: [SortOrder.asc, SortOrder.desc], diff --git a/rules/sort-imports.ts b/rules/sort-imports.ts index 04ac5b71..f3e12e14 100644 --- a/rules/sort-imports.ts +++ b/rules/sort-imports.ts @@ -106,7 +106,7 @@ export default createEslintRule, MESSAGE_ID>({ SortType.natural, SortType['line-length'], ], - default: SortType.natural, + default: SortType.alphabetical, }, order: { enum: [SortOrder.asc, SortOrder.desc], diff --git a/rules/sort-interfaces.ts b/rules/sort-interfaces.ts index cbe35809..74ebf3df 100644 --- a/rules/sort-interfaces.ts +++ b/rules/sort-interfaces.ts @@ -45,7 +45,7 @@ export default createEslintRule({ SortType.natural, SortType['line-length'], ], - default: SortType.natural, + default: SortType.alphabetical, }, order: { enum: [SortOrder.asc, SortOrder.desc], diff --git a/rules/sort-jsx-props.ts b/rules/sort-jsx-props.ts index 94c5c511..0043790c 100644 --- a/rules/sort-jsx-props.ts +++ b/rules/sort-jsx-props.ts @@ -58,7 +58,7 @@ export default createEslintRule({ SortType.natural, SortType['line-length'], ], - default: SortType.natural, + default: SortType.alphabetical, }, order: { enum: [SortOrder.asc, SortOrder.desc], diff --git a/rules/sort-map-elements.ts b/rules/sort-map-elements.ts index 694823bb..c7712cac 100644 --- a/rules/sort-map-elements.ts +++ b/rules/sort-map-elements.ts @@ -45,7 +45,7 @@ export default createEslintRule({ SortType.natural, SortType['line-length'], ], - default: SortType.natural, + default: SortType.alphabetical, }, order: { enum: [SortOrder.asc, SortOrder.desc], diff --git a/rules/sort-named-exports.ts b/rules/sort-named-exports.ts index 4a43ab86..f01a6645 100644 --- a/rules/sort-named-exports.ts +++ b/rules/sort-named-exports.ts @@ -40,7 +40,7 @@ export default createEslintRule({ SortType.natural, SortType['line-length'], ], - default: SortType.natural, + default: SortType.alphabetical, }, order: { enum: [SortOrder.asc, SortOrder.desc], diff --git a/rules/sort-named-imports.ts b/rules/sort-named-imports.ts index 0a56b585..22254eaf 100644 --- a/rules/sort-named-imports.ts +++ b/rules/sort-named-imports.ts @@ -42,7 +42,7 @@ export default createEslintRule({ SortType.natural, SortType['line-length'], ], - default: SortType.natural, + default: SortType.alphabetical, }, order: { enum: [SortOrder.asc, SortOrder.desc], diff --git a/rules/sort-object-types.ts b/rules/sort-object-types.ts index 20a0b91b..527dbfed 100644 --- a/rules/sort-object-types.ts +++ b/rules/sort-object-types.ts @@ -43,7 +43,7 @@ export default createEslintRule({ SortType.natural, SortType['line-length'], ], - default: SortType.natural, + default: SortType.alphabetical, }, order: { enum: [SortOrder.asc, SortOrder.desc], diff --git a/rules/sort-objects.ts b/rules/sort-objects.ts index 2cbb16cc..deaa5a81 100644 --- a/rules/sort-objects.ts +++ b/rules/sort-objects.ts @@ -64,7 +64,7 @@ export default createEslintRule({ SortType.natural, SortType['line-length'], ], - default: SortType.natural, + default: SortType.alphabetical, }, order: { enum: [SortOrder.asc, SortOrder.desc], diff --git a/rules/sort-union-types.ts b/rules/sort-union-types.ts index 0d62ac90..7755c591 100644 --- a/rules/sort-union-types.ts +++ b/rules/sort-union-types.ts @@ -41,7 +41,7 @@ export default createEslintRule({ SortType.natural, SortType['line-length'], ], - default: SortType.natural, + default: SortType.alphabetical, }, order: { enum: [SortOrder.asc, SortOrder.desc], diff --git a/test/sort-array-includes.test.ts b/test/sort-array-includes.test.ts index 65e7a9ed..5bb69b0f 100644 --- a/test/sort-array-includes.test.ts +++ b/test/sort-array-includes.test.ts @@ -843,6 +843,17 @@ describe(RULE_NAME, () => { 'Tomomi Masaoka', ].includes(enforcer) `, + { + code: dedent` + [ + 'img1.png', + 'img10.png', + 'img12.png', + 'img2.png', + ].includes(filename) + `, + options: [{}], + }, ], invalid: [ { diff --git a/test/sort-classes.test.ts b/test/sort-classes.test.ts index 1a478999..43892fb9 100644 --- a/test/sort-classes.test.ts +++ b/test/sort-classes.test.ts @@ -945,4 +945,86 @@ describe(RULE_NAME, () => { }) }) }) + + describe(`${RULE_NAME}: misc`, () => { + it(`${RULE_NAME}: sets alphabetical asc sorting as default`, () => { + ruleTester.run(RULE_NAME, rule, { + valid: [ + { + code: dedent` + class Calculator { + static log(x) { + return 0; + } + + static log10(x) { + return 0; + } + + static log1p(x) { + return 0; + } + + static log2(x) { + return 0; + } + } + `, + options: [{}], + }, + ], + invalid: [ + { + code: dedent` + class Calculator { + static log(x) { + return 0; + } + + static log1p(x) { + return 0; + } + + static log10(x) { + return 0; + } + + static log2(x) { + return 0; + } + } + `, + output: dedent` + class Calculator { + static log(x) { + return 0; + } + + static log10(x) { + return 0; + } + + static log1p(x) { + return 0; + } + + static log2(x) { + return 0; + } + } + `, + errors: [ + { + messageId: 'unexpectedClassesOrder', + data: { + left: 'log1p', + right: 'log10', + }, + }, + ], + }, + ], + }) + }) + }) }) diff --git a/test/sort-enums.test.ts b/test/sort-enums.test.ts index a7537978..b23153ba 100644 --- a/test/sort-enums.test.ts +++ b/test/sort-enums.test.ts @@ -935,6 +935,17 @@ describe(RULE_NAME, () => { 'Ushio Kofune' = 'Ushio Kofune', } `, + { + code: dedent` + enum NumberBase { + BASE_10 = 10, + BASE_16 = 16, + BASE_2 = 2, + BASE_8 = 8 + } + `, + options: [{}], + }, ], invalid: [ { diff --git a/test/sort-exports.test.ts b/test/sort-exports.test.ts index 176f6f1c..b9eaedc6 100644 --- a/test/sort-exports.test.ts +++ b/test/sort-exports.test.ts @@ -512,6 +512,60 @@ describe(RULE_NAME, () => { }) describe('misc', () => { + it(`${RULE_NAME}: sets alphabetical asc sorting as default`, () => { + ruleTester.run(RULE_NAME, rule, { + valid: [ + dedent` + export { Hizuru } from '~/higotoshima/hizuru' + export { Mio } from '~/higotoshima/mio' + export { Shinpei } from '~/higotoshima/shinpei' + export { Ushio } from '~/higotoshima/ushio' + `, + { + code: dedent` + export { log } from './log' + export { log10 } from './log10' + export { log1p } from './log1p' + export { log2 } from './log2' + `, + options: [{}], + }, + ], + invalid: [ + { + code: dedent` + export { Shinpei } from '~/higotoshima/shinpei' + export { Mio } from '~/higotoshima/mio' + export { Ushio } from '~/higotoshima/ushio' + export { Hizuru } from '~/higotoshima/hizuru' + `, + output: dedent` + export { Hizuru } from '~/higotoshima/hizuru' + export { Mio } from '~/higotoshima/mio' + export { Shinpei } from '~/higotoshima/shinpei' + export { Ushio } from '~/higotoshima/ushio' + `, + errors: [ + { + messageId: 'unexpectedExportsOrder', + data: { + left: '~/higotoshima/shinpei', + right: '~/higotoshima/mio', + }, + }, + { + messageId: 'unexpectedExportsOrder', + data: { + left: '~/higotoshima/ushio', + right: '~/higotoshima/hizuru', + }, + }, + ], + }, + ], + }) + }) + it(`${RULE_NAME}: ignores exported variables or functions`, () => { ruleTester.run(RULE_NAME, rule, { valid: [ diff --git a/test/sort-imports.test.ts b/test/sort-imports.test.ts index 3aa57cdb..8c95b644 100644 --- a/test/sort-imports.test.ts +++ b/test/sort-imports.test.ts @@ -3216,6 +3216,15 @@ describe(RULE_NAME, () => { import Shinpei from '~/higotoshima/shinpei' import Ushio from '~/higotoshima/ushio' `, + { + code: dedent` + import { log } from './log' + import { log10 } from './log10' + import { log1p } from './log1p' + import { log2 } from './log2' + `, + options: [{}], + }, ], invalid: [ { diff --git a/test/sort-interfaces.test.ts b/test/sort-interfaces.test.ts index 55705216..8ef8d81a 100644 --- a/test/sort-interfaces.test.ts +++ b/test/sort-interfaces.test.ts @@ -1590,11 +1590,22 @@ describe(RULE_NAME, () => { ruleTester.run(RULE_NAME, rule, { valid: [ dedent` - interface DeathNoteValue { - causeOfDeath: string - name: string + interface DeathNoteValue { + causeOfDeath: string + name: string + } + `, + { + code: dedent` + interface Calculator { + log: (x: number) => number, + log10: (x: number) => number, + log1p: (x: number) => number, + log2: (x: number) => number, } `, + options: [{}], + }, ], invalid: [ { diff --git a/test/sort-jsx-props.test.ts b/test/sort-jsx-props.test.ts index dd31a565..9b04e7f4 100644 --- a/test/sort-jsx-props.test.ts +++ b/test/sort-jsx-props.test.ts @@ -1725,6 +1725,18 @@ describe(RULE_NAME, () => { /> ) `, + { + code: dedent` + const content = ( + + ) + `, + options: [{}], + }, ], invalid: [ { diff --git a/test/sort-map-elements.test.ts b/test/sort-map-elements.test.ts index 99ab68b0..c2ee0326 100644 --- a/test/sort-map-elements.test.ts +++ b/test/sort-map-elements.test.ts @@ -931,14 +931,25 @@ describe(RULE_NAME, () => { ruleTester.run(RULE_NAME, rule, { valid: [ dedent` + new Map([ + ['CNY', 'Renminbi'], + ['EUR', 'Euro'], + ['GBP', 'Sterling'], + ['RUB', 'Russian ruble'], + ['USD', 'United States dollar'], + ]) + `, + { + code: dedent` new Map([ - ['CNY', 'Renminbi'], - ['EUR', 'Euro'], - ['GBP', 'Sterling'], - ['RUB', 'Russian ruble'], - ['USD', 'United States dollar'], + ['img1.png', 'http://www.example.com/img1.png'], + ['img10.png', 'http://www.example.com/img10.png'], + ['img12.png', 'http://www.example.com/img12.png'], + ['img2.png', 'http://www.example.com/img2.png'] ]) `, + options: [{}], + }, ], invalid: [ { diff --git a/test/sort-named-exports.test.ts b/test/sort-named-exports.test.ts index 611da738..f0b1a33e 100644 --- a/test/sort-named-exports.test.ts +++ b/test/sort-named-exports.test.ts @@ -172,7 +172,13 @@ describe(RULE_NAME, () => { describe(`${RULE_NAME}: misc`, () => { it(`${RULE_NAME}: sets alphabetical asc sorting as default`, () => { ruleTester.run(RULE_NAME, rule, { - valid: ['export { KayoHinazuki, SatoruFujinuma }'], + valid: [ + 'export { KayoHinazuki, SatoruFujinuma }', + { + code: 'export { log, log10, log1p, log2 }', + options: [{}], + }, + ], invalid: [ { code: dedent` diff --git a/test/sort-named-imports.test.ts b/test/sort-named-imports.test.ts index 490e18f6..5841ee7e 100644 --- a/test/sort-named-imports.test.ts +++ b/test/sort-named-imports.test.ts @@ -851,6 +851,10 @@ describe(RULE_NAME, () => { ruleTester.run(RULE_NAME, rule, { valid: [ "import { David, Maine, Rebecca } from 'cyberpunks-edgerunners'", + { + code: "import { log, log10, log1p, log2 } from 'calculator'", + options: [{}], + }, ], invalid: [ { diff --git a/test/sort-object-types.test.ts b/test/sort-object-types.test.ts index c36e6891..9c8ec8e4 100644 --- a/test/sort-object-types.test.ts +++ b/test/sort-object-types.test.ts @@ -963,5 +963,60 @@ describe(RULE_NAME, () => { invalid: [], }) }) + + it(`${RULE_NAME}: sets alphabetical asc sorting as default`, () => { + ruleTester.run(RULE_NAME, rule, { + valid: [ + dedent` + type Calculator = { + log: (x: number) => number, + log10: (x: number) => number, + log1p: (x: number) => number, + log2: (x: number) => number, + } + `, + { + code: dedent` + type Calculator = { + log: (x: number) => number, + log10: (x: number) => number, + log1p: (x: number) => number, + log2: (x: number) => number, + } + `, + options: [{}], + }, + ], + invalid: [ + { + code: dedent` + type Calculator = { + log: (x: number) => number, + log1p: (x: number) => number, + log2: (x: number) => number, + log10: (x: number) => number, + } + `, + output: dedent` + type Calculator = { + log: (x: number) => number, + log10: (x: number) => number, + log1p: (x: number) => number, + log2: (x: number) => number, + } + `, + errors: [ + { + messageId: 'unexpectedObjectTypesOrder', + data: { + left: 'log2', + right: 'log10', + }, + }, + ], + }, + ], + }) + }) }) }) diff --git a/test/sort-objects.test.ts b/test/sort-objects.test.ts index be57ca63..fd452664 100644 --- a/test/sort-objects.test.ts +++ b/test/sort-objects.test.ts @@ -2249,6 +2249,17 @@ describe(RULE_NAME, () => { mom: 'Yor Forger', } `, + { + code: dedent` + const calculator = { + log: () => undefined, + log10: () => undefined, + log1p: () => undefined, + log2: () => undefined, + } + `, + options: [{}], + }, ], invalid: [ { diff --git a/test/sort-union-types.test.ts b/test/sort-union-types.test.ts index cbee9c95..4841d2ca 100644 --- a/test/sort-union-types.test.ts +++ b/test/sort-union-types.test.ts @@ -758,4 +758,41 @@ describe(RULE_NAME, () => { }) }) }) + + describe(`${RULE_NAME}: misc`, () => { + it(`${RULE_NAME}: sets alphabetical asc sorting as default`, () => { + ruleTester.run(RULE_NAME, rule, { + valid: [ + dedent` + type SupportedNumberBase = NumberBase.BASE_10 | NumberBase.BASE_16 | NumberBase.BASE_2 + `, + { + code: dedent` + type SupportedNumberBase = NumberBase.BASE_10 | NumberBase.BASE_16 | NumberBase.BASE_2 + `, + options: [{}], + }, + ], + invalid: [ + { + code: dedent` + type SupportedNumberBase = NumberBase.BASE_2 | NumberBase.BASE_10 | NumberBase.BASE_16 + `, + output: dedent` + type SupportedNumberBase = NumberBase.BASE_10 | NumberBase.BASE_16 | NumberBase.BASE_2 + `, + errors: [ + { + messageId: 'unexpectedUnionTypesOrder', + data: { + left: 'NumberBase.BASE_2', + right: 'NumberBase.BASE_10', + }, + }, + ], + }, + ], + }) + }) + }) })