Skip to content

refactor: rename settings.kit to settings.svelte.kit #290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,6 @@ See also <https://github.com/ota-meshi/svelte-eslint-parser#readme>.

You can change the behavior of this plugin with some settings.

- `ignoreWarnings` (optional) ... Specifies an array of rules that ignore reports in the template.
For example, set rules on the template that cannot avoid false positives.
- `compileOptions` (optional) ... Specifies options for Svelte compile. Effects rules that use Svelte compile. The target rules are [svelte/valid-compile](https://ota-meshi.github.io/eslint-plugin-svelte/rules/valid-compile/) and [svelte/no-unused-svelte-ignore](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-unused-svelte-ignore/). **Note that it has no effect on ESLint's custom parser**.
- `postcss` (optional) ... Specifies options related to PostCSS. You can disable the PostCSS process by specifying `false`.
- `configFilePath` (optional) ... Specifies the path of the directory containing the PostCSS configuration.

e.g.

```js
Expand All @@ -210,13 +204,30 @@ module.exports = {
configFilePath: "./path/to/my/postcss.config.js",
},
},
kit: {
files: {
routes: "src/routes",
},
},
},
},
// ...
}
```

#### settings.kit
#### settings.svelte.ignoreWarnings

Specifies an array of rules that ignore reports in the template.
For example, set rules on the template that cannot avoid false positives.

#### settings.svelte.compileOptions

Specifies options for Svelte compile. Effects rules that use Svelte compile. The target rules are [svelte/valid-compile](https://ota-meshi.github.io/eslint-plugin-svelte/rules/valid-compile/) and [svelte/no-unused-svelte-ignore](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-unused-svelte-ignore/). **Note that it has no effect on ESLint's custom parser**.

- `postcss` ... Specifies options related to PostCSS. You can disable the PostCSS process by specifying `false`.
- `configFilePath` ... Specifies the path of the directory containing the PostCSS configuration.

#### settings.svelte.kit

If you use SvelteKit with not default configuration, you need to set below configurations.
The schema is subset of SvelteKit's configuration.
Expand All @@ -228,9 +239,11 @@ e.g.
module.exports = {
// ...
settings: {
kit: {
files: {
routes: "src/routes",
svelte: {
kit: {
files: {
routes: "src/routes",
},
},
},
},
Expand Down Expand Up @@ -294,7 +307,7 @@ These rules relate to possible syntax or logic errors in Svelte code:
| [svelte/no-shorthand-style-property-overrides](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-shorthand-style-property-overrides/) | disallow shorthand style properties that override related longhand properties | :star: |
| [svelte/no-store-async](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-store-async/) | disallow using async/await inside svelte stores because it causes issues with the auto-unsubscribing features | |
| [svelte/no-unknown-style-directive-property](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-unknown-style-directive-property/) | disallow unknown `style:property` | :star: |
| [svelte/require-store-callbacks-use-set-param](https://ota-meshi.github.io/eslint-plugin-svelte/rules/require-store-callbacks-use-set-param/) | (no description) | |
| [svelte/require-store-callbacks-use-set-param](https://ota-meshi.github.io/eslint-plugin-svelte/rules/require-store-callbacks-use-set-param/) | store callbacks must use `set` param | |
| [svelte/valid-compile](https://ota-meshi.github.io/eslint-plugin-svelte/rules/valid-compile/) | disallow warnings when compiling. | :star: |

## Security Vulnerability
Expand Down
2 changes: 1 addition & 1 deletion docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ These rules relate to possible syntax or logic errors in Svelte code:
| [svelte/no-shorthand-style-property-overrides](./rules/no-shorthand-style-property-overrides.md) | disallow shorthand style properties that override related longhand properties | :star: |
| [svelte/no-store-async](./rules/no-store-async.md) | disallow using async/await inside svelte stores because it causes issues with the auto-unsubscribing features | |
| [svelte/no-unknown-style-directive-property](./rules/no-unknown-style-directive-property.md) | disallow unknown `style:property` | :star: |
| [svelte/require-store-callbacks-use-set-param](./rules/require-store-callbacks-use-set-param.md) | (no description) | |
| [svelte/require-store-callbacks-use-set-param](./rules/require-store-callbacks-use-set-param.md) | store callbacks must use `set` param | |
| [svelte/valid-compile](./rules/valid-compile.md) | disallow warnings when compiling. | :star: |

## Security Vulnerability
Expand Down
10 changes: 6 additions & 4 deletions docs/rules/no-export-load-in-svelte-module-in-kit-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ And the API has changed.
<script>
const config = {
settings: {
kit: {
files: {
routes: "",
svelte: {
kit: {
files: {
routes: "",
},
},
},
},
Expand All @@ -49,7 +51,7 @@ And the API has changed.

## :wrench: Options

Nothing. But if use are using not default routes folder, please set configuration according to the [user guide](../user-guide.md#settings-kit).
Nothing. But if use are using not default routes folder, please set configuration according to the [user guide](../user-guide.md#settings-svelte-kit).

## :books: Further Reading

Expand Down
4 changes: 3 additions & 1 deletion docs/rules/require-store-callbacks-use-set-param.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ description: "store callbacks must use `set` param"

# svelte/require-store-callbacks-use-set-param

> Store callbacks must use `set` param.
> store callbacks must use `set` param

- :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

Expand Down
33 changes: 23 additions & 10 deletions docs/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@ See also <https://github.com/ota-meshi/svelte-eslint-parser#readme>.

You can change the behavior of this plugin with some settings.

- `ignoreWarnings` (optional) ... Specifies an array of rules that ignore reports in the template.
For example, set rules on the template that cannot avoid false positives.
- `compileOptions` (optional) ... Specifies options for Svelte compile. Effects rules that use Svelte compile. The target rules are [svelte/valid-compile](./rules/valid-compile.md) and [svelte/no-unused-svelte-ignore](./rules/no-unused-svelte-ignore.md). **Note that it has no effect on ESLint's custom parser**.
- `postcss` (optional) ... Specifies options related to PostCSS. You can disable the PostCSS process by specifying `false`.
- `configFilePath` (optional) ... Specifies the path of the directory containing the PostCSS configuration.

e.g.

```js
Expand All @@ -162,13 +156,30 @@ module.exports = {
configFilePath: "./path/to/my/postcss.config.js",
},
},
kit: {
files: {
routes: "src/routes",
},
},
},
},
// ...
}
```

#### settings.kit
#### settings.svelte.ignoreWarnings

Specifies an array of rules that ignore reports in the template.
For example, set rules on the template that cannot avoid false positives.

#### settings.svelte.compileOptions

Specifies options for Svelte compile. Effects rules that use Svelte compile. The target rules are [svelte/valid-compile](./rules/valid-compile.md) and [svelte/no-unused-svelte-ignore](./rules/no-unused-svelte-ignore.md). **Note that it has no effect on ESLint's custom parser**.

- `postcss` ... Specifies options related to PostCSS. You can disable the PostCSS process by specifying `false`.
- `configFilePath` ... Specifies the path of the directory containing the PostCSS configuration.

#### settings.svelte.kit

If you use SvelteKit with not default configuration, you need to set below configurations.
The schema is subset of SvelteKit's configuration.
Expand All @@ -180,9 +191,11 @@ e.g.
module.exports = {
// ...
settings: {
kit: {
files: {
routes: "src/routes",
svelte: {
kit: {
files: {
routes: "src/routes",
},
},
},
},
Expand Down
10 changes: 5 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ export type RuleContext = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ignore
options: any[]
settings?: {
["svelte"]?: {
svelte?: {
ignoreWarnings?: unknown
compileOptions?: {
babel?: boolean
postcss?: false | { configFilePath?: unknown }
}
}
["kit"]?: {
files?: {
routes?: string
kit?: {
files?: {
routes?: string
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/svelte-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export function isKitPageComponent(context: RuleContext): boolean {
if (isRunOnBrowser) return true
if (!hasSvelteKit(context.getFilename())) return false
const routes =
context.settings?.kit?.files?.routes?.replace(/^\//, "") ?? "src/routes"
context.settings?.svelte?.kit?.files?.routes?.replace(/^\//, "") ??
"src/routes"
const filePath = context.getFilename()
const projectRootDir = getProjectRootDir(context.getFilename()) ?? ""
return filePath.startsWith(path.join(projectRootDir, routes))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"settings": {
"kit": {
"files": {
"routes": "tests/fixtures"
"svelte": {
"kit": {
"files": {
"routes": "tests/fixtures"
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"settings": {
"kit": {
"files": {
"routes": "tests/fixtures"
"svelte": {
"kit": {
"files": {
"routes": "tests/fixtures"
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"settings": {
"kit": {
"files": {
"routes": "some-path"
"svelte": {
"kit": {
"files": {
"routes": "some-path"
}
}
}
}
Expand Down