diff --git a/.editorconfig b/.editorconfig index d4479bea2..9364f19c0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,3 +5,9 @@ end_of_line = lf indent_size = 2 indent_style = tab trim_trailing_whitespace = true + +[docs/rules/no-trailing-spaces.md] +trim_trailing_whitespace = false + +[packages/eslint-plugin-svelte/tests/fixtures/**/*-input.svelte] +trim_trailing_whitespace = false diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index ce9bdc71a..e0e7fc31d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -68,13 +68,13 @@ body: attributes: label: Link to **GitHub Repo** with Minimal Reproducible Example description: | - Create a minimal reproduction of the problem. **A minimal reproduction is required** so that others can help debug your issue. If a report is vague (e.g. just a generic error message) and has no reproduction, it may be closed. - [Why Reproductions are Required](https://antfu.me/posts/why-reproductions-are-required) + Create a minimal reproduction of the problem. **A minimal reproduction is required** so that others can help debug your issue. If a report is vague (e.g. just a generic error message) and has no reproduction, it may be closed.\ + [Why Reproductions are Required](https://antfu.me/posts/why-reproductions-are-required)\ - Be sure to share the repo on GitHub. GitHub's repo is ready to debug using Codespace. - Please DON'T USE non-GitHub repos such as GitLab as repro. - It takes me a long time to prepare my local PC for debugging. - Please DON'T USE stackblitz as a repro. + Be sure to share the repo on GitHub. GitHub's repo is ready to debug using Codespace.\ + Please DON'T USE non-GitHub repos such as GitLab as repro.\ + It takes me a long time to prepare my local PC for debugging.\ + Please DON'T USE stackblitz as a repro.\ We can't debug eslint with stackblitz. placeholder: | https://github.com/[your]/[repo] diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 7a81ca70f..88dc427e9 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -7,7 +7,7 @@ body: attributes: label: Description description: | - A clear and concise description of the new feature. + A clear and concise description of the new feature.\ Also give a few code examples. validations: required: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1f1d95462..fcddde4a3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,7 +34,7 @@ Rule tests typically use fixtures. For example, for the `indent` rule, the test - The `invalid` directory contains test cases where the rule should report errors. - The `valid` directory contains test cases where no errors are reported. -Fixture input files should be named `*-input.svelte` and are automatically collected. +Fixture input files should be named `*-input.svelte` and are automatically collected.\ If configuration is needed, include a JSON file: - For a specific test file (e.g., `my-test-input.svelte`), add `my-test-config.json`. @@ -52,7 +52,7 @@ pnpm run test -- -g indent Refer to [this Stack Overflow post](https://stackoverflow.com/questions/10832031/how-to-run-a-single-test-with-mocha) for details. -To test a single file (e.g., `my-test-input.svelte`), add a `my-test-config.json` with `{"only": true}`. +To test a single file (e.g., `my-test-input.svelte`), add a `my-test-config.json` with `{"only": true}`. (Remember to remove `{"only": true}` before submitting a pull request.) ## Preview Docs diff --git a/README.md b/README.md index edc472b33..e64034538 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ ## Introduction -`eslint-plugin-svelte` is the official [ESLint](https://eslint.org/) plugin for [Svelte](https://svelte.dev/). -It leverages the AST generated by [svelte-eslint-parser](https://github.com/sveltejs/svelte-eslint-parser) to provide custom linting for Svelte. +`eslint-plugin-svelte` is the official [ESLint](https://eslint.org/) plugin for [Svelte](https://svelte.dev/).\ +It leverages the AST generated by [svelte-eslint-parser](https://github.com/sveltejs/svelte-eslint-parser) to provide custom linting for Svelte.\ Note that `eslint-plugin-svelte` and `svelte-eslint-parser` cannot be used alongside [eslint-plugin-svelte3](https://github.com/sveltejs/eslint-plugin-svelte3). @@ -219,8 +219,8 @@ export default [ ## Editor Integrations -**Visual Studio Code** -Install [dbaeumer.vscode-eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint). +**Visual Studio Code**\ +Install [dbaeumer.vscode-eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).\ Configure `.svelte` files in `.vscode/settings.json`: ```json @@ -247,8 +247,8 @@ This project follows [Semantic Versioning](https://semver.org/). Unlike [ESLint -:wrench: Indicates that the rule is fixable, and using `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the reported problems. -:bulb: Indicates that some problems reported by the rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +:wrench: Indicates that the rule is fixable, and using `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the reported problems.\ +:bulb: Indicates that some problems reported by the rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).\ :star: Indicates that the rule is included in the `plugin:svelte/recommended` config. @@ -400,7 +400,7 @@ These rules relate to this plugin works: ## Contributing -Contributions are welcome! Please open an issue or submit a PR. For more details, see [CONTRIBUTING.md](./CONTRIBUTING.md). +Contributions are welcome! Please open an issue or submit a PR. For more details, see [CONTRIBUTING.md](./CONTRIBUTING.md).\ Refer to [svelte-eslint-parser](https://github.com/sveltejs/svelte-eslint-parser) for AST details. diff --git a/docs/README.md b/docs/README.md index 9f765d50e..0e49ffdbc 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,8 +4,8 @@ title: 'eslint-plugin-svelte' ## Introduction -`eslint-plugin-svelte` is the official [ESLint](https://eslint.org/) plugin for [Svelte](https://svelte.dev/). -It leverages the AST generated by [svelte-eslint-parser](https://github.com/sveltejs/svelte-eslint-parser) to provide custom linting for Svelte. +`eslint-plugin-svelte` is the official [ESLint](https://eslint.org/) plugin for [Svelte](https://svelte.dev/).\ +It leverages the AST generated by [svelte-eslint-parser](https://github.com/sveltejs/svelte-eslint-parser) to provide custom linting for Svelte.\ Note that `eslint-plugin-svelte` and `svelte-eslint-parser` cannot be used alongside [eslint-plugin-svelte3](https://github.com/sveltejs/eslint-plugin-svelte3). See [User Guide](./user-guide.md). diff --git a/docs/migration.md b/docs/migration.md index 0acc972ff..2f9796fc4 100644 --- a/docs/migration.md +++ b/docs/migration.md @@ -65,7 +65,7 @@ Therefore, you need to replace the package name, and the presets, rules, and set ## From `eslint-plugin-svelte` v2 To v3 -This section explains the necessary changes when upgrading from `eslint-plugin-svelte` v2 to v3. +This section explains the necessary changes when upgrading from `eslint-plugin-svelte` v2 to v3.\ v3 includes **support for ESLint Flat Config only**, **changes to the recommended rule set**, and other breaking changes. --- diff --git a/docs/rules.md b/docs/rules.md index 75dd5ed5e..f01645596 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -4,8 +4,8 @@ sidebarDepth: 0 # Available Rules -:wrench: Indicates that the rule is fixable, and using `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the reported problems. -:bulb: Indicates that some problems reported by the rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +:wrench: Indicates that the rule is fixable, and using `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the reported problems.\ +:bulb: Indicates that some problems reported by the rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).\ :star: Indicates that the rule is included in the `plugin:svelte/recommended` config. diff --git a/docs/rules/no-dynamic-slot-name.md b/docs/rules/no-dynamic-slot-name.md index 805e5e923..8ad69b959 100644 --- a/docs/rules/no-dynamic-slot-name.md +++ b/docs/rules/no-dynamic-slot-name.md @@ -15,7 +15,7 @@ since: 'v0.14.0' ## :book: Rule Details -This rule reports the dynamically specified `` name. +This rule reports the dynamically specified `` name.\ Dynamic `` names are not allowed in Svelte, so you must use static names. The auto-fix of this rule can be replaced with a static `` name if the expression given to the `` name is static and resolvable. diff --git a/docs/rules/no-extra-reactive-curlies.md b/docs/rules/no-extra-reactive-curlies.md index 6d8a9f63e..bc0a6eae9 100644 --- a/docs/rules/no-extra-reactive-curlies.md +++ b/docs/rules/no-extra-reactive-curlies.md @@ -38,7 +38,7 @@ Nothing. ## :heart: Compatibility -This rule was taken from [@tivac/eslint-plugin-svelte]. +This rule was taken from [@tivac/eslint-plugin-svelte].\ This rule is compatible with `@tivac/svelte/reactive-curlies` rule. [@tivac/eslint-plugin-svelte]: https://github.com/tivac/eslint-plugin-svelte/ diff --git a/docs/rules/no-inner-declarations.md b/docs/rules/no-inner-declarations.md index 50cff3ecd..aa35c9b31 100644 --- a/docs/rules/no-inner-declarations.md +++ b/docs/rules/no-inner-declarations.md @@ -16,7 +16,7 @@ since: 'v0.0.8' This rule requires that function declarations and, optionally, variable declarations be in the root of a program or the body of a function. -This rule extends the base ESLint's [no-inner-declarations] rule. The AST generated by [svelte-eslint-parser] will false positives in [no-inner-declarations] rule because the root node of the script is not the `Program`. +This rule extends the base ESLint's [no-inner-declarations] rule. The AST generated by [svelte-eslint-parser] will false positives in [no-inner-declarations] rule because the root node of the script is not the `Program`.\ This rule supports [svelte-eslint-parser]'s AST. [svelte-eslint-parser]: https://github.com/sveltejs/svelte-eslint-parser diff --git a/docs/rules/no-not-function-handler.md b/docs/rules/no-not-function-handler.md index c1736a0a2..ae0055171 100644 --- a/docs/rules/no-not-function-handler.md +++ b/docs/rules/no-not-function-handler.md @@ -14,7 +14,7 @@ since: 'v0.5.0' ## :book: Rule Details -This rule reports where you used not function value in event handlers. +This rule reports where you used not function value in event handlers.\ If you use a non-function value for the event handler, it event handler will not be called. It's almost always a mistake. You may have written a lot of unnecessary curly braces. diff --git a/docs/rules/no-object-in-text-mustaches.md b/docs/rules/no-object-in-text-mustaches.md index c6f2a3587..ed7078833 100644 --- a/docs/rules/no-object-in-text-mustaches.md +++ b/docs/rules/no-object-in-text-mustaches.md @@ -14,7 +14,7 @@ since: 'v0.5.0' ## :book: Rule Details -This rule disallows the use of objects in text mustache interpolation. +This rule disallows the use of objects in text mustache interpolation.\ When you use an object for text interpolation, it is drawn as `[object Object]`. It's almost always a mistake. You may have written a lot of unnecessary curly braces. diff --git a/docs/rules/no-reactive-functions.md b/docs/rules/no-reactive-functions.md index d81f1861f..5b5c90407 100644 --- a/docs/rules/no-reactive-functions.md +++ b/docs/rules/no-reactive-functions.md @@ -47,7 +47,7 @@ Nothing ## :heart: Compatibility -This rule was taken from [@tivac/eslint-plugin-svelte]. +This rule was taken from [@tivac/eslint-plugin-svelte].\ This rule is compatible with `@tivac/svelte/reactive-functions` rule. [@tivac/eslint-plugin-svelte]: https://github.com/tivac/eslint-plugin-svelte/ diff --git a/docs/rules/no-reactive-literals.md b/docs/rules/no-reactive-literals.md index d0633ae10..6fb6e44f8 100644 --- a/docs/rules/no-reactive-literals.md +++ b/docs/rules/no-reactive-literals.md @@ -36,7 +36,7 @@ Nothing. ## :heart: Compatibility -This rule was taken from [@tivac/eslint-plugin-svelte]. +This rule was taken from [@tivac/eslint-plugin-svelte].\ This rule is compatible with `@tivac/svelte/reactive-literals` rule. [@tivac/eslint-plugin-svelte]: https://github.com/tivac/eslint-plugin-svelte/ diff --git a/docs/rules/no-unused-props.md b/docs/rules/no-unused-props.md index 33f1f0804..d87e29b5b 100644 --- a/docs/rules/no-unused-props.md +++ b/docs/rules/no-unused-props.md @@ -14,7 +14,7 @@ since: 'v3.2.0' ## :book: Rule Details -This rule reports properties that are defined in Props but never used in the component code. +This rule reports properties that are defined in Props but never used in the component code.\ It helps to detect dead code and improve component clarity by ensuring that every declared prop is utilized. This rule checks various usage patterns of props: diff --git a/docs/rules/no-useless-mustaches.md b/docs/rules/no-useless-mustaches.md index 5ded18531..781793cbf 100644 --- a/docs/rules/no-useless-mustaches.md +++ b/docs/rules/no-useless-mustaches.md @@ -15,7 +15,7 @@ since: 'v0.0.4' ## :book: Rule Details -This rule reports mustache interpolation with a string literal value. +This rule reports mustache interpolation with a string literal value.\ The mustache interpolation with a string literal value can be changed to a static contents. diff --git a/docs/rules/prefer-destructured-store-props.md b/docs/rules/prefer-destructured-store-props.md index ce9890b3f..6d7e2db51 100644 --- a/docs/rules/prefer-destructured-store-props.md +++ b/docs/rules/prefer-destructured-store-props.md @@ -43,7 +43,7 @@ Nothing ## :heart: Compatibility -This rule was taken from [@tivac/eslint-plugin-svelte]. +This rule was taken from [@tivac/eslint-plugin-svelte].\ This rule is compatible with `@tivac/svelte/store-prop-destructuring` rule. [@tivac/eslint-plugin-svelte]: https://github.com/tivac/eslint-plugin-svelte/ diff --git a/docs/rules/require-optimized-style-attribute.md b/docs/rules/require-optimized-style-attribute.md index dc526df82..60380edaf 100644 --- a/docs/rules/require-optimized-style-attribute.md +++ b/docs/rules/require-optimized-style-attribute.md @@ -14,7 +14,7 @@ since: 'v0.32.0' This rule reports `style` attributes written in a format that cannot be optimized. -Svelte parses the content written in the style attribute and tries to optimize it. (See [https://github.com/sveltejs/svelte/pull/810](https://github.com/sveltejs/svelte/pull/810)) +Svelte parses the content written in the style attribute and tries to optimize it. (See [https://github.com/sveltejs/svelte/pull/810](https://github.com/sveltejs/svelte/pull/810))\ If Svelte can be successfully optimized, Svelte can minimize the number of re-renders. e.g. diff --git a/docs/rules/require-store-reactive-access.md b/docs/rules/require-store-reactive-access.md index b8d917cef..b8013f306 100644 --- a/docs/rules/require-store-reactive-access.md +++ b/docs/rules/require-store-reactive-access.md @@ -15,7 +15,7 @@ since: 'v2.12.0' ## :book: Rule Details -This rule disallow to use of the store itself as an operand. +This rule disallow to use of the store itself as an operand.\ You should access the store value using the `$` prefix or the `get` function. @@ -58,7 +58,7 @@ You should access the store value using the `$` prefix or the `get` function. ``` -This rule checks the usage of store variables only if the store can be determined within a single file. +This rule checks the usage of store variables only if the store can be determined within a single file. However, when using `@typescript-eslint/parser` and full type information, this rule uses the type information to determine if the expression is a store. diff --git a/docs/rules/require-stores-init.md b/docs/rules/require-stores-init.md index 13dcc9985..78222fb42 100644 --- a/docs/rules/require-stores-init.md +++ b/docs/rules/require-stores-init.md @@ -38,7 +38,7 @@ Nothing. ## :heart: Compatibility -This rule was taken from [@tivac/eslint-plugin-svelte]. +This rule was taken from [@tivac/eslint-plugin-svelte].\ This rule is compatible with `@tivac/svelte/stores-initial-value` rule. [@tivac/eslint-plugin-svelte]: https://github.com/tivac/eslint-plugin-svelte/ diff --git a/docs/rules/sort-attributes.md b/docs/rules/sort-attributes.md index 4f45af126..5d427d575 100644 --- a/docs/rules/sort-attributes.md +++ b/docs/rules/sort-attributes.md @@ -14,7 +14,7 @@ since: 'v2.4.0' ## :book: Rule Details -This rule aims to enforce ordering of attributes. +This rule aims to enforce ordering of attributes.\ The default order is: - `this` property. @@ -175,8 +175,8 @@ If there is a spread attribute between the attributes, it will not be reported a - `"alphabetical"` ... Sorts the attributes of the same group in alphabetical order. - `"ignore"` ... Attributes in the same group are not sorted. -Note that the behavior may change depending on how you specify the `order` setting. -For example, `bind:value` and `on:input={() => console.log(value)}` behave differently depending on the order. See for details. +Note that the behavior may change depending on how you specify the `order` setting.\ +For example, `bind:value` and `on:input={() => console.log(value)}` behave differently depending on the order. See for details.\ By default it is designed to be sorted safely. You can use the following formats for names or patterns: diff --git a/docs/user-guide.md b/docs/user-guide.md index babec87fa..14c061354 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -184,8 +184,8 @@ export default [ ## Editor Integrations -**Visual Studio Code** -Install [dbaeumer.vscode-eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint). +**Visual Studio Code**\ +Install [dbaeumer.vscode-eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).\ Configure `.svelte` files in `.vscode/settings.json`: ```json diff --git a/packages/eslint-plugin-svelte/tools/update-docs-rules-index.ts b/packages/eslint-plugin-svelte/tools/update-docs-rules-index.ts index e0c9a420a..ae38b30c0 100644 --- a/packages/eslint-plugin-svelte/tools/update-docs-rules-index.ts +++ b/packages/eslint-plugin-svelte/tools/update-docs-rules-index.ts @@ -14,8 +14,8 @@ sidebarDepth: 0 # Available Rules -:wrench: Indicates that the rule is fixable, and using \`--fix\` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the reported problems. -:bulb: Indicates that some problems reported by the rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +:wrench: Indicates that the rule is fixable, and using \`--fix\` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the reported problems.\\ +:bulb: Indicates that some problems reported by the rule are manually fixable by editor [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).\\ :star: Indicates that the rule is included in the \`plugin:svelte/recommended\` config.