Skip to content
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

chore: add playground #29

Merged
merged 2 commits into from
Mar 27, 2025
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
</p>
<p align="center">ESLint plugin for internationalization with Svelte</p>

<h2 align="center">

[Online Demo](https://eslint-online-playground.netlify.app/#https://github.com/intlify/eslint-plugin-svelte/tree/main/playground)

</h2>

## :book: Documentation

See [here](https://github.com/intlify/eslint-plugin-svelte/blob/main/docs/README.md)
Expand Down
16 changes: 2 additions & 14 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@

@intlify/eslint-plugin-svelte is ESLint plugin for internationalization with Svelte. It easily integrates some localization features to your Svelte Application.

Go to [Get Started](./started.md)
- 👉 Go to [Get Started](./started.md)

<eslint-code-block :rules="{ '@intlify/svelte/no-raw-text': 'error' }">

<!-- eslint-skip -->

```html
<!-- ✓ GOOD -->
<h2>{$_('page.subtitle')}</h2>

<!-- ✗ BAD -->
<p>Plain text cannot be replaced by multiple languages.</p>
```

</eslint-code-block>
- 👉 Try it out in [Online Demo](https://eslint-online-playground.netlify.app/#https://github.com/intlify/eslint-plugin-svelte/tree/main/playground)
2 changes: 1 addition & 1 deletion docs/rules/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Available Rules

- :star: mark: the rule which is enabled by the `plugin:@intlify/svelte/recommended` or `*.configs.["flat/recommended"]` preset.
- :star: mark: the rule which is enabled by the `*.configs.["flat/recommended"]` preset.
- :black_nib: mark: the rule which is fixable by `eslint --fix` command.

## Recommended
Expand Down
2 changes: 1 addition & 1 deletion lib/configs/flat/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default [
},
{
name: '@intlify/svelte:base:svelte',
files: ['*.svelte'],
files: ['**/*.svelte', '*.svelte'],
languageOptions: {
parser: parser
}
Expand Down
12 changes: 12 additions & 0 deletions playground/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import js from '@eslint/js'
import intlifySvelte from '@intlify/eslint-plugin-svelte'
export default [
js.configs.recommended,
...intlifySvelte.configs.recommended,
{
files: ['**/*.svelte', '*.svelte'],
rules: {
'@intlify/svelte/no-raw-text': 'warn'
}
}
]
9 changes: 9 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "module",
"devDependencies": {
"@eslint/js": "latest",
"eslint": "latest",
"@intlify/eslint-plugin-svelte": "latest",
"svelte-i18n": "^4.0.1"
}
}
9 changes: 9 additions & 0 deletions playground/src/MyComponent.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

<script>
import { t } from 'svelte-i18n'
</script>
<!-- ✗ BAD -->
<p>hello</p>

<!-- ✓ GOOD -->
<p>{ $t('hello') }</p>
2 changes: 1 addition & 1 deletion scripts/update-docs-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ writeFileSync(
resolve(import.meta.dirname, '../docs/rules/README.md'),
`# Available Rules

- :star: mark: the rule which is enabled by the \`plugin:@intlify/svelte/recommended\` or \`*.configs.["flat/recommended"]\` preset.
- :star: mark: the rule which is enabled by the \`*.configs.["flat/recommended"]\` preset.
- :black_nib: mark: the rule which is fixable by \`eslint --fix\` command.

${withCategories
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-flat-base-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default [
},
{
name: '@intlify/svelte:base:svelte',
files: ['*.svelte'],
files: ['**/*.svelte', '*.svelte'],
languageOptions: {
parser: parser,
}
Expand Down