Skip to content

Commit

Permalink
feat: deprecate sort-astro-attributes, sort-svelte-attributes and sor…
Browse files Browse the repository at this point in the history
…t-vue-attributes
  • Loading branch information
azat-io authored Oct 15, 2024
1 parent 398ac13 commit 46790ea
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 10 deletions.
8 changes: 7 additions & 1 deletion docs/components/Important.astro
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
---
import Typography from './Typography.astro'
interface Props {
title?: string
}
let { title = 'Important' } = Astro.props
---

<div class="important">
<Typography class="title" size="l" bold> Important</Typography>
<Typography class="title" size="l" bold>{title}</Typography>
<slot />
</div>

Expand Down
1 change: 1 addition & 0 deletions docs/content/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ let configs = defineCollection({
let rules = defineCollection({
schema: z.object({
keywords: z.array(z.string()).optional(),
deprecated: z.boolean().optional(),
shortDescription: z.string(),
description: z.string(),
title: z.string(),
Expand Down
8 changes: 8 additions & 0 deletions docs/content/rules/sort-astro-attributes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ keywords:
- code quality
- javascript linting
- astro attributes sorting
deprecated: true
---

import CodeExample from '../../components/CodeExample.svelte'
import Important from '../../components/Important.astro'
import CodeTabs from '../../components/CodeTabs.svelte'
import { dedent } from 'ts-dedent'

Expand All @@ -25,6 +27,12 @@ Adopting this rule helps standardize code formatting across your project, facili

It's **safe**. The rule considers spread elements in an attributes list and does not break component functionality.

<Important title="Deprecated">
This rule has been deprecated in favor of the [`astro/sort-attributes`](https://ota-meshi.github.io/eslint-plugin-astro/rules/sort-attributes/) rule.

See [Deprecate rules for sorting Vue, Svelte and Astro attributes](https://github.com/azat-io/eslint-plugin-perfectionist/issues/175) issue for more information.
</Important>

## Try it out

<CodeExample
Expand Down
7 changes: 5 additions & 2 deletions docs/content/rules/sort-svelte-attributes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ keywords:
- javascript linting
- svelte attributes sorting
- svelte props sorting
deprecated: true
---

import CodeExample from '../../components/CodeExample.svelte'
Expand All @@ -25,8 +26,10 @@ Maintaining a consistent order of attributes in Svelte elements enhances readabi

It's **safe**. The rule considers spread elements in an attributes list and does not break component functionality.

<Important>
If you use the [`sort-attributes`](https://sveltejs.github.io/eslint-plugin-svelte/rules/sort-attributes/) rule from the [`eslint-plugin-svelte`](https://sveltejs.github.io/eslint-plugin-svelte) plugin, it is highly recommended to [disable it](https://eslint.org/docs/latest/use/configure/rules#using-configuration-files-1) to avoid conflicts.
<Important title="Deprecated">
This rule has been deprecated in favor of the [`svelte/sort-attributes`](https://sveltejs.github.io/eslint-plugin-svelte/rules/sort-attributes/) rule.

See [Deprecate rules for sorting Vue, Svelte and Astro attributes](https://github.com/azat-io/eslint-plugin-perfectionist/issues/175) issue for more information.
</Important>

## Try it out
Expand Down
8 changes: 8 additions & 0 deletions docs/content/rules/sort-vue-attributes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ keywords:
- vue elements attributes
- vue elements order
- vue elements structure
deprecated: true
---

import CodeExample from '../../components/CodeExample.svelte'
import Important from '../../components/Important.astro'
import CodeTabs from '../../components/CodeTabs.svelte'
import { dedent } from 'ts-dedent'

Expand All @@ -27,6 +29,12 @@ Ensuring a consistent order of attributes in Vue elements is essential for reada

This rule enforces attribute sorting, making the structure of Vue components more predictable and easier to manage. By adopting this rule, developers can maintain a high standard of code organization and clarity in their Vue projects.

<Important title="Deprecated">
This rule has been deprecated in favor of the [`vue/attributes-order`](https://eslint.vuejs.org/rules/attributes-order.html) rule.

See [Deprecate rules for sorting Vue, Svelte and Astro attributes](https://github.com/azat-io/eslint-plugin-perfectionist/issues/175) issue for more information.
</Important>

## Try it out

<CodeExample
Expand Down
9 changes: 9 additions & 0 deletions docs/icons/delete.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/pages/rules/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ let rules = await getCollection('rules')
<th>Description</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
Expand All @@ -74,9 +75,8 @@ let rules = await getCollection('rules')
<td>
<Icon name="tool" size="s" />
</td>
<td>
<Icon name="star" size="s" />
</td>
<td>{!rule.data.deprecated && <Icon name="star" size="s" />}</td>
<td>{rule.data.deprecated && <Icon name="delete" size="s" />}</td>
</tr>
))
}
Expand Down
11 changes: 7 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ let plugin = {

let getRules = (options: BaseOptions): Record<string, RuleDeclaration> =>
Object.fromEntries(
Object.keys(plugin.rules).map(rule => [
`${name}/${rule}`,
['error', options],
]),
Object.entries(plugin.rules).reduce(
(accumulator: [string, RuleDeclaration][], [ruleName, ruleValue]) =>
ruleValue.meta.deprecated
? accumulator
: [...accumulator, [`${name}/${ruleName}`, ['error', options]]],
[],
),
)

let createConfig = (options: BaseOptions): FlatConfig.Config => ({
Expand Down
2 changes: 2 additions & 0 deletions rules/sort-astro-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export default createEslintRule<Options<string[]>, MESSAGE_ID>({
description: 'Enforce sorted Astro attributes.',
},
fixable: 'code',
deprecated: true,
replacedBy: ['astro/sort-attributes'],
schema: [
{
type: 'object',
Expand Down
2 changes: 2 additions & 0 deletions rules/sort-svelte-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export default createEslintRule<Options<string[]>, MESSAGE_ID>({
description: 'Enforce sorted Svelte attributes.',
},
fixable: 'code',
deprecated: true,
replacedBy: ['svelte/sort-attributes'],
schema: [
{
type: 'object',
Expand Down
2 changes: 2 additions & 0 deletions rules/sort-vue-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export default createEslintRule<Options<string[]>, MESSAGE_ID>({
description: 'Enforce sorted Vue attributes.',
},
fixable: 'code',
deprecated: true,
replacedBy: ['vue/attributes-order'],
schema: [
{
type: 'object',
Expand Down

0 comments on commit 46790ea

Please sign in to comment.