Skip to content

Commit a0301c4

Browse files
committed
chore(consistent-selector-style): added rule scaffolding
1 parent ca37fbb commit a0301c4

File tree

7 files changed

+89
-0
lines changed

7 files changed

+89
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ These rules relate to style guidelines, and are therefore quite subjective:
439439

440440
| Rule ID | Description | |
441441
|:--------|:------------|:---|
442+
| [svelte/consistent-selector-style](https://sveltejs.github.io/eslint-plugin-svelte/rules/consistent-selector-style/) | enforce a consistent style for CSS selectors | |
442443
| [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 | |
443444
| [svelte/first-attribute-linebreak](https://sveltejs.github.io/eslint-plugin-svelte/rules/first-attribute-linebreak/) | enforce the location of first attribute | :wrench: |
444445
| [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: |

docs/rules.md

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ These rules relate to style guidelines, and are therefore quite subjective:
7676

7777
| Rule ID | Description | |
7878
| :------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | :------- |
79+
| [svelte/consistent-selector-style](./rules/consistent-selector-style.md) | enforce a consistent style for CSS selectors | |
7980
| [svelte/derived-has-same-inputs-outputs](./rules/derived-has-same-inputs-outputs.md) | derived store should use same variable names between values and callback | |
8081
| [svelte/first-attribute-linebreak](./rules/first-attribute-linebreak.md) | enforce the location of first attribute | :wrench: |
8182
| [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: |
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
pageClass: 'rule-details'
3+
sidebarDepth: 0
4+
title: 'svelte/consistent-selector-style'
5+
description: 'enforce a consistent style for CSS selectors'
6+
---
7+
8+
# svelte/consistent-selector-style
9+
10+
> enforce a consistent style for CSS selectors
11+
12+
- :exclamation: <badge text="This rule has not been released yet." vertical="middle" type="error"> **_This rule has not been released yet._** </badge>
13+
14+
## :book: Rule Details
15+
16+
This rule reports ???.
17+
18+
<ESLintCodeBlock>
19+
20+
<!--eslint-skip-->
21+
22+
```svelte
23+
<script>
24+
/* eslint svelte/consistent-selector-style: "error" */
25+
</script>
26+
27+
<!-- ✓ GOOD -->
28+
29+
<!-- ✗ BAD -->
30+
```
31+
32+
</ESLintCodeBlock>
33+
34+
## :wrench: Options
35+
36+
```json
37+
{
38+
"svelte/consistent-selector-style": ["error", {}]
39+
}
40+
```
41+
42+
-
43+
44+
## :books: Further Reading
45+
46+
-
47+
48+
## :mag: Implementation
49+
50+
- [Rule source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/rules/consistent-selector-style.ts)
51+
- [Test source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/tests/src/rules/consistent-selector-style.ts)

packages/eslint-plugin-svelte/src/rule-types.ts

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export interface RuleOptions {
3434
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/comment-directive/
3535
*/
3636
'svelte/comment-directive'?: Linter.RuleEntry<SvelteCommentDirective>
37+
/**
38+
* enforce a consistent style for CSS selectors
39+
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/consistent-selector-style/
40+
*/
41+
'svelte/consistent-selector-style'?: Linter.RuleEntry<[]>
3742
/**
3843
* derived store should use same variable names between values and callback
3944
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/derived-has-same-inputs-outputs/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { createRule } from '../utils';
2+
3+
export default createRule('consistent-selector-style', {
4+
meta: {
5+
docs: {
6+
description: 'enforce a consistent style for CSS selectors',
7+
category: 'Stylistic Issues',
8+
recommended: false
9+
},
10+
schema: [],
11+
messages: {},
12+
type: 'suggestion'
13+
},
14+
create(context) {
15+
return {};
16+
}
17+
});

packages/eslint-plugin-svelte/src/utils/rules.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import typescriptEslintNoUnnecessaryCondition from '../rules/@typescript-eslint/
66
import blockLang from '../rules/block-lang';
77
import buttonHasType from '../rules/button-has-type';
88
import commentDirective from '../rules/comment-directive';
9+
import consistentSelectorStyle from '../rules/consistent-selector-style';
910
import derivedHasSameInputsOutputs from '../rules/derived-has-same-inputs-outputs';
1011
import experimentalRequireSlotTypes from '../rules/experimental-require-slot-types';
1112
import experimentalRequireStrictEvents from '../rules/experimental-require-strict-events';
@@ -73,6 +74,7 @@ export const rules = [
7374
blockLang,
7475
buttonHasType,
7576
commentDirective,
77+
consistentSelectorStyle,
7678
derivedHasSameInputsOutputs,
7779
experimentalRequireSlotTypes,
7880
experimentalRequireStrictEvents,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { RuleTester } from '../../utils/eslint-compat';
2+
import rule from '../../../src/rules/consistent-selector-style';
3+
import { loadTestCases } from '../../utils/utils';
4+
5+
const tester = new RuleTester({
6+
languageOptions: {
7+
ecmaVersion: 2020,
8+
sourceType: 'module'
9+
}
10+
});
11+
12+
tester.run('consistent-selector-style', rule as any, loadTestCases('consistent-selector-style'));

0 commit comments

Comments
 (0)