Skip to content

Commit

Permalink
feat: add ignore-case option to each rule
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io committed Jun 2, 2023
1 parent 2989539 commit e331b9a
Show file tree
Hide file tree
Showing 25 changed files with 125 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/rules/sort-array-includes.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ This rule aims to promote code readability and maintainability by enforcing a co
- `asc` - enforce properties to be in ascending order.
- `desc` - enforce properties to be in descending order.

### `ignore-case`

- `boolean` (default: `false`) - only affects alphabetical and natural sorting. When `true` the rule ignores the case-sensitivity of the order.

### `spreadLast`

- `boolean` (default: `false`) - enforce spread elements in array to be last
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/sort-enums.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ enum Hinamizawa {
- `asc` - enforce properties to be in ascending order.
- `desc` - enforce properties to be in descending order.

### `ignore-case`

- `boolean` (default: `false`) - only affects alphabetical and natural sorting. When `true` the rule ignores the case-sensitivity of the order.

## ⚙️ Usage

### Legacy Config
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/sort-imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ import './style.css'
- `asc` - enforce properties to be in ascending order.
- `desc` - enforce properties to be in descending order.

### `ignore-case`

- `boolean` (default: `false`) - only affects alphabetical and natural sorting. When `true` the rule ignores the case-sensitivity of the order.

### `groups`

- `[array]`
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/sort-interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ interface Hero {
- `asc` - enforce properties to be in ascending order.
- `desc` - enforce properties to be in descending order.

### `ignore-case`

- `boolean` (default: `false`) - only affects alphabetical and natural sorting. When `true` the rule ignores the case-sensitivity of the order.

### `ignore-pattern`

- `[string]` (default: `[]`) - allows to ignore interface by pattern
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/sort-jsx-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ let Riko = () => (
- `asc` - enforce properties to be in ascending order.
- `desc` - enforce properties to be in descending order.

### `ignore-case`

- `boolean` (default: `false`) - only affects alphabetical and natural sorting. When `true` the rule ignores the case-sensitivity of the order.

## ⚙️ Usage

### Legacy Config
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/sort-map-elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ let bebop = Map([
- `asc` - enforce properties to be in ascending order.
- `desc` - enforce properties to be in descending order.

### `ignore-case`

- `boolean` (default: `false`) - only affects alphabetical and natural sorting. When `true` the rule ignores the case-sensitivity of the order.

## ⚙️ Usage

### Legacy Config
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/sort-named-exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ export {
- `asc` - enforce properties to be in ascending order.
- `desc` - enforce properties to be in descending order.

### `ignore-case`

- `boolean` (default: `false`) - only affects alphabetical and natural sorting. When `true` the rule ignores the case-sensitivity of the order.

## ⚙️ Usage

### Legacy Config
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/sort-named-imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ export {
- `asc` - enforce properties to be in ascending order.
- `desc` - enforce properties to be in descending order.

### `ignore-case`

- `boolean` (default: `false`) - only affects alphabetical and natural sorting. When `true` the rule ignores the case-sensitivity of the order.

## ⚙️ Usage

### Legacy Config
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/sort-object-keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ let family = {
- `asc` - enforce properties to be in ascending order.
- `desc` - enforce properties to be in descending order.

### `ignore-case`

- `boolean` (default: `false`) - only affects alphabetical and natural sorting. When `true` the rule ignores the case-sensitivity of the order.

## ⚙️ Usage

### Legacy Config
Expand Down
4 changes: 4 additions & 0 deletions docs/rules/sort-union-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ type DevilHunter =
- `asc` - enforce properties to be in ascending order.
- `desc` - enforce properties to be in descending order.
### `ignore-case`
- `boolean` (default: `false`) - only affects alphabetical and natural sorting. When `true` the rule ignores the case-sensitivity of the order.
## ⚙️ Usage
### Legacy Config
Expand Down
3 changes: 3 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type RuleDeclaration = [RuleSeverity, { [key: string]: unknown }?]
let createConfigWithOptions = (options: {
type: SortType
order: SortOrder
'ignore-case'?: boolean
}): {
plugins: ['perfectionist']
rules: {
Expand Down Expand Up @@ -84,10 +85,12 @@ export default {
'recommended-alphabetical': createConfigWithOptions({
type: SortType.alphabetical,
order: SortOrder.asc,
'ignore-case': false,
}),
'recommended-natural': createConfigWithOptions({
type: SortType.natural,
order: SortOrder.asc,
'ignore-case': false,
}),
'recommended-line-length': createConfigWithOptions({
type: SortType['line-length'],
Expand Down
8 changes: 7 additions & 1 deletion rules/sort-array-includes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ type MESSAGE_ID = 'unexpectedArrayIncludesOrder'

type Options = [
Partial<{
spreadLast: boolean
'ignore-case': boolean
order: SortOrder
type: SortType
spreadLast: boolean
}>,
]

Expand Down Expand Up @@ -49,6 +50,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
enum: [SortOrder.asc, SortOrder.desc],
default: SortOrder.asc,
},
'ignore-case': {
type: 'boolean',
default: false,
},
spreadLast: {
type: 'boolean',
default: false,
Expand Down Expand Up @@ -79,6 +84,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
let options = complete(context.options.at(0), {
type: SortType.alphabetical,
order: SortOrder.asc,
'ignore-case': false,
spreadLast: false,
})

Expand Down
6 changes: 6 additions & 0 deletions rules/sort-enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type MESSAGE_ID = 'unexpectedEnumsOrder'

type Options = [
Partial<{
'ignore-case': boolean
order: SortOrder
type: SortType
}>,
Expand Down Expand Up @@ -43,6 +44,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
],
default: SortType.natural,
},
'ignore-case': {
type: 'boolean',
default: false,
},
order: {
enum: [SortOrder.asc, SortOrder.desc],
default: SortOrder.asc,
Expand All @@ -66,6 +71,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
let options = complete(context.options.at(0), {
type: SortType.alphabetical,
order: SortOrder.asc,
'ignore-case': false,
})

if (node.members.length > 1) {
Expand Down
6 changes: 6 additions & 0 deletions rules/sort-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Options = [
'internal-pattern': string[]
groups: (Group[] | Group)[]
'read-tsconfig': boolean
'ignore-case': boolean
}>,
]

Expand Down Expand Up @@ -86,6 +87,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
enum: [SortOrder.asc, SortOrder.desc],
default: SortOrder.asc,
},
'ignore-case': {
type: 'boolean',
default: false,
},
groups: {
type: 'array',
default: [],
Expand Down Expand Up @@ -132,6 +137,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
type: SortType.alphabetical,
'read-tsconfig': false,
order: SortOrder.asc,
'ignore-case': false,
groups: ['unknown'],
})

Expand Down
6 changes: 6 additions & 0 deletions rules/sort-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Options = [
Partial<{
order: SortOrder
type: SortType
'ignore-case': boolean
'ignore-pattern': string[]
}>,
]
Expand Down Expand Up @@ -49,6 +50,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
enum: [SortOrder.asc, SortOrder.desc],
default: SortOrder.asc,
},
'ignore-case': {
type: 'boolean',
default: false,
},
'ignore-pattern': {
type: 'array',
default: [],
Expand All @@ -72,6 +77,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
TSInterfaceDeclaration: node => {
let options = complete(context.options.at(0), {
type: SortType.alphabetical,
'ignore-case': false,
order: SortOrder.asc,
'ignore-pattern': [],
})
Expand Down
6 changes: 6 additions & 0 deletions rules/sort-jsx-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Options = [
Partial<{
order: SortOrder
type: SortType
'ignore-case': boolean
}>,
]

Expand Down Expand Up @@ -48,6 +49,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
enum: [SortOrder.asc, SortOrder.desc],
default: SortOrder.asc,
},
'ignore-case': {
type: 'boolean',
default: false,
},
},
additionalProperties: false,
},
Expand All @@ -67,6 +72,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
JSXElement: node => {
let options = complete(context.options.at(0), {
type: SortType.alphabetical,
'ignore-case': false,
order: SortOrder.asc,
})

Expand Down
6 changes: 6 additions & 0 deletions rules/sort-map-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type MESSAGE_ID = 'unexpectedMapElementsOrder'

type Options = [
Partial<{
'ignore-case': boolean
order: SortOrder
type: SortType
}>,
Expand Down Expand Up @@ -48,6 +49,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
enum: [SortOrder.asc, SortOrder.desc],
default: SortOrder.asc,
},
'ignore-case': {
type: 'boolean',
default: false,
},
},
additionalProperties: false,
},
Expand All @@ -72,6 +77,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
) {
let options = complete(context.options.at(0), {
type: SortType.alphabetical,
'ignore-case': false,
order: SortOrder.asc,
})

Expand Down
6 changes: 6 additions & 0 deletions rules/sort-named-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type MESSAGE_ID = 'unexpectedNamedExportsOrder'

type Options = [
Partial<{
'ignore-case': boolean
order: SortOrder
type: SortType
}>,
Expand Down Expand Up @@ -45,6 +46,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
enum: [SortOrder.asc, SortOrder.desc],
default: SortOrder.asc,
},
'ignore-case': {
type: 'boolean',
default: false,
},
},
additionalProperties: false,
},
Expand All @@ -64,6 +69,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
ExportNamedDeclaration: node => {
let options = complete(context.options.at(0), {
type: SortType.alphabetical,
'ignore-case': false,
order: SortOrder.asc,
})

Expand Down
6 changes: 6 additions & 0 deletions rules/sort-named-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type MESSAGE_ID = 'unexpectedNamedImportsOrder'

type Options = [
Partial<{
'ignore-case': boolean
order: SortOrder
type: SortType
}>,
Expand Down Expand Up @@ -45,6 +46,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
enum: [SortOrder.asc, SortOrder.desc],
default: SortOrder.asc,
},
'ignore-case': {
type: 'boolean',
default: false,
},
},
additionalProperties: false,
},
Expand All @@ -64,6 +69,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
ImportDeclaration: node => {
let options = complete(context.options.at(0), {
type: SortType.alphabetical,
'ignore-case': false,
order: SortOrder.asc,
})

Expand Down
6 changes: 6 additions & 0 deletions rules/sort-object-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type MESSAGE_ID = 'unexpectedObjectKeysOrder'

type Options = [
Partial<{
'ignore-case': boolean
order: SortOrder
type: SortType
}>,
Expand Down Expand Up @@ -48,6 +49,10 @@ export default createEslintRule<Options, MESSAGE_ID>({
enum: [SortOrder.asc, SortOrder.desc],
default: SortOrder.asc,
},
'ignore-case': {
type: 'boolean',
default: false,
},
},
additionalProperties: false,
},
Expand All @@ -68,6 +73,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
if (node.properties.length > 1) {
let options = complete(context.options.at(0), {
type: SortType.alphabetical,
'ignore-case': false,
order: SortOrder.asc,
})

Expand Down
Loading

0 comments on commit e331b9a

Please sign in to comment.