Skip to content

Commit

Permalink
chore(consistent-selector-style): added rule scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Nov 22, 2024
1 parent ca37fbb commit df5843e
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-trainers-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-plugin-svelte': minor
---

feat: added the consistent-selector-style rule
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ These rules relate to style guidelines, and are therefore quite subjective:

| Rule ID | Description | |
|:--------|:------------|:---|
| [svelte/consistent-selector-style](https://sveltejs.github.io/eslint-plugin-svelte/rules/consistent-selector-style/) | enforce a consistent style for CSS selectors | |
| [svelte/derived-has-same-inputs-outputs](https://sveltejs.github.io/eslint-plugin-svelte/rules/derived-has-same-inputs-outputs/) | derived store should use same variable names between values and callback | |
| [svelte/first-attribute-linebreak](https://sveltejs.github.io/eslint-plugin-svelte/rules/first-attribute-linebreak/) | enforce the location of first attribute | :wrench: |
| [svelte/html-closing-bracket-new-line](https://sveltejs.github.io/eslint-plugin-svelte/rules/html-closing-bracket-new-line/) | Require or disallow a line break before tag's closing brackets | :wrench: |
Expand Down
1 change: 1 addition & 0 deletions docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ These rules relate to style guidelines, and are therefore quite subjective:

| Rule ID | Description | |
| :------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | :------- |
| [svelte/consistent-selector-style](./rules/consistent-selector-style.md) | enforce a consistent style for CSS selectors | |
| [svelte/derived-has-same-inputs-outputs](./rules/derived-has-same-inputs-outputs.md) | derived store should use same variable names between values and callback | |
| [svelte/first-attribute-linebreak](./rules/first-attribute-linebreak.md) | enforce the location of first attribute | :wrench: |
| [svelte/html-closing-bracket-new-line](./rules/html-closing-bracket-new-line.md) | Require or disallow a line break before tag's closing brackets | :wrench: |
Expand Down
51 changes: 51 additions & 0 deletions docs/rules/consistent-selector-style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
pageClass: 'rule-details'
sidebarDepth: 0
title: 'svelte/consistent-selector-style'
description: 'enforce a consistent style for CSS selectors'
---

# svelte/consistent-selector-style

> enforce a consistent style for CSS selectors
- :exclamation: <badge text="This rule has not been released yet." vertical="middle" type="error"> **_This rule has not been released yet._** </badge>

## :book: Rule Details

This rule reports ???.

<ESLintCodeBlock>

<!--eslint-skip-->

```svelte
<script>
/* eslint svelte/consistent-selector-style: "error" */
</script>
<!-- ✓ GOOD -->
<!-- ✗ BAD -->
```

</ESLintCodeBlock>

## :wrench: Options

```json
{
"svelte/consistent-selector-style": ["error", {}]
}
```

-

## :books: Further Reading

-

## :mag: Implementation

- [Rule source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/rules/consistent-selector-style.ts)
- [Test source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/tests/src/rules/consistent-selector-style.ts)
5 changes: 5 additions & 0 deletions packages/eslint-plugin-svelte/src/rule-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export interface RuleOptions {
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/comment-directive/
*/
'svelte/comment-directive'?: Linter.RuleEntry<SvelteCommentDirective>
/**
* enforce a consistent style for CSS selectors
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/consistent-selector-style/
*/
'svelte/consistent-selector-style'?: Linter.RuleEntry<[]>
/**
* derived store should use same variable names between values and callback
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/derived-has-same-inputs-outputs/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { createRule } from '../utils';

export default createRule('consistent-selector-style', {
meta: {
docs: {
description: 'enforce a consistent style for CSS selectors',
category: 'Stylistic Issues',
recommended: false
},
schema: [],
messages: {},
type: 'suggestion'
},
create(context) {
return {};
}
});
2 changes: 2 additions & 0 deletions packages/eslint-plugin-svelte/src/utils/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import typescriptEslintNoUnnecessaryCondition from '../rules/@typescript-eslint/
import blockLang from '../rules/block-lang';
import buttonHasType from '../rules/button-has-type';
import commentDirective from '../rules/comment-directive';
import consistentSelectorStyle from '../rules/consistent-selector-style';
import derivedHasSameInputsOutputs from '../rules/derived-has-same-inputs-outputs';
import experimentalRequireSlotTypes from '../rules/experimental-require-slot-types';
import experimentalRequireStrictEvents from '../rules/experimental-require-strict-events';
Expand Down Expand Up @@ -73,6 +74,7 @@ export const rules = [
blockLang,
buttonHasType,
commentDirective,
consistentSelectorStyle,
derivedHasSameInputsOutputs,
experimentalRequireSlotTypes,
experimentalRequireStrictEvents,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { RuleTester } from '../../utils/eslint-compat';
import rule from '../../../src/rules/consistent-selector-style';
import { loadTestCases } from '../../utils/utils';

const tester = new RuleTester({
languageOptions: {
ecmaVersion: 2020,
sourceType: 'module'
}
});

tester.run('consistent-selector-style', rule as any, loadTestCases('consistent-selector-style'));

0 comments on commit df5843e

Please sign in to comment.