From 57ac0f2d2d048402bf82ac08446d8836e2d5e862 Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Thu, 8 Jul 2021 12:27:33 +0900 Subject: [PATCH] Add first-attribute-linebreak rule --- README.md | 1 + docs/rules/README.md | 1 + docs/rules/first-attribute-linebreak.md | 79 +++++++++++++++++ docs/rules/max-attributes-per-line.md | 8 +- src/rules/first-attribute-linebreak.ts | 84 +++++++++++++++++++ src/utils/rules.ts | 2 + .../invalid/below/_config.json | 3 + .../invalid/below/test01-errors.json | 12 +++ .../invalid/below/test01-input.svelte | 18 ++++ .../invalid/below/test01-output.svelte | 20 +++++ .../invalid/beside/_config.json | 3 + .../invalid/beside/test01-errors.json | 12 +++ .../invalid/beside/test01-input.svelte | 18 ++++ .../invalid/beside/test01-output.svelte | 16 ++++ .../invalid/test01-errors.json | 12 +++ .../invalid/test01-input.svelte | 18 ++++ .../invalid/test01-output.svelte | 18 ++++ .../valid/below/_config.json | 3 + .../valid/below/test01-input.svelte | 22 +++++ .../valid/beside/_config.json | 3 + .../valid/beside/test01-input.svelte | 16 ++++ .../valid/test01-input.svelte | 18 ++++ tests/src/rules/first-attribute-linebreak.ts | 16 ++++ 23 files changed, 402 insertions(+), 1 deletion(-) create mode 100644 docs/rules/first-attribute-linebreak.md create mode 100644 src/rules/first-attribute-linebreak.ts create mode 100644 tests/fixtures/rules/first-attribute-linebreak/invalid/below/_config.json create mode 100644 tests/fixtures/rules/first-attribute-linebreak/invalid/below/test01-errors.json create mode 100644 tests/fixtures/rules/first-attribute-linebreak/invalid/below/test01-input.svelte create mode 100644 tests/fixtures/rules/first-attribute-linebreak/invalid/below/test01-output.svelte create mode 100644 tests/fixtures/rules/first-attribute-linebreak/invalid/beside/_config.json create mode 100644 tests/fixtures/rules/first-attribute-linebreak/invalid/beside/test01-errors.json create mode 100644 tests/fixtures/rules/first-attribute-linebreak/invalid/beside/test01-input.svelte create mode 100644 tests/fixtures/rules/first-attribute-linebreak/invalid/beside/test01-output.svelte create mode 100644 tests/fixtures/rules/first-attribute-linebreak/invalid/test01-errors.json create mode 100644 tests/fixtures/rules/first-attribute-linebreak/invalid/test01-input.svelte create mode 100644 tests/fixtures/rules/first-attribute-linebreak/invalid/test01-output.svelte create mode 100644 tests/fixtures/rules/first-attribute-linebreak/valid/below/_config.json create mode 100644 tests/fixtures/rules/first-attribute-linebreak/valid/below/test01-input.svelte create mode 100644 tests/fixtures/rules/first-attribute-linebreak/valid/beside/_config.json create mode 100644 tests/fixtures/rules/first-attribute-linebreak/valid/beside/test01-input.svelte create mode 100644 tests/fixtures/rules/first-attribute-linebreak/valid/test01-input.svelte create mode 100644 tests/src/rules/first-attribute-linebreak.ts diff --git a/README.md b/README.md index c6d848e9b..c2a1c6753 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,7 @@ These rules relate to style guidelines, and are therefore quite subjective: | Rule ID | Description | | |:--------|:------------|:---| +| [@ota-meshi/svelte/first-attribute-linebreak](https://ota-meshi.github.io/eslint-plugin-svelte/rules/first-attribute-linebreak.html) | enforce the location of first attribute | :wrench: | | [@ota-meshi/svelte/html-quotes](https://ota-meshi.github.io/eslint-plugin-svelte/rules/html-quotes.html) | enforce quotes style of HTML attributes | :wrench: | | [@ota-meshi/svelte/indent](https://ota-meshi.github.io/eslint-plugin-svelte/rules/indent.html) | enforce consistent indentation | :wrench: | | [@ota-meshi/svelte/max-attributes-per-line](https://ota-meshi.github.io/eslint-plugin-svelte/rules/max-attributes-per-line.html) | enforce the maximum number of attributes per line | :wrench: | diff --git a/docs/rules/README.md b/docs/rules/README.md index 6a2d2cb02..edd61c36b 100644 --- a/docs/rules/README.md +++ b/docs/rules/README.md @@ -44,6 +44,7 @@ These rules relate to style guidelines, and are therefore quite subjective: | Rule ID | Description | | |:--------|:------------|:---| +| [@ota-meshi/svelte/first-attribute-linebreak](./first-attribute-linebreak.md) | enforce the location of first attribute | :wrench: | | [@ota-meshi/svelte/html-quotes](./html-quotes.md) | enforce quotes style of HTML attributes | :wrench: | | [@ota-meshi/svelte/indent](./indent.md) | enforce consistent indentation | :wrench: | | [@ota-meshi/svelte/max-attributes-per-line](./max-attributes-per-line.md) | enforce the maximum number of attributes per line | :wrench: | diff --git a/docs/rules/first-attribute-linebreak.md b/docs/rules/first-attribute-linebreak.md new file mode 100644 index 000000000..3f6f033fc --- /dev/null +++ b/docs/rules/first-attribute-linebreak.md @@ -0,0 +1,79 @@ +--- +pageClass: "rule-details" +sidebarDepth: 0 +title: "@ota-meshi/svelte/first-attribute-linebreak" +description: "enforce the location of first attribute" +--- + +# @ota-meshi/svelte/first-attribute-linebreak + +> enforce the location of first attribute + +- :exclamation: **_This rule has not been released yet._** +- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule. + +## :book: Rule Details + +This rule aims to enforce a consistent location for the first attribute. + + + + + + +```svelte + + + + +