diff --git a/.env-cmdrc.js b/.env-cmdrc.js index eb513f08a..3261880a7 100644 --- a/.env-cmdrc.js +++ b/.env-cmdrc.js @@ -14,7 +14,7 @@ module.exports = { UPDATE_FIXTURES: 'true' }, sveltekit: { - NODE_OPTIONS: `--experimental-loader ./svelte-kit-import-hook.mjs ${ + NODE_OPTIONS: `--import ./svelte-kit-import.mjs ${ // eslint-disable-next-line no-process-env -- ignore process.env.NODE_OPTIONS || '' }` diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index b95b8f503..000000000 --- a/.eslintignore +++ /dev/null @@ -1,30 +0,0 @@ -/.nyc_output -/coverage -/lib -/node_modules -!/.vscode -!/.github -!/.devcontainer -/prettier-playground -/tests/fixtures/rules/indent/invalid/ts -/tests/fixtures/rules/indent/invalid/ts-v5 -/tests/fixtures/rules/indent/valid/ -/tests/fixtures/rules/no-unused-class-name/valid/invalid-style01-input.svelte -/tests/fixtures/rules/no-unused-class-name/valid/unknown-lang01-input.svelte -/tests/fixtures/rules/valid-compile/invalid/ts -/tests/fixtures/rules/valid-compile/valid/babel -/tests/fixtures/rules/valid-compile/valid/ts -/tests/fixtures/rules/prefer-style-directive -/tests/fixtures/rules/@typescript-eslint -/.svelte-kit -/svelte.config-dist.js -/build -/docs-svelte-kit/shim/eslint.mjs -/docs-svelte-kit/shim/assert.mjs -!/.*.js -/docs-svelte-kit/src/routes/*.md -/docs-svelte-kit/src/routes/**/*.md -/docs-svelte-kit/src/app.html - -# JSONSchema bug? -/.devcontainer/devcontainer.json diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index a81c80236..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,174 +0,0 @@ -'use strict'; - -// const version = require("./package.json").version - -module.exports = { - parserOptions: { - sourceType: 'script', - ecmaVersion: 'latest', - project: require.resolve('./tsconfig.json') - }, - extends: [ - 'plugin:@ota-meshi/recommended', - 'plugin:@ota-meshi/+node', - 'plugin:@ota-meshi/+typescript', - 'plugin:@ota-meshi/+eslint-plugin', - 'plugin:@ota-meshi/+package-json', - 'plugin:@ota-meshi/+json', - 'plugin:@ota-meshi/+yaml', - 'plugin:@ota-meshi/+md', - 'plugin:@ota-meshi/+prettier' - ], - rules: { - 'require-jsdoc': 'off', - 'no-warning-comments': 'warn', - 'no-lonely-if': 'off', - 'new-cap': 'off', - 'no-shadow': 'off', - 'no-void': ['error', { allowAsStatement: true }], - 'prettier/prettier': [ - 'error', - {}, - { - usePrettierrc: true - } - ], - 'n/file-extension-in-import': 'off', // It's a plugin bug(?). - // Repo rule - 'no-restricted-imports': [ - 'error', - { - patterns: [ - { - group: ['/regexpp', '/regexpp/*'], - message: 'Please use `@eslint-community/regexpp` instead.' - }, - { - group: ['/eslint-utils', '/eslint-utils/*'], - message: 'Please use `@eslint-community/eslint-utils` instead.' - } - ] - } - ] - }, - overrides: [ - { - files: ['*.md'], - extends: 'plugin:mdx/recommended', - settings: { - 'mdx/code-blocks': true - } - }, - { - files: ['*.mjs'], - parserOptions: { - sourceType: 'module' - } - }, - { - files: ['*.svelte'], - extends: ['plugin:svelte/base'], - parser: 'svelte-eslint-parser', - parserOptions: { - parser: { - ts: '@typescript-eslint/parser', - js: 'espree' - } - } - }, - { - files: ['*.ts', '*.mts'], - parser: '@typescript-eslint/parser', - parserOptions: { - sourceType: 'module', - project: require.resolve('./tsconfig.json') - }, - rules: { - '@typescript-eslint/naming-convention': [ - 'error', - { - selector: 'default', - format: ['camelCase'], - leadingUnderscore: 'allow', - trailingUnderscore: 'allow' - }, - { - selector: 'variable', - format: ['camelCase', 'UPPER_CASE'], - leadingUnderscore: 'allow', - trailingUnderscore: 'allow' - }, - { - selector: 'typeLike', - format: ['PascalCase'] - }, - { - selector: 'property', - format: null - }, - { - selector: 'method', - format: null - }, - { - selector: 'import', - format: null - } - ], - '@typescript-eslint/no-non-null-assertion': 'off' - } - }, - { - files: ['src/**'], - rules: { - '@typescript-eslint/no-restricted-imports': [ - 'error', - { - patterns: [ - { - group: ['@typescript-eslint/*'], - message: - '@typescript-eslint is not included in dependencies. Only type-import is allowed.', - allowTypeImports: true - } - ] - } - ], - 'no-restricted-properties': [ - 'error', - { object: 'context', property: 'getSourceCode', message: 'Use src/utils/compat.ts' }, - { object: 'context', property: 'getFilename', message: 'Use src/utils/compat.ts' }, - { - object: 'context', - property: 'getPhysicalFilename', - message: 'Use src/utils/compat.ts' - }, - { object: 'context', property: 'getCwd', message: 'Use src/utils/compat.ts' }, - { object: 'context', property: 'getScope', message: 'Use src/utils/compat.ts' }, - { object: 'context', property: 'parserServices', message: 'Use src/utils/compat.ts' } - ] - } - }, - { - files: ['src/rules/**'], - rules: {} - }, - { - files: ['tests/**'], - rules: { - '@typescript-eslint/no-misused-promises': 'off' - } - }, - { - files: ['scripts/**/*.ts', 'tests/**/*.ts'], - parser: '@typescript-eslint/parser', - parserOptions: { - sourceType: 'module', - project: require.resolve('./tsconfig.json') - }, - rules: { - 'no-console': 'off' - } - } - ] -}; diff --git a/.github/workflows/GHPages.yml b/.github/workflows/GHPages.yml index ff1339641..30ccd714c 100644 --- a/.github/workflows/GHPages.yml +++ b/.github/workflows/GHPages.yml @@ -35,11 +35,11 @@ jobs: export NODE_OPTIONS="--max-old-space-size=8192" pnpm run docs:build - name: Setup Pages - uses: actions/configure-pages@v3 + uses: actions/configure-pages@v5 - name: Upload artifact - uses: actions/upload-pages-artifact@v2 + uses: actions/upload-pages-artifact@v3 with: path: ./build/eslint-plugin-svelte - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/NodeCI.yml b/.github/workflows/NodeCI.yml index c27cf13bc..206d2d01b 100644 --- a/.github/workflows/NodeCI.yml +++ b/.github/workflows/NodeCI.yml @@ -34,13 +34,13 @@ jobs: pnpm run update pnpm run build test: - name: 'Test for ESLint ${{ matrix.eslint }} on ${{ matrix.node }} OS: ${{matrix.os}}' + name: 'Test for ESLint ${{ matrix.eslint }} on Node.js: ${{ matrix.node }} OS: ${{matrix.os}}' runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest] - eslint: [7, 8] - node: [16, 17, 18, 20] + eslint: [7, 8, 9] + node: [20] steps: - name: Checkout uses: actions/checkout@v4 @@ -53,7 +53,43 @@ jobs: run: |+ pnpm install -D eslint@${{ matrix.eslint }} rm -rf node_modules - if: matrix.eslint != 8 + if: matrix.eslint != 9 + - name: Install Packages + run: pnpm install + - name: Test + run: pnpm run test + test-for-svelte-v4: + name: 'Test for Svelte v4 on Node.js: ${{ matrix.node }} OS: ${{matrix.os}}' + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + eslint: [9] + node: [18, 20] + include: + # On old Node.js version + - eslint: 8 + node: 16 + os: ubuntu-latest + - eslint: 8 + node: 17 + os: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: pnpm/action-setup@v2 + - name: Setup Node.js ${{ matrix.node }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + - name: Install svelte@4 + run: |+ + pnpm install -D svelte@4 + rm -rf node_modules + - name: Install ESLint ${{ matrix.eslint }} + run: |+ + pnpm install -D eslint@${{ matrix.eslint }} + rm -rf node_modules - name: Install Packages run: pnpm install - name: Test @@ -79,7 +115,7 @@ jobs: rm -rf node_modules - name: Install svelte@3 run: |+ - pnpm install -D svelte@3 @typescript-eslint/parser@5 @typescript-eslint/eslint-plugin@5 + pnpm install -D svelte@3 @typescript-eslint/parser@5 @typescript-eslint/eslint-plugin@5 eslint@8 rm -rf node_modules - name: Install Packages run: pnpm install diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..84140fb47 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,33 @@ +name: 👔 Format + +on: + workflow_dispatch: null + +permissions: + contents: write + +jobs: + format: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v2 + - uses: actions/setup-node@v4 + - name: Install deps + run: pnpm install -f + - name: Format + run: pnpm run lint-fix + - name: Commit + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + + git add . + if [ -z "$(git status --porcelain)" ]; then + echo "no formatting changed" + exit 0 + fi + git commit -m "chore: format" + git push + echo "pushed formatting changes https://github.com/$GITHUB_REPOSITORY/commit/$(git rev-parse HEAD)" diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index cc27349d2..7dafd679f 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -13,7 +13,7 @@ jobs: name: Close stale issues with missing information runs-on: ubuntu-latest steps: - - uses: actions/stale@v8 + - uses: actions/stale@v9 with: any-of-labels: 'needs repro,needs info,needs more info' days-before-stale: 60 diff --git a/.vscode/settings.json b/.vscode/settings.json index bfa69db54..9c214fd5a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,8 +3,9 @@ "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.codeActionsOnSave": { - "source.fixAll": true, - "source.fixAll.stylelint": true + "source.fixAll": "explicit", + "source.fixAll.stylelint": "explicit" }, - "svelte.plugin.typescript.diagnostics.enable": false + "svelte.plugin.typescript.diagnostics.enable": false, + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 50feddb5b..421bb6122 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,142 @@ # eslint-plugin-svelte +## 2.38.0 + +### Minor Changes + +- [#741](https://github.com/sveltejs/eslint-plugin-svelte/pull/741) [`33626a3`](https://github.com/sveltejs/eslint-plugin-svelte/commit/33626a3444cc6bd5a1789b0043ea5799b81711d1) Thanks [@baseballyama](https://github.com/baseballyama)! - Use the latest Svelte 5 + +## 2.37.0 + +### Minor Changes + +- [#735](https://github.com/sveltejs/eslint-plugin-svelte/pull/735) [`33f0de2`](https://github.com/sveltejs/eslint-plugin-svelte/commit/33f0de261636e0dca77ec0479fa93a988e6ca950) Thanks [@xiBread](https://github.com/xiBread)! - feat: add rule types + +## 2.36.0 + +### Minor Changes + +- Add experimental support for Svelte v5 + - [#622](https://github.com/sveltejs/eslint-plugin-svelte/pull/622) [`470ef6c`](https://github.com/sveltejs/eslint-plugin-svelte/commit/470ef6cd1ef4767528ff15b5fbdfec1740a5ec02) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: add support for `{@snippet}`and `{@render}` in indent rule + - [#620](https://github.com/sveltejs/eslint-plugin-svelte/pull/620) [`1097107`](https://github.com/sveltejs/eslint-plugin-svelte/commit/1097107afce00fd8b959261b015a4eb1f39f116d) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: (experimental) partial support for Svelte v5 + - [#624](https://github.com/sveltejs/eslint-plugin-svelte/pull/624) [`7df5b6f`](https://github.com/sveltejs/eslint-plugin-svelte/commit/7df5b6f0963f1fb8fc9256f8ed6f034e5f7fbf3d) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: add support for `{@snippet}` and `{@render}` in mustache-spacing rule + - Update parser and svelte(v5) + - [#657](https://github.com/sveltejs/eslint-plugin-svelte/pull/657) [`b159b46`](https://github.com/sveltejs/eslint-plugin-svelte/commit/b159b467427aab17c74246f9b89283aa966bb2e4) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: update svelte to v5.0.0-next.33 + - [#704](https://github.com/sveltejs/eslint-plugin-svelte/pull/704) [`af2ccf9`](https://github.com/sveltejs/eslint-plugin-svelte/commit/af2ccf9f85af00221f9ec10efbc770cba5615a62) Thanks [@ota-meshi](https://github.com/ota-meshi)! - Update svelte-eslint-parser + - [#693](https://github.com/sveltejs/eslint-plugin-svelte/pull/693) [`b11ff34`](https://github.com/sveltejs/eslint-plugin-svelte/commit/b11ff34de949f778d9344ec1143d1a636864d95b) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: update dependencies & some fixes + - [#628](https://github.com/sveltejs/eslint-plugin-svelte/pull/628) [`85fc8f4`](https://github.com/sveltejs/eslint-plugin-svelte/commit/85fc8f467bd9c69475b2ef46fae7bfdd7360158f) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: update parser and fix some tests + - [#696](https://github.com/sveltejs/eslint-plugin-svelte/pull/696) [`d4303f5`](https://github.com/sveltejs/eslint-plugin-svelte/commit/d4303f5347dae7828e08e699741a276ee35dbd43) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: update svelte-eslint-parser + - [#635](https://github.com/sveltejs/eslint-plugin-svelte/pull/635) [`ec3f1cf`](https://github.com/sveltejs/eslint-plugin-svelte/commit/ec3f1cf5ab1726e2a8b79225c231159333474c71) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: update svelte to v5.0.0-next.16 + - [#687](https://github.com/sveltejs/eslint-plugin-svelte/pull/687) [`2943021`](https://github.com/sveltejs/eslint-plugin-svelte/commit/29430210e25cbe417ba28d65d7bf1b07ed4e08e3) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: update parser +- Support for ESLint v9 + - [#673](https://github.com/sveltejs/eslint-plugin-svelte/pull/673) [`b72b97b`](https://github.com/sveltejs/eslint-plugin-svelte/commit/b72b97ba617ff5eeb9b6f4e600c511250c19a72b) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: add support for eslint v9 + - [#708](https://github.com/sveltejs/eslint-plugin-svelte/pull/708) [`d597a69`](https://github.com/sveltejs/eslint-plugin-svelte/commit/d597a69637d95f6be13eaa10a7cc6feebd812e23) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: add support for flat config + - [#719](https://github.com/sveltejs/eslint-plugin-svelte/pull/719) [`eaf5e6a`](https://github.com/sveltejs/eslint-plugin-svelte/commit/eaf5e6af1edab5a4d565b74be6bcc02c71c13ac6) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: suppress comment not working in flat config. + - [#711](https://github.com/sveltejs/eslint-plugin-svelte/pull/711) [`aaba61f`](https://github.com/sveltejs/eslint-plugin-svelte/commit/aaba61f1d7f8337e690659e396d52453b3cc0002) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: flat config would cause an error with non-svelte files +- [#690](https://github.com/sveltejs/eslint-plugin-svelte/pull/690) [`e84397d`](https://github.com/sveltejs/eslint-plugin-svelte/commit/e84397dd71300fc5e4200e9e6c807a3e5f901e23) Thanks [@sdarnell](https://github.com/sdarnell)! - Added prefer option to prefer-class-directive rule ('always' or 'empty'). The default is now 'empty' which is a slight relaxation of the rule. +- [#679](https://github.com/sveltejs/eslint-plugin-svelte/pull/679) [`4e6c681`](https://github.com/sveltejs/eslint-plugin-svelte/commit/4e6c6817681b81bd546b032d7b1ff9a6a6e1935a) Thanks [@marekdedic](https://github.com/marekdedic)! - feat: added the no-goto-without-base rule + +### Patch Changes + +- [#694](https://github.com/sveltejs/eslint-plugin-svelte/pull/694) [`73d6fd8`](https://github.com/sveltejs/eslint-plugin-svelte/commit/73d6fd832d88af44feb9a8b86826e138d47251de) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: style report location +- [#670](https://github.com/sveltejs/eslint-plugin-svelte/pull/670) [`6121a56`](https://github.com/sveltejs/eslint-plugin-svelte/commit/6121a562f8a6d34bb338a5a2df373032abe514d6) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update dependency eslint-compat-utils to ^0.3.0 + +## 2.36.0-next.13 + +### Patch Changes + +- [#719](https://github.com/sveltejs/eslint-plugin-svelte/pull/719) [`eaf5e6a`](https://github.com/sveltejs/eslint-plugin-svelte/commit/eaf5e6af1edab5a4d565b74be6bcc02c71c13ac6) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: suppress comment not working in flat config. + +## 2.36.0-next.12 + +### Patch Changes + +- [#711](https://github.com/sveltejs/eslint-plugin-svelte/pull/711) [`aaba61f`](https://github.com/sveltejs/eslint-plugin-svelte/commit/aaba61f1d7f8337e690659e396d52453b3cc0002) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: flat config would cause an error with non-svelte files + +## 2.36.0-next.11 + +### Minor Changes + +- [#708](https://github.com/sveltejs/eslint-plugin-svelte/pull/708) [`d597a69`](https://github.com/sveltejs/eslint-plugin-svelte/commit/d597a69637d95f6be13eaa10a7cc6feebd812e23) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: add support for flat config + +## 2.36.0-next.10 + +### Patch Changes + +- [#704](https://github.com/sveltejs/eslint-plugin-svelte/pull/704) [`af2ccf9`](https://github.com/sveltejs/eslint-plugin-svelte/commit/af2ccf9f85af00221f9ec10efbc770cba5615a62) Thanks [@ota-meshi](https://github.com/ota-meshi)! - Update svelte-eslint-parser + +## 2.36.0-next.9 + +### Minor Changes + +- [#679](https://github.com/sveltejs/eslint-plugin-svelte/pull/679) [`4e6c681`](https://github.com/sveltejs/eslint-plugin-svelte/commit/4e6c6817681b81bd546b032d7b1ff9a6a6e1935a) Thanks [@marekdedic](https://github.com/marekdedic)! - feat: added the no-goto-without-base rule + +### Patch Changes + +- [#696](https://github.com/sveltejs/eslint-plugin-svelte/pull/696) [`d4303f5`](https://github.com/sveltejs/eslint-plugin-svelte/commit/d4303f5347dae7828e08e699741a276ee35dbd43) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: update svelte-eslint-parser + +## 2.36.0-next.8 + +### Patch Changes + +- [#694](https://github.com/sveltejs/eslint-plugin-svelte/pull/694) [`73d6fd8`](https://github.com/sveltejs/eslint-plugin-svelte/commit/73d6fd832d88af44feb9a8b86826e138d47251de) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: style report location + +## 2.36.0-next.7 + +### Minor Changes + +- [#690](https://github.com/sveltejs/eslint-plugin-svelte/pull/690) [`e84397d`](https://github.com/sveltejs/eslint-plugin-svelte/commit/e84397dd71300fc5e4200e9e6c807a3e5f901e23) Thanks [@sdarnell](https://github.com/sdarnell)! - Added prefer option to prefer-class-directive rule ('always' or 'empty'). The default is now 'empty' which is a slight relaxation of the rule. + +### Patch Changes + +- [#693](https://github.com/sveltejs/eslint-plugin-svelte/pull/693) [`b11ff34`](https://github.com/sveltejs/eslint-plugin-svelte/commit/b11ff34de949f778d9344ec1143d1a636864d95b) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: update dependencies & some fixes + +## 2.36.0-next.6 + +### Patch Changes + +- [#687](https://github.com/sveltejs/eslint-plugin-svelte/pull/687) [`2943021`](https://github.com/sveltejs/eslint-plugin-svelte/commit/29430210e25cbe417ba28d65d7bf1b07ed4e08e3) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: update parser + +## 2.36.0-next.5 + +### Patch Changes + +- [#670](https://github.com/sveltejs/eslint-plugin-svelte/pull/670) [`6121a56`](https://github.com/sveltejs/eslint-plugin-svelte/commit/6121a562f8a6d34bb338a5a2df373032abe514d6) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update dependency eslint-compat-utils to ^0.3.0 + +- [#673](https://github.com/sveltejs/eslint-plugin-svelte/pull/673) [`b72b97b`](https://github.com/sveltejs/eslint-plugin-svelte/commit/b72b97ba617ff5eeb9b6f4e600c511250c19a72b) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: add support for eslint v9 + +## 2.36.0-next.4 + +### Patch Changes + +- [#657](https://github.com/sveltejs/eslint-plugin-svelte/pull/657) [`b159b46`](https://github.com/sveltejs/eslint-plugin-svelte/commit/b159b467427aab17c74246f9b89283aa966bb2e4) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: update svelte to v5.0.0-next.33 + +## 2.36.0-next.3 + +### Patch Changes + +- [#635](https://github.com/sveltejs/eslint-plugin-svelte/pull/635) [`ec3f1cf`](https://github.com/sveltejs/eslint-plugin-svelte/commit/ec3f1cf5ab1726e2a8b79225c231159333474c71) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: update svelte to v5.0.0-next.16 + +## 2.36.0-next.2 + +### Patch Changes + +- [#628](https://github.com/sveltejs/eslint-plugin-svelte/pull/628) [`85fc8f4`](https://github.com/sveltejs/eslint-plugin-svelte/commit/85fc8f467bd9c69475b2ef46fae7bfdd7360158f) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: update parser and fix some tests + +## 2.36.0-next.1 + +### Minor Changes + +- [#622](https://github.com/sveltejs/eslint-plugin-svelte/pull/622) [`470ef6c`](https://github.com/sveltejs/eslint-plugin-svelte/commit/470ef6cd1ef4767528ff15b5fbdfec1740a5ec02) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: add support for `{@snippet}`and `{@render}` in indent rule + +- [#624](https://github.com/sveltejs/eslint-plugin-svelte/pull/624) [`7df5b6f`](https://github.com/sveltejs/eslint-plugin-svelte/commit/7df5b6f0963f1fb8fc9256f8ed6f034e5f7fbf3d) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: add support for `{@snippet}` and `{@render}` in mustache-spacing rule + +## 2.36.0-next.0 + +### Minor Changes + +- [#620](https://github.com/sveltejs/eslint-plugin-svelte/pull/620) [`1097107`](https://github.com/sveltejs/eslint-plugin-svelte/commit/1097107afce00fd8b959261b015a4eb1f39f116d) Thanks [@ota-meshi](https://github.com/ota-meshi)! - feat: (experimental) partial support for Svelte v5 + ## 2.35.1 ### Patch Changes diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 95a30132f..4c273bea6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,28 +7,28 @@ Thanks for contributing! ```sh git clone https://github.com/sveltejs/eslint-plugin-svelte.git cd eslint-plugin-svelte -yarn +pnpm install ``` ## Running the tests ```sh -yarn test +pnpm run test ``` -To run the tests with debugging log, you can use `yarn test:debug`. +To run the tests with debugging log, you can use `pnpm run test:debug`. This is an [ESLint](http://eslint.org) plugin. Documentation for the APIs that it uses can be found on ESLint's [Working with Plugins](http://eslint.org/docs/developer-guide/working-with-plugins) page. -This plugin is used to lint itself. The style is checked when `yarn lint` is run, and the build will fail if there are any linting errors. You can use `yarn lint-fix` to fix some linting errors. +This plugin is used to lint itself. The style is checked when `pnpm run lint` is run, and the build will fail if there are any linting errors. You can use `pnpm run lint-fix` to fix some linting errors. ## Other Development Tools -- `yarn test` runs tests. -- `yarn cover` runs tests and measures coverage. -- `yarn new [new-rule-name]` generate the files needed to implement the new rule. -- `yarn update` runs in order to update readme and recommended configuration. -- `yarn docs:watch` launch the document site in development mode. +- `pnpm run test` runs tests. +- `pnpm run cover` runs tests and measures coverage. +- `pnpm run new -- [new-rule-name]` generate the files needed to implement the new rule. +- `pnpm run update` runs in order to update readme and recommended configuration. +- `pnpm run docs:watch` launch the document site in development mode. ## Test the Rule @@ -52,7 +52,7 @@ To verify the output of invalid test cases requires `*-errors.json`, and `*-outp If you want to test only one rule, run the following command (for `indent` rule): ```sh -yarn test -g indent +pnpm run test -- -g indent ``` Take as reference for details. diff --git a/README.md b/README.md index 151fad7a0..435777a47 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ It provides many unique check rules by using the template AST. You can check on the [Online DEMO](https://sveltejs.github.io/eslint-plugin-svelte/playground/). +**_We are working on experimental support for Svelte v5, but may break with new versions of Svelte v5._** + [![NPM license](https://img.shields.io/npm/l/eslint-plugin-svelte.svg)](https://www.npmjs.com/package/eslint-plugin-svelte) [![NPM version](https://img.shields.io/npm/v/eslint-plugin-svelte.svg)](https://www.npmjs.com/package/eslint-plugin-svelte) [![NPM downloads](https://img.shields.io/badge/dynamic/json.svg?label=downloads&colorB=green&suffix=/day&query=$.downloads&uri=https://api.npmjs.org//downloads/point/last-day/eslint-plugin-svelte&maxAge=3600)](http://www.npmtrends.com/eslint-plugin-svelte) @@ -25,11 +27,17 @@ It provides many unique check rules using the AST generated by [svelte-eslint-pa ### ❗ Attention +#### Cannot be used with eslint-plugin-svelte3 + The [svelte-eslint-parser] and the `eslint-plugin-svelte` can not be used with the [eslint-plugin-svelte3]. [svelte-eslint-parser]: https://github.com/sveltejs/svelte-eslint-parser [eslint-plugin-svelte3]: https://github.com/sveltejs/eslint-plugin-svelte3 +#### Experimental support for Svelte v5 + +We are working on support for Svelte v5, but it is still an experimental feature. Please note that rules and features related to Svelte v5 may be changed or removed in minor versions without notice. + ## Migration Guide @@ -60,6 +68,38 @@ npm install --save-dev eslint eslint-plugin-svelte svelte ### Configuration +#### New Config (`eslint.config.js`) + +Use `eslint.config.js` file to configure rules. See also: . + +Example **eslint.config.js**: + +```js +import eslintPluginSvelte from 'eslint-plugin-svelte'; +export default [ + // add more generic rule sets here, such as: + // js.configs.recommended, + ...eslintPluginSvelte.configs['flat/recommended'], + { + rules: { + // override/add rules settings here, such as: + // 'svelte/rule-name': 'error' + } + } +]; +``` + +This plugin provides configs: + +- `eslintPluginSvelte.configs['flat/base']` ... Configuration to enable correct Svelte parsing. +- `eslintPluginSvelte.configs['flat/recommended']` ... Above, plus rules to prevent errors or unintended behavior. +- `eslintPluginSvelte.configs['flat/prettier']` ... Turns off rules that may conflict with [Prettier](https://prettier.io/) (You still need to configure prettier to work with svelte yourself, for example by using [prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte).). +- `eslintPluginSvelte.configs['flat/all']` ... All rules. This configuration is not recommended for production use because it changes with every minor and major version of `eslint-plugin-svelte`. Use it at your own risk. + +See [the rule list](https://sveltejs.github.io/eslint-plugin-svelte/rules/) to get the `rules` that this plugin provides. + +#### Legacy Config (`.eslintrc`) + Use `.eslintrc.*` file to configure rules. See also: . Example **.eslintrc.js**: @@ -388,6 +428,14 @@ These rules extend the rules provided by ESLint itself, or other plugins to work | [svelte/no-inner-declarations](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-inner-declarations/) | disallow variable or `function` declarations in nested blocks | :star: | | [svelte/no-trailing-spaces](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-trailing-spaces/) | disallow trailing whitespace at the end of lines | :wrench: | +## SvelteKit + +These rules relate to SvelteKit and its best Practices. + +| Rule ID | Description | | +|:--------|:------------|:---| +| [svelte/no-goto-without-base](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-goto-without-base/) | disallow using goto() without the base path | | + ## Experimental :warning: These rules are considered experimental and may change or be removed in the future: diff --git a/docs-svelte-kit/.eslintrc.cjs b/docs-svelte-kit/.eslintrc.cjs deleted file mode 100644 index 250d5fa92..000000000 --- a/docs-svelte-kit/.eslintrc.cjs +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = { - extends: ['plugin:@ota-meshi/+svelte'], - env: { - browser: true, - es2022: true - }, - parserOptions: { - sourceType: 'module' - }, - rules: { - 'svelte/no-target-blank': 'error', - 'svelte/button-has-type': 'error', - 'n/file-extension-in-import': 'off' - } -}; diff --git a/docs-svelte-kit/build-system/build.mts b/docs-svelte-kit/build-system/build.mts index 51f8858b8..e13936dbb 100644 --- a/docs-svelte-kit/build-system/build.mts +++ b/docs-svelte-kit/build-system/build.mts @@ -2,20 +2,9 @@ import esbuild from 'esbuild'; import path from 'path'; import fs from 'fs'; import { fileURLToPath } from 'url'; -// const babelCore = require("@babel/core") -// const t = require("@babel/types") -const dirname = path.dirname( - fileURLToPath( - // @ts-expect-error -- Cannot change `module` option - import.meta.url - ) -); +const dirname = path.dirname(fileURLToPath(import.meta.url)); -build(path.join(dirname, './src/eslint.mjs'), path.join(dirname, '../shim/eslint.mjs'), [ - 'assert', - 'util' -]); build(path.join(dirname, '../../node_modules/assert'), path.join(dirname, '../shim/assert.mjs')); /** build */ diff --git a/docs-svelte-kit/build-system/src/eslint.mjs b/docs-svelte-kit/build-system/src/eslint.mjs deleted file mode 100644 index e07acde73..000000000 --- a/docs-svelte-kit/build-system/src/eslint.mjs +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint require-jsdoc:0 -- shim */ - -import * as all from '../../../node_modules/eslint/lib/linter/linter.js'; -const Linter = all.Linter; -export { Linter }; -export default { Linter }; diff --git a/docs-svelte-kit/shim/fs.mjs b/docs-svelte-kit/shim/fs.mjs index ce1d4d8a4..78a71c8db 100644 --- a/docs-svelte-kit/shim/fs.mjs +++ b/docs-svelte-kit/shim/fs.mjs @@ -1,4 +1,3 @@ -/* eslint require-jsdoc:0 -- shim */ function existsSync() { return false; } diff --git a/docs-svelte-kit/shim/globby.mjs b/docs-svelte-kit/shim/globby.mjs index 6fc39b8af..670c5431e 100644 --- a/docs-svelte-kit/shim/globby.mjs +++ b/docs-svelte-kit/shim/globby.mjs @@ -1,4 +1,2 @@ -/* eslint require-jsdoc:0 -- shim */ - export {}; export default {}; diff --git a/docs-svelte-kit/shim/module.mjs b/docs-svelte-kit/shim/module.mjs index e55b853cf..9981ca9db 100644 --- a/docs-svelte-kit/shim/module.mjs +++ b/docs-svelte-kit/shim/module.mjs @@ -1,4 +1,3 @@ -/* eslint require-jsdoc:0 -- shim */ function _createRequire() { return () => null; } diff --git a/docs-svelte-kit/shim/os.mjs b/docs-svelte-kit/shim/os.mjs index 95f24ca2b..535c3e75f 100644 --- a/docs-svelte-kit/shim/os.mjs +++ b/docs-svelte-kit/shim/os.mjs @@ -1,4 +1,3 @@ -/* eslint require-jsdoc:0 -- shim */ function platform() { return ''; } diff --git a/docs-svelte-kit/shim/path.mjs b/docs-svelte-kit/shim/path.mjs deleted file mode 100644 index 63e3abc27..000000000 --- a/docs-svelte-kit/shim/path.mjs +++ /dev/null @@ -1,63 +0,0 @@ -/* eslint require-jsdoc:0 -- shim */ - -function dirname(p) { - return p.split('/').slice(0, -1).join('/') || p; -} - -function extname(p) { - return /\.[\w$-]+$/iu.exec(p)[0]; -} - -function basename(p, ext) { - const nm = p.split('/').slice(-1)[0]; - if (!ext) { - return nm; - } - return nm.endsWith(ext) ? nm.slice(0, -ext.length) : nm; -} - -function relative(s) { - return s; -} - -function resolve(s) { - return s; -} - -function isAbsolute() { - return false; -} - -function join(...args) { - return args.length ? normalize(args.join('/')) : '.'; -} - -function normalize(path) { - let result = []; - for (const part of path.replace(/\/+/gu, '/').split('/')) { - if (part === '..') { - if (result[0] && result[0] !== '..' && result[0] !== '.') result.shift(); - } else if (part === '.' && result.length) { - // noop - } else { - result.unshift(part); - } - } - return result.reverse().join('/'); -} - -const sep = '/'; -const posix = { - dirname, - extname, - resolve, - relative, - sep, - isAbsolute, - join, - normalize, - basename -}; -posix.posix = posix; -export { dirname, extname, posix, resolve, relative, sep, isAbsolute, join, normalize, basename }; -export default posix; diff --git a/docs-svelte-kit/shim/picocolors.mjs b/docs-svelte-kit/shim/picocolors.mjs new file mode 100644 index 000000000..0547d6950 --- /dev/null +++ b/docs-svelte-kit/shim/picocolors.mjs @@ -0,0 +1,4 @@ +export function createColors() { + return {}; +} +export default { createColors }; diff --git a/docs-svelte-kit/shim/postcss-load-config.mjs b/docs-svelte-kit/shim/postcss-load-config.mjs index bd4450887..a03070451 100644 --- a/docs-svelte-kit/shim/postcss-load-config.mjs +++ b/docs-svelte-kit/shim/postcss-load-config.mjs @@ -1,4 +1,3 @@ -/* eslint require-jsdoc:0 -- shim */ import nested from 'postcss-nested'; function loadConfig() { diff --git a/docs-svelte-kit/shim/url.mjs b/docs-svelte-kit/shim/url.mjs index 00921bad0..ba848d8bd 100644 --- a/docs-svelte-kit/shim/url.mjs +++ b/docs-svelte-kit/shim/url.mjs @@ -1,4 +1,3 @@ -/* eslint require-jsdoc:0 -- shim */ function fileURLToPath(p) { return p; } diff --git a/docs-svelte-kit/src/.eslintrc.js b/docs-svelte-kit/src/.eslintrc.js deleted file mode 100644 index af7e60f6a..000000000 --- a/docs-svelte-kit/src/.eslintrc.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - parserOptions: { - sourceType: 'module' - }, - rules: { - 'n/no-unsupported-features/es-syntax': 'off', - 'require-jsdoc': 'off', - 'n/no-missing-import': 'off' - } -}; diff --git a/docs-svelte-kit/src/lib/components/ESLintCodeBlock.svelte b/docs-svelte-kit/src/lib/components/ESLintCodeBlock.svelte index 30e742a3e..393070fc5 100644 --- a/docs-svelte-kit/src/lib/components/ESLintCodeBlock.svelte +++ b/docs-svelte-kit/src/lib/components/ESLintCodeBlock.svelte @@ -1,12 +1,13 @@ diff --git a/docs-svelte-kit/src/lib/utils.js b/docs-svelte-kit/src/lib/utils.js index 8ef89992b..ce28beab4 100644 --- a/docs-svelte-kit/src/lib/utils.js +++ b/docs-svelte-kit/src/lib/utils.js @@ -18,6 +18,7 @@ const categories = [ 'Best Practices', 'Stylistic Issues', 'Extension Rules', + 'SvelteKit', 'Experimental', 'System' ]; diff --git a/docs-svelte-kit/src/routes/+layout.svelte b/docs-svelte-kit/src/routes/+layout.svelte index e13f7291a..00b5bcda1 100644 --- a/docs-svelte-kit/src/routes/+layout.svelte +++ b/docs-svelte-kit/src/routes/+layout.svelte @@ -29,7 +29,7 @@ -
+
diff --git a/docs-svelte-kit/tools/vite-plugin-svelte-md-option.mts b/docs-svelte-kit/tools/vite-plugin-svelte-md-option.mts index 753ee6308..52dab990a 100644 --- a/docs-svelte-kit/tools/vite-plugin-svelte-md-option.mts +++ b/docs-svelte-kit/tools/vite-plugin-svelte-md-option.mts @@ -1,6 +1,7 @@ import highlight from './highlight.mjs'; import replaceLinkPlugin from './markdown-it-replace-link.mjs'; -import emojiPlugin from 'markdown-it-emoji'; +// @ts-expect-error missing types +import { full as emojiPlugin } from 'markdown-it-emoji'; import anchorPlugin from 'markdown-it-anchor'; import containerPlugin from 'markdown-it-container'; import autoInjectComponentsPlugin from './markdown-it-auto-inject-components.mjs'; diff --git a/docs/.eslintrc.js b/docs/.eslintrc.js deleted file mode 100644 index 598b8931c..000000000 --- a/docs/.eslintrc.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict" - -module.exports = { - extends: ["plugin:svelte/recommended"], - rules: { - "eslint-comments/require-description": "off", - "prettier/prettier": "off", - "require-jsdoc": "off", - }, -} diff --git a/docs/README.md b/docs/README.md index b7aa3bfee..f93bd38e6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -8,6 +8,8 @@ title: 'eslint-plugin-svelte' It provides many unique check rules by using the template AST. You can check on the [Online DEMO](./playground.md). +**_We are working on experimental support for Svelte v5, but may break with new versions of Svelte v5._** + [![NPM license](https://img.shields.io/npm/l/eslint-plugin-svelte.svg)](https://www.npmjs.com/package/eslint-plugin-svelte) [![NPM version](https://img.shields.io/npm/v/eslint-plugin-svelte.svg)](https://www.npmjs.com/package/eslint-plugin-svelte) [![NPM downloads](https://img.shields.io/badge/dynamic/json.svg?label=downloads&colorB=green&suffix=/day&query=$.downloads&uri=https://api.npmjs.org//downloads/point/last-day/eslint-plugin-svelte&maxAge=3600)](http://www.npmtrends.com/eslint-plugin-svelte) @@ -29,11 +31,17 @@ It provides many unique check rules using the AST generated by [svelte-eslint-pa ### ❗ Attention +#### Cannot be used with eslint-plugin-svelte3 + The [svelte-eslint-parser] and the `eslint-plugin-svelte` can not be used with the [eslint-plugin-svelte3]. [svelte-eslint-parser]: https://github.com/sveltejs/svelte-eslint-parser [eslint-plugin-svelte3]: https://github.com/sveltejs/eslint-plugin-svelte3 +#### Experimental support for Svelte v5 + +We are working on support for Svelte v5, but it is still an experimental feature. Please note that rules and features related to Svelte v5 may be changed or removed in minor versions without notice. + ## :book: Usage See [User Guide](./user-guide.md). diff --git a/docs/rules.md b/docs/rules.md index 257cb4f93..e932ded0a 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -101,6 +101,14 @@ These rules extend the rules provided by ESLint itself, or other plugins to work | [svelte/no-inner-declarations](./rules/no-inner-declarations.md) | disallow variable or `function` declarations in nested blocks | :star: | | [svelte/no-trailing-spaces](./rules/no-trailing-spaces.md) | disallow trailing whitespace at the end of lines | :wrench: | +## SvelteKit + +These rules relate to SvelteKit and its best Practices. + +| Rule ID | Description | | +| :------------------------------------------------------------- | :------------------------------------------ | :-- | +| [svelte/no-goto-without-base](./rules/no-goto-without-base.md) | disallow using goto() without the base path | | + ## Experimental :warning: These rules are considered experimental and may change or be removed in the future: diff --git a/docs/rules/html-self-closing.md b/docs/rules/html-self-closing.md index 15da003e5..ce49ac672 100644 --- a/docs/rules/html-self-closing.md +++ b/docs/rules/html-self-closing.md @@ -71,7 +71,7 @@ config object: "void": "always", // or "never" or "ignore" "normal": "always", // or "never" or "ignore" "component": "always", // or "never" or "ignore" - "svelte": "always" // or "never" or "igore" + "svelte": "always" // or "never" or "ignore" } ] } diff --git a/docs/rules/no-export-load-in-svelte-module-in-kit-pages.md b/docs/rules/no-export-load-in-svelte-module-in-kit-pages.md index 1bd641e69..ea2caadc6 100644 --- a/docs/rules/no-export-load-in-svelte-module-in-kit-pages.md +++ b/docs/rules/no-export-load-in-svelte-module-in-kit-pages.md @@ -50,7 +50,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-svelte-kit). +Nothing. But if you are not using the default routes folder, please set configuration according to the [user guide](../user-guide.md#settings-svelte-kit). ## :books: Further Reading diff --git a/docs/rules/no-goto-without-base.md b/docs/rules/no-goto-without-base.md new file mode 100644 index 000000000..a9ca2b4e8 --- /dev/null +++ b/docs/rules/no-goto-without-base.md @@ -0,0 +1,64 @@ +--- +pageClass: 'rule-details' +sidebarDepth: 0 +title: 'svelte/no-goto-without-base' +description: 'disallow using goto() without the base path' +since: 'v2.36.0-next.9' +--- + +# svelte/no-goto-without-base + +> disallow using goto() without the base path + +## :book: Rule Details + +This rule reports navigation using SvelteKit's `goto()` function without prefixing a relative URL with the base path. If a non-prefixed relative URL is used for navigation, the `goto` function navigates away from the base path, which is usually not what you wanted to do (for external URLs, `window.location = url` should be used instead). + + + + + +```svelte + +``` + + + +## :wrench: Options + +Nothing. + +## :books: Further Reading + +- [`goto()` documentation](https://kit.svelte.dev/docs/modules#$app-navigation-goto) +- [`base` documentation](https://kit.svelte.dev/docs/modules#$app-paths-base) + +## :rocket: Version + +This rule was introduced in eslint-plugin-svelte v2.36.0-next.9 + +## :mag: Implementation + +- [Rule source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/src/rules/no-goto-without-base.ts) +- [Test source](https://github.com/sveltejs/eslint-plugin-svelte/blob/main/tests/src/rules/no-goto-without-base.ts) diff --git a/docs/rules/no-target-blank.md b/docs/rules/no-target-blank.md index 401124a2e..836a4381f 100644 --- a/docs/rules/no-target-blank.md +++ b/docs/rules/no-target-blank.md @@ -12,7 +12,7 @@ since: 'v0.0.4' ## :book: Rule Details -This rule disallows using `target="_blank"` attribute without `rel="noopener noreferrer"` to avoid a security vulnerability([see here for more details](https://mathiasbynens.github.io/rel-noopener/)). +This rule disallows using `target="_blank"` attribute without `rel="noopener noreferrer"` to avoid a security vulnerability in legacy browsers where a page can trigger a navigation in the opener regardless of origin ([see here for more details](https://mathiasbynens.github.io/rel-noopener/)). @@ -46,8 +46,8 @@ This rule disallows using `target="_blank"` attribute without `rel="noopener nor } ``` -- `allowReferrer` ... If `true`, does not require noreferrer.default `false` -- `enforceDynamicLinks ("always" | "never")` ... If `always`, enforces the rule if the href is a dynamic link. default `always`. +- `allowReferrer` ... If `true`, allows the `Referrer` header to be sent by not requiring `noreferrer` to be present. default `false` +- `enforceDynamicLinks ("always" | "never")` ... If `always`, enforces the rule if the href is a dynamic link. default `always` ### `{ allowReferrer: false }` (default) diff --git a/docs/rules/no-useless-mustaches.md b/docs/rules/no-useless-mustaches.md index f879e5e2f..0425122e1 100644 --- a/docs/rules/no-useless-mustaches.md +++ b/docs/rules/no-useless-mustaches.md @@ -81,6 +81,8 @@ Lorem ipsum {foo} + + ```svelte {'Lorem \n ipsum'} diff --git a/docs/rules/prefer-class-directive.md b/docs/rules/prefer-class-directive.md index f026296fa..1841be9e3 100644 --- a/docs/rules/prefer-class-directive.md +++ b/docs/rules/prefer-class-directive.md @@ -22,13 +22,16 @@ This rule aims to replace a class with ternary operator with the class directive ```svelte + + ``` @@ -40,7 +43,20 @@ You cannot enforce this style by using [prettier-plugin-svelte]. That is, this r ## :wrench: Options -Nothing. +```json +{ + "svelte/html-quotes": [ + "error", + { + "prefer": "empty" // or "always" + } + ] +} +``` + +- `prefer` ... Whether to apply this rule always or just when there's an empty string. Default is `"empty"`. + - `"empty"` ... Requires class directives only if one of the strings is empty. + - `"always"` ... Requires class directives always rather than interpolation. ## :couple: Related Rules diff --git a/docs/user-guide.md b/docs/user-guide.md index ab76c64a9..0a48c998c 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -19,6 +19,38 @@ npm install --save-dev eslint eslint-plugin-svelte svelte ### Configuration +#### New Config (`eslint.config.js`) + +Use `eslint.config.js` file to configure rules. See also: . + +Example **eslint.config.js**: + +```js +import eslintPluginSvelte from 'eslint-plugin-svelte'; +export default [ + // add more generic rule sets here, such as: + // js.configs.recommended, + ...eslintPluginSvelte.configs['flat/recommended'], + { + rules: { + // override/add rules settings here, such as: + // 'svelte/rule-name': 'error' + } + } +]; +``` + +This plugin provides configs: + +- `eslintPluginSvelte.configs['flat/base']` ... Configuration to enable correct Svelte parsing. +- `eslintPluginSvelte.configs['flat/recommended']` ... Above, plus rules to prevent errors or unintended behavior. +- `eslintPluginSvelte.configs['flat/prettier']` ... Turns off rules that may conflict with [Prettier](https://prettier.io/) (You still need to configure prettier to work with svelte yourself, for example by using [prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte).). +- `eslintPluginSvelte.configs['flat/all']` ... All rules. This configuration is not recommended for production use because it changes with every minor and major version of `eslint-plugin-svelte`. Use it at your own risk. + +See [the rule list](./rules.md) to get the `rules` that this plugin provides. + +#### Legacy Config (`.eslintrc`) + Use `.eslintrc.*` file to configure rules. See also: . Example **.eslintrc.js**: diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..8b3acb10c --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,195 @@ +import * as myPlugin from '@ota-meshi/eslint-plugin'; +import * as tseslint from 'typescript-eslint'; +import * as svelte from 'eslint-plugin-svelte'; +import globals from 'globals'; + +/** + * @type {import('eslint').Linter.FlatConfig[]} + */ +const config = [ + { + ignores: [ + '.nyc_output/', + 'coverage/', + 'lib/', + 'node_modules/', + '!.vscode/', + '!.github/', + '!.devcontainer/', + 'prettier-playground/', + 'tests/fixtures/rules/indent/invalid/ts/', + 'tests/fixtures/rules/indent/invalid/ts-v5/', + 'tests/fixtures/rules/indent/invalid/snippets01-input.svelte', + 'tests/fixtures/rules/indent/valid/', + 'tests/fixtures/rules/no-unused-class-name/valid/invalid-style01-input.svelte', + 'tests/fixtures/rules/no-unused-class-name/valid/unknown-lang01-input.svelte', + 'tests/fixtures/rules/valid-compile/invalid/ts/', + 'tests/fixtures/rules/valid-compile/valid/babel/', + 'tests/fixtures/rules/valid-compile/valid/ts/', + 'tests/fixtures/rules/prefer-style-directive/', + 'tests/fixtures/rules/@typescript-eslint/', + 'tests/fixtures/rules/valid-compile/valid/svelte3-options-custom-element-input.svelte', + 'tests/fixtures/rules/mustache-spacing/valid/always/snippet-render01-input.svelte', + 'tests/fixtures/rules/mustache-spacing/invalid/snippet-render01-input.svelte', + 'tests/fixtures/rules/valid-prop-names-in-kit-pages/valid/+test-for-form-input.svelte', + '.svelte-kit/', + 'svelte.config-dist.js', + 'build/', + 'docs-svelte-kit/shim/eslint.mjs', + 'docs-svelte-kit/shim/assert.mjs', + '!.*.js', + 'docs-svelte-kit/src/routes/*.md', + 'docs-svelte-kit/src/routes/**/*.md', + 'docs-svelte-kit/src/app.html', + 'src/rule-types.ts', + // JSONSchema bug? + '.devcontainer/devcontainer.json', + // Parser bug? + 'tests/fixtures/rules/indent/invalid/const-tag01-input.svelte', + 'tests/fixtures/rules/indent/invalid/const-tag01-output.svelte' + ] + }, + ...myPlugin.config({ + eslintPlugin: true, + node: true, + ts: true, + json: true, + packageJson: true, + yaml: true, + md: true, + prettier: true, + svelte: { withTs: false } + }), + { + rules: { + 'jsdoc/require-jsdoc': 'off', + '@typescript-eslint/no-shadow': 'off', + 'no-shadow': 'off', + '@typescript-eslint/naming-convention': 'off', + 'new-cap': 'off', + complexity: 'off', + // Repo rule + 'no-restricted-imports': [ + 'error', + { + patterns: [ + { + group: ['/regexpp', '/regexpp/*'], + message: 'Please use `@eslint-community/regexpp` instead.' + }, + { + group: ['/eslint-utils', '/eslint-utils/*'], + message: 'Please use `@eslint-community/eslint-utils` instead.' + } + ] + } + ] + } + }, + { + files: ['src/**'], + rules: { + '@typescript-eslint/no-restricted-imports': [ + 'error', + { + patterns: [ + { + group: ['@typescript-eslint/*'], + message: + '@typescript-eslint is not included in dependencies. Only type-import is allowed.', + allowTypeImports: true + } + ] + } + ], + 'no-restricted-properties': [ + 'error', + { object: 'context', property: 'getSourceCode', message: 'Use src/utils/compat.ts' }, + { object: 'context', property: 'getFilename', message: 'Use src/utils/compat.ts' }, + { + object: 'context', + property: 'getPhysicalFilename', + message: 'Use src/utils/compat.ts' + }, + { object: 'context', property: 'getCwd', message: 'Use src/utils/compat.ts' }, + { object: 'context', property: 'getScope', message: 'Use src/utils/compat.ts' }, + { object: 'context', property: 'parserServices', message: 'Use src/utils/compat.ts' } + ] + } + }, + { + files: ['docs-svelte-kit/**'], + languageOptions: { + sourceType: 'module', + globals: { + ...globals.browser, + require: 'readonly' + } + }, + rules: { + 'n/file-extension-in-import': 'off', + 'n/no-unsupported-features/es-syntax': 'off' + } + }, + { + files: ['docs-svelte-kit/**/*.svelte'], + languageOptions: { + parserOptions: { project: null } + } + }, + ...tseslint.config({ + files: ['tests/fixtures/rules/**'], + extends: [tseslint.configs.disableTypeChecked], + rules: { + 'one-var': 'off', + 'no-unused-vars': 'off', + 'no-undef': 'off', + 'no-empty-function': 'off', + 'no-console': 'off', + 'dot-notation': 'off', + 'no-constant-binary-expression': 'off', + 'func-style': 'off', + 'no-var': 'off', + 'no-unused-expressions': 'off', + 'no-new': 'off', + 'getter-return': 'off', + 'no-sparse-arrays': 'off', + + ...Object.fromEntries( + Object.keys(svelte.rules).map((key) => { + return [`svelte/${key}`, 'off']; + }) + ) + }, + languageOptions: { + sourceType: 'module', + parserOptions: { + project: null + } + } + }), + { + files: [ + 'tests/fixtures/rules/**/*output.*', + 'tests/fixtures/rules/no-unused-svelte-ignore/valid/style-lang07-input.svelte' + ], + rules: { + 'prettier/prettier': 'off' + } + }, + { + files: ['tests/fixtures/rules/**/*errors.yaml'], + rules: { + 'yml/no-tab-indent': 'off' + } + }, + + { + files: ['tests/**'], + rules: { + '@typescript-eslint/no-misused-promises': 'off', + '@typescript-eslint/no-require-imports': 'off' + } + } +]; +export default config; diff --git a/package.json b/package.json index d41a309af..58380d768 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-svelte", - "version": "2.35.1", + "version": "2.38.0", "description": "ESLint plugin for Svelte using AST", "repository": "git+https://github.com/sveltejs/eslint-plugin-svelte.git", "homepage": "https://sveltejs.github.io/eslint-plugin-svelte", @@ -10,10 +10,11 @@ ], "funding": "https://github.com/sponsors/ota-meshi", "license": "MIT", - "packageManager": "pnpm@7.33.6", + "packageManager": "pnpm@7.33.7", "engines": { "node": "^14.17.0 || >=16.0.0" }, + "type": "commonjs", "main": "lib/index.js", "files": [ "lib" @@ -57,8 +58,8 @@ "version:ci": "env-cmd -e version-ci pnpm run update && changeset version" }, "peerDependencies": { - "eslint": "^7.0.0 || ^8.0.0-0", - "svelte": "^3.37.0 || ^4.0.0" + "eslint": "^7.0.0 || ^8.0.0-0 || ^9.0.0-0", + "svelte": "^3.37.0 || ^4.0.0 || ^5.0.0-next.112" }, "peerDependenciesMeta": { "svelte": { @@ -66,113 +67,120 @@ } }, "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@jridgewell/sourcemap-codec": "^1.4.14", - "debug": "^4.3.1", - "eslint-compat-utils": "^0.1.2", + "@eslint-community/eslint-utils": "^4.4.0", + "@jridgewell/sourcemap-codec": "^1.4.15", + "debug": "^4.3.4", + "eslint-compat-utils": "^0.5.0", "esutils": "^2.0.3", - "known-css-properties": "^0.29.0", - "postcss": "^8.4.5", + "known-css-properties": "^0.30.0", + "postcss": "^8.4.38", "postcss-load-config": "^3.1.4", "postcss-safe-parser": "^6.0.0", - "postcss-selector-parser": "^6.0.11", - "semver": "^7.5.3", - "svelte-eslint-parser": ">=0.33.0 <1.0.0" + "postcss-selector-parser": "^6.0.16", + "semver": "^7.6.0", + "svelte-eslint-parser": ">=0.35.0 <1.0.0" }, "devDependencies": { - "@1stg/browserslist-config": "^1.2.3", - "@1stg/stylelint-config": "^5.0.0", - "@babel/core": "^7.16.0", - "@babel/eslint-parser": "^7.17.0", - "@babel/plugin-proposal-function-bind": "^7.16.7", - "@babel/types": "^7.16.0", - "@changesets/changelog-github": "^0.4.6", - "@changesets/cli": "^2.24.2", - "@changesets/get-release-plan": "^3.0.16", - "@fontsource/fira-mono": "^5.0.0", - "@ota-meshi/eslint-plugin": "^0.15.0", - "@sindresorhus/slugify": "^2.1.0", - "@sveltejs/adapter-static": "^2.0.2", - "@sveltejs/kit": "^1.16.3", - "@types/babel__core": "^7.1.19", - "@types/cross-spawn": "^6.0.2", - "@types/escape-html": "^1.0.2", - "@types/eslint": "^8.0.0", - "@types/eslint-scope": "^3.7.0", - "@types/eslint-utils": "^3.0.1", - "@types/eslint-visitor-keys": "^1.0.0", - "@types/esutils": "^2.0.0", - "@types/json-schema": "^7.0.11", - "@types/less": "^3.0.3", - "@types/markdown-it": "^13.0.0", - "@types/markdown-it-container": "^2.0.5", - "@types/markdown-it-emoji": "^2.0.2", - "@types/mocha": "^10.0.0", - "@types/node": "^20.0.0", - "@types/postcss-safe-parser": "^5.0.1", - "@types/prismjs": "^1.26.0", - "@types/semver": "^7.5.0", - "@types/stylus": "^0.48.38", - "@typescript-eslint/eslint-plugin": "^6.9.0", - "@typescript-eslint/parser": "^6.9.0", - "@typescript/vfs": "^1.4.0", - "acorn": "^8.8.2", - "assert": "^2.0.0", + "@1stg/browserslist-config": "^2.0.0", + "@1stg/stylelint-config": "^6.0.0", + "@babel/core": "^7.24.4", + "@babel/eslint-parser": "^7.24.1", + "@babel/plugin-proposal-function-bind": "^7.24.1", + "@babel/types": "^7.24.0", + "@changesets/changelog-github": "^0.5.0", + "@changesets/cli": "^2.27.1", + "@changesets/get-release-plan": "^4.0.0", + "@eslint-community/eslint-plugin-eslint-comments": "4.3.0", + "@fontsource/fira-mono": "^5.0.12", + "@ota-meshi/eslint-plugin": "^0.17.1", + "@sindresorhus/slugify": "^2.2.1", + "@sveltejs/adapter-static": "^3.0.1", + "@sveltejs/kit": "^2.5.6", + "@sveltejs/vite-plugin-svelte": "^3.1.0", + "@types/babel__core": "^7.20.5", + "@types/cross-spawn": "^6.0.6", + "@types/escape-html": "^1.0.4", + "@types/eslint": "^8.56.10", + "@types/eslint-scope": "^3.7.7", + "@types/eslint-utils": "^3.0.5", + "@types/eslint-visitor-keys": "^3.3.0", + "@types/esutils": "^2.0.2", + "@types/json-schema": "^7.0.15", + "@types/less": "^3.0.6", + "@types/markdown-it": "^14.0.1", + "@types/markdown-it-container": "^2.0.10", + "@types/markdown-it-emoji": "^2.0.5", + "@types/mocha": "^10.0.6", + "@types/node": "^20.12.7", + "@types/postcss-safe-parser": "^5.0.4", + "@types/prismjs": "^1.26.3", + "@types/semver": "^7.5.8", + "@types/stylus": "^0.48.42", + "@typescript-eslint/eslint-plugin": "^7.7.0", + "@typescript-eslint/parser": "^7.7.0", + "@typescript/vfs": "^1.5.0", + "acorn": "^8.11.3", + "assert": "^2.1.0", "cross-spawn": "^7.0.3", "env-cmd": "^10.1.0", - "esbuild": "^0.19.0", - "esbuild-register": "^3.2.0", + "esbuild": "^0.20.2", + "esbuild-register": "^3.5.0", "escape-html": "^1.0.3", - "eslint": "^8.40.0", - "eslint-config-prettier": "^9.0.0", + "eslint": "^9.0.0", + "eslint-config-prettier": "^9.1.0", "eslint-formatter-friendly": "^7.0.0", - "eslint-plugin-eslint-comments": "^3.2.0", - "eslint-plugin-eslint-plugin": "^5.0.0", - "eslint-plugin-json-schema-validator": "^4.0.0", - "eslint-plugin-jsonc": "^2.0.0", - "eslint-plugin-markdown": "^3.0.0", - "eslint-plugin-mdx": "^2.0.2", - "eslint-plugin-n": "^16.0.0", - "eslint-plugin-node-dependencies": "^0.11.0", - "eslint-plugin-prettier": "^5.0.0", - "eslint-plugin-regexp": "^2.0.0", - "eslint-plugin-svelte": "^2.28.0", - "eslint-plugin-yml": "^1.0.0", - "eslint-scope": "^7.1.1", - "eslint-visitor-keys": "^3.4.1", - "espree": "^9.5.2", - "estree-walker": "^3.0.0", - "less": "^4.1.2", + "eslint-plugin-eslint-plugin": "^6.0.0", + "eslint-plugin-jsdoc": "^48.2.3", + "eslint-plugin-json-schema-validator": "^5.1.0", + "eslint-plugin-jsonc": "^2.15.1", + "eslint-plugin-markdown": "^4.0.1", + "eslint-plugin-mdx": "^3.1.5", + "eslint-plugin-n": "^17.2.1", + "eslint-plugin-node-dependencies": "^0.12.0", + "eslint-plugin-prettier": "^5.1.3", + "eslint-plugin-regexp": "^2.5.0", + "eslint-plugin-svelte": "^2.37.0", + "eslint-plugin-yml": "^1.14.0", + "eslint-scope": "^8.0.1", + "eslint-typegen": "^0.2.3", + "eslint-visitor-keys": "^4.0.0", + "espree": "^10.0.1", + "estree-walker": "^3.0.3", + "globals": "^15.0.0", + "less": "^4.2.0", "locate-character": "^3.0.0", - "magic-string": "^0.30.0", - "markdown-it-anchor": "^8.4.1", - "markdown-it-container": "^3.0.0", - "markdown-it-emoji": "^2.0.0", - "mocha": "^10.0.0", - "npm-run-all": "^4.1.5", + "magic-string": "^0.30.10", + "markdown-it-anchor": "^8.6.7", + "markdown-it-container": "^4.0.0", + "markdown-it-emoji": "^3.0.0", + "mocha": "^10.4.0", + "npm-run-all2": "^6.1.2", "nyc": "^15.1.0", - "pako": "^2.0.3", - "postcss-nested": "^6.0.0", - "prettier": "^3.0.0", - "prettier-plugin-pkg": "^0.18.0", - "prettier-plugin-svelte": "^3.0.0", + "pako": "^2.1.0", + "postcss-nested": "^6.0.1", + "prettier": "^3.2.5", + "prettier-plugin-pkg": "^0.18.1", + "prettier-plugin-svelte": "^3.2.3", "prism-svelte": "^0.5.0", - "prismjs": "^1.25.0", - "rimraf": "^5.0.0", - "sass": "^1.64.0", - "source-map-js": "^1.0.2", - "stylelint": "^15.0.0", - "stylelint-config-standard": "^34.0.0", - "stylus": "^0.62.0", - "svelte": "^4.0.0", - "svelte-adapter-ghpages": "0.1.0", + "prismjs": "^1.29.0", + "rimraf": "^5.0.5", + "sass": "^1.75.0", + "source-map-js": "^1.2.0", + "stylelint": "~16.3.1", + "stylelint-config-standard": "^36.0.0", + "stylus": "^0.63.0", + "svelte": "^5.0.0-next.112", + "svelte-adapter-ghpages": "0.2.2", "svelte-i18n": "^4.0.0", - "tslib": "^2.5.0", - "type-coverage": "^2.22.0", - "typescript": "~5.1.0", - "vite": "^5.0.0", + "tslib": "^2.6.2", + "type-coverage": "^2.28.1", + "typescript": "~5.4.5", + "typescript-eslint": "^7.7.0", + "util": "^0.12.5", + "vite": "^5.2.9", + "vite-plugin-eslint4b": "^0.4.0", "vite-plugin-svelte-md": "^0.1.7", - "yaml": "^2.1.1" + "yaml": "^2.4.1" }, "publishConfig": { "access": "public" diff --git a/src/configs/flat/all.ts b/src/configs/flat/all.ts new file mode 100644 index 000000000..c2dfe9771 --- /dev/null +++ b/src/configs/flat/all.ts @@ -0,0 +1,18 @@ +import { rules } from '../../utils/rules'; +import base from './base'; +export default [ + ...base, + { + rules: Object.fromEntries( + rules + .map((rule) => [`svelte/${rule.meta.docs.ruleName}`, 'error']) + .filter( + ([ruleName]) => + ![ + // Does not work without options. + 'svelte/no-restricted-html-elements' + ].includes(ruleName) + ) + ) + } +]; diff --git a/src/configs/flat/base.ts b/src/configs/flat/base.ts new file mode 100644 index 000000000..755a52831 --- /dev/null +++ b/src/configs/flat/base.ts @@ -0,0 +1,33 @@ +// IMPORTANT! +// This file has been automatically generated, +// in order to update its content execute "pnpm run update" +import type { ESLint } from 'eslint'; +export default [ + { + plugins: { + get svelte(): ESLint.Plugin { + // eslint-disable-next-line @typescript-eslint/no-require-imports -- ignore + return require('../../index'); + } + } + }, + { + files: ['*.svelte', '**/*.svelte'], + languageOptions: { + // eslint-disable-next-line @typescript-eslint/no-require-imports -- ignore + parser: require('svelte-eslint-parser') + }, + rules: { + // ESLint core rules known to cause problems with `.svelte`. + 'no-inner-declarations': 'off', // The AST generated by svelte-eslint-parser will false positives in it rule because the root node of the script is not the `Program`. + // "no-irregular-whitespace": "off", + // Self assign is one of way to update reactive value in Svelte. + 'no-self-assign': 'off', + + // eslint-plugin-svelte rules + 'svelte/comment-directive': 'error', + 'svelte/system': 'error' + }, + processor: 'svelte/svelte' + } +]; diff --git a/src/configs/flat/prettier.ts b/src/configs/flat/prettier.ts new file mode 100644 index 000000000..5b2b1543b --- /dev/null +++ b/src/configs/flat/prettier.ts @@ -0,0 +1,23 @@ +// IMPORTANT! +// This file has been automatically generated, +// in order to update its content execute "pnpm run update" +import base from './base'; +export default [ + ...base, + { + rules: { + // eslint-plugin-svelte rules + 'svelte/first-attribute-linebreak': 'off', + 'svelte/html-closing-bracket-spacing': 'off', + 'svelte/html-quotes': 'off', + 'svelte/html-self-closing': 'off', + 'svelte/indent': 'off', + 'svelte/max-attributes-per-line': 'off', + 'svelte/mustache-spacing': 'off', + 'svelte/no-spaces-around-equal-signs-in-attribute': 'off', + 'svelte/no-trailing-spaces': 'off', + 'svelte/shorthand-attribute': 'off', + 'svelte/shorthand-directive': 'off' + } + } +]; diff --git a/src/configs/flat/recommended.ts b/src/configs/flat/recommended.ts new file mode 100644 index 000000000..7e2c4a80d --- /dev/null +++ b/src/configs/flat/recommended.ts @@ -0,0 +1,26 @@ +// IMPORTANT! +// This file has been automatically generated, +// in order to update its content execute "pnpm run update" +import base from './base'; +export default [ + ...base, + { + rules: { + // eslint-plugin-svelte rules + 'svelte/comment-directive': 'error', + 'svelte/no-at-debug-tags': 'warn', + 'svelte/no-at-html-tags': 'error', + 'svelte/no-dupe-else-if-blocks': 'error', + 'svelte/no-dupe-style-properties': 'error', + 'svelte/no-dynamic-slot-name': 'error', + 'svelte/no-inner-declarations': 'error', + 'svelte/no-not-function-handler': 'error', + 'svelte/no-object-in-text-mustaches': 'error', + 'svelte/no-shorthand-style-property-overrides': 'error', + 'svelte/no-unknown-style-directive-property': 'error', + 'svelte/no-unused-svelte-ignore': 'error', + 'svelte/system': 'error', + 'svelte/valid-compile': 'error' + } + } +]; diff --git a/src/index.ts b/src/index.ts index ed6162c8c..826a7b8d2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,14 @@ +import './rule-types'; import type { RuleModule } from './types'; import { rules as ruleList } from './utils/rules'; import base from './configs/base'; import recommended from './configs/recommended'; import prettier from './configs/prettier'; import all from './configs/all'; +import flatBase from './configs/flat/base'; +import flatRecommended from './configs/flat/recommended'; +import flatPrettier from './configs/flat/prettier'; +import flatAll from './configs/flat/all'; import * as processor from './processor'; import * as meta from './meta'; @@ -11,7 +16,11 @@ const configs = { base, recommended, prettier, - all + all, + 'flat/base': flatBase, + 'flat/recommended': flatRecommended, + 'flat/prettier': flatPrettier, + 'flat/all': flatAll }; const rules = ruleList.reduce( diff --git a/src/meta.ts b/src/meta.ts index 189abf6c2..bd0fd9420 100644 --- a/src/meta.ts +++ b/src/meta.ts @@ -1,5 +1,5 @@ // IMPORTANT! // This file has been automatically generated, // in order to update its content execute "pnpm run update" -export const name = 'eslint-plugin-svelte' as const; -export const version = '2.35.1' as const; +export const name = 'eslint-plugin-svelte'; +export const version = '2.38.0'; diff --git a/src/rule-types.ts b/src/rule-types.ts new file mode 100644 index 000000000..8f9e88911 --- /dev/null +++ b/src/rule-types.ts @@ -0,0 +1,479 @@ +// IMPORTANT! +// This file has been automatically generated, +// in order to update its content execute "pnpm run update" + +/* eslint-disable */ +/* prettier-ignore */ +import type { Linter } from 'eslint' + +declare module 'eslint' { + namespace Linter { + interface RulesRecord extends RuleOptions {} + } +} + +export interface RuleOptions { + /** + * disallow conditionals where the type is always truthy or always falsy + * @see https://sveltejs.github.io/eslint-plugin-svelte/rules/@typescript-eslint/no-unnecessary-condition/ + * @deprecated + */ + 'svelte/@typescript-eslint/no-unnecessary-condition'?: Linter.RuleEntry + /** + * disallows the use of languages other than those specified in the configuration for the lang attribute of ` + + diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-attributes03-errors.yaml b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-attributes03-errors.yaml new file mode 100644 index 000000000..f6af5dd96 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-attributes03-errors.yaml @@ -0,0 +1,28 @@ +- message: Expected indentation of 2 spaces but found 0 spaces. + line: 3 + column: 1 + suggestions: null +- message: Expected indentation of 4 spaces but found 0 spaces. + line: 4 + column: 1 + suggestions: null +- message: Expected indentation of 6 spaces but found 0 spaces. + line: 5 + column: 1 + suggestions: null +- message: Expected indentation of 8 spaces but found 0 spaces. + line: 6 + column: 1 + suggestions: null +- message: Expected indentation of 8 spaces but found 0 spaces. + line: 7 + column: 1 + suggestions: null +- message: Expected indentation of 4 spaces but found 0 spaces. + line: 8 + column: 1 + suggestions: null +- message: Expected indentation of 2 spaces but found 0 spaces. + line: 9 + column: 1 + suggestions: null diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-attributes03-output.svelte b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-attributes03-output.svelte new file mode 100644 index 000000000..8a9647777 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-attributes03-output.svelte @@ -0,0 +1,12 @@ + + + + diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-attributes04-errors.yaml b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-attributes04-errors.yaml new file mode 100644 index 000000000..f6af5dd96 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-attributes04-errors.yaml @@ -0,0 +1,28 @@ +- message: Expected indentation of 2 spaces but found 0 spaces. + line: 3 + column: 1 + suggestions: null +- message: Expected indentation of 4 spaces but found 0 spaces. + line: 4 + column: 1 + suggestions: null +- message: Expected indentation of 6 spaces but found 0 spaces. + line: 5 + column: 1 + suggestions: null +- message: Expected indentation of 8 spaces but found 0 spaces. + line: 6 + column: 1 + suggestions: null +- message: Expected indentation of 8 spaces but found 0 spaces. + line: 7 + column: 1 + suggestions: null +- message: Expected indentation of 4 spaces but found 0 spaces. + line: 8 + column: 1 + suggestions: null +- message: Expected indentation of 2 spaces but found 0 spaces. + line: 9 + column: 1 + suggestions: null diff --git a/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-attributes04-output.svelte b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-attributes04-output.svelte new file mode 100644 index 000000000..a62c1c129 --- /dev/null +++ b/tests/fixtures/rules/indent/invalid/ts-v5/ts-import-attributes04-output.svelte @@ -0,0 +1,12 @@ + + + + diff --git a/tests/fixtures/rules/mustache-spacing/invalid/always-after-expression/snippet-render01-errors.yaml b/tests/fixtures/rules/mustache-spacing/invalid/always-after-expression/snippet-render01-errors.yaml new file mode 100644 index 000000000..5270244ea --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/invalid/always-after-expression/snippet-render01-errors.yaml @@ -0,0 +1,8 @@ +- message: Expected 1 space before '}', but not found. + line: 2 + column: 16 + suggestions: null +- message: Expected 1 space before '}', but not found. + line: 4 + column: 15 + suggestions: null diff --git a/tests/fixtures/rules/mustache-spacing/invalid/always-after-expression/snippet-render01-input.svelte b/tests/fixtures/rules/mustache-spacing/invalid/always-after-expression/snippet-render01-input.svelte new file mode 100644 index 000000000..04cc8421b --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/invalid/always-after-expression/snippet-render01-input.svelte @@ -0,0 +1,4 @@ + +{#snippet foo()} +{/snippet} +{@render foo()} diff --git a/tests/fixtures/rules/mustache-spacing/invalid/always-after-expression/snippet-render01-output.svelte b/tests/fixtures/rules/mustache-spacing/invalid/always-after-expression/snippet-render01-output.svelte new file mode 100644 index 000000000..981b40eb5 --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/invalid/always-after-expression/snippet-render01-output.svelte @@ -0,0 +1,4 @@ + +{#snippet foo() } +{/snippet} +{@render foo() } diff --git a/tests/fixtures/rules/mustache-spacing/invalid/always-after-expression/snippet-render01-requirements.json b/tests/fixtures/rules/mustache-spacing/invalid/always-after-expression/snippet-render01-requirements.json new file mode 100644 index 000000000..0192b1098 --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/invalid/always-after-expression/snippet-render01-requirements.json @@ -0,0 +1,3 @@ +{ + "svelte": ">=5.0.0-0" +} diff --git a/tests/fixtures/rules/mustache-spacing/invalid/always/snippet-render01-errors.yaml b/tests/fixtures/rules/mustache-spacing/invalid/always/snippet-render01-errors.yaml new file mode 100644 index 000000000..0eb38c3cd --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/invalid/always/snippet-render01-errors.yaml @@ -0,0 +1,24 @@ +- message: Expected 1 space after '{', but not found. + line: 2 + column: 1 + suggestions: null +- message: Expected 1 space before '}', but not found. + line: 2 + column: 16 + suggestions: null +- message: Expected 1 space after '{', but not found. + line: 3 + column: 1 + suggestions: null +- message: Expected 1 space before '}', but not found. + line: 3 + column: 10 + suggestions: null +- message: Expected 1 space after '{', but not found. + line: 4 + column: 1 + suggestions: null +- message: Expected 1 space before '}', but not found. + line: 4 + column: 15 + suggestions: null diff --git a/tests/fixtures/rules/mustache-spacing/invalid/always/snippet-render01-input.svelte b/tests/fixtures/rules/mustache-spacing/invalid/always/snippet-render01-input.svelte new file mode 100644 index 000000000..04cc8421b --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/invalid/always/snippet-render01-input.svelte @@ -0,0 +1,4 @@ + +{#snippet foo()} +{/snippet} +{@render foo()} diff --git a/tests/fixtures/rules/mustache-spacing/invalid/always/snippet-render01-output.svelte b/tests/fixtures/rules/mustache-spacing/invalid/always/snippet-render01-output.svelte new file mode 100644 index 000000000..59b726019 --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/invalid/always/snippet-render01-output.svelte @@ -0,0 +1,4 @@ + +{ #snippet foo() } +{ /snippet } +{ @render foo() } diff --git a/tests/fixtures/rules/mustache-spacing/invalid/always/snippet-render01-requirements.json b/tests/fixtures/rules/mustache-spacing/invalid/always/snippet-render01-requirements.json new file mode 100644 index 000000000..0192b1098 --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/invalid/always/snippet-render01-requirements.json @@ -0,0 +1,3 @@ +{ + "svelte": ">=5.0.0-0" +} diff --git a/tests/fixtures/rules/mustache-spacing/invalid/always/test01-input.svelte b/tests/fixtures/rules/mustache-spacing/invalid/always/test01-input.svelte index dec41e0b9..a47613804 100644 --- a/tests/fixtures/rules/mustache-spacing/invalid/always/test01-input.svelte +++ b/tests/fixtures/rules/mustache-spacing/invalid/always/test01-input.svelte @@ -46,3 +46,5 @@ {#await expression}...{:then}...{:catch}...{/await} {#key expression}...{/key} + + diff --git a/tests/fixtures/rules/mustache-spacing/invalid/always/test01-output.svelte b/tests/fixtures/rules/mustache-spacing/invalid/always/test01-output.svelte index 8eec437c1..113d6aefd 100644 --- a/tests/fixtures/rules/mustache-spacing/invalid/always/test01-output.svelte +++ b/tests/fixtures/rules/mustache-spacing/invalid/always/test01-output.svelte @@ -46,3 +46,5 @@ { #await expression }...{ :then}...{ :catch}...{ /await } { #key expression }...{ /key } + + diff --git a/tests/fixtures/rules/mustache-spacing/invalid/snippet-render01-errors.yaml b/tests/fixtures/rules/mustache-spacing/invalid/snippet-render01-errors.yaml new file mode 100644 index 000000000..b8ea33588 --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/invalid/snippet-render01-errors.yaml @@ -0,0 +1,24 @@ +- message: Expected no space after '{', but found. + line: 2 + column: 1 + suggestions: null +- message: Expected no space before '}', but found. + line: 2 + column: 17 + suggestions: null +- message: Expected no space after '{', but found. + line: 3 + column: 1 + suggestions: null +- message: Expected no space before '}', but found. + line: 3 + column: 11 + suggestions: null +- message: Expected no space after '{', but found. + line: 4 + column: 1 + suggestions: null +- message: Expected no space before '}', but found. + line: 4 + column: 16 + suggestions: null diff --git a/tests/fixtures/rules/mustache-spacing/invalid/snippet-render01-input.svelte b/tests/fixtures/rules/mustache-spacing/invalid/snippet-render01-input.svelte new file mode 100644 index 000000000..59b726019 --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/invalid/snippet-render01-input.svelte @@ -0,0 +1,4 @@ + +{ #snippet foo() } +{ /snippet } +{ @render foo() } diff --git a/tests/fixtures/rules/mustache-spacing/invalid/snippet-render01-output.svelte b/tests/fixtures/rules/mustache-spacing/invalid/snippet-render01-output.svelte new file mode 100644 index 000000000..04cc8421b --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/invalid/snippet-render01-output.svelte @@ -0,0 +1,4 @@ + +{#snippet foo()} +{/snippet} +{@render foo()} diff --git a/tests/fixtures/rules/mustache-spacing/invalid/snippet-render01-requirements.json b/tests/fixtures/rules/mustache-spacing/invalid/snippet-render01-requirements.json new file mode 100644 index 000000000..0192b1098 --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/invalid/snippet-render01-requirements.json @@ -0,0 +1,3 @@ +{ + "svelte": ">=5.0.0-0" +} diff --git a/tests/fixtures/rules/mustache-spacing/invalid/test01-input.svelte b/tests/fixtures/rules/mustache-spacing/invalid/test01-input.svelte index e6d19dcd4..10ec4b852 100644 --- a/tests/fixtures/rules/mustache-spacing/invalid/test01-input.svelte +++ b/tests/fixtures/rules/mustache-spacing/invalid/test01-input.svelte @@ -46,3 +46,5 @@ { #key expression }...{ /key } + + diff --git a/tests/fixtures/rules/mustache-spacing/invalid/test01-output.svelte b/tests/fixtures/rules/mustache-spacing/invalid/test01-output.svelte index aefac172f..23515c7fb 100644 --- a/tests/fixtures/rules/mustache-spacing/invalid/test01-output.svelte +++ b/tests/fixtures/rules/mustache-spacing/invalid/test01-output.svelte @@ -46,3 +46,5 @@ {#key expression}...{/key} + + diff --git a/tests/fixtures/rules/mustache-spacing/valid/always/snippet-render01-input.svelte b/tests/fixtures/rules/mustache-spacing/valid/always/snippet-render01-input.svelte new file mode 100644 index 000000000..59b726019 --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/valid/always/snippet-render01-input.svelte @@ -0,0 +1,4 @@ + +{ #snippet foo() } +{ /snippet } +{ @render foo() } diff --git a/tests/fixtures/rules/mustache-spacing/valid/always/snippet-render01-requirements.json b/tests/fixtures/rules/mustache-spacing/valid/always/snippet-render01-requirements.json new file mode 100644 index 000000000..0192b1098 --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/valid/always/snippet-render01-requirements.json @@ -0,0 +1,3 @@ +{ + "svelte": ">=5.0.0-0" +} diff --git a/tests/fixtures/rules/mustache-spacing/valid/snippet-render01-input.svelte b/tests/fixtures/rules/mustache-spacing/valid/snippet-render01-input.svelte new file mode 100644 index 000000000..04cc8421b --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/valid/snippet-render01-input.svelte @@ -0,0 +1,4 @@ + +{#snippet foo()} +{/snippet} +{@render foo()} diff --git a/tests/fixtures/rules/mustache-spacing/valid/snippet-render01-requirements.json b/tests/fixtures/rules/mustache-spacing/valid/snippet-render01-requirements.json new file mode 100644 index 000000000..0192b1098 --- /dev/null +++ b/tests/fixtures/rules/mustache-spacing/valid/snippet-render01-requirements.json @@ -0,0 +1,3 @@ +{ + "svelte": ">=5.0.0-0" +} diff --git a/tests/fixtures/rules/no-goto-without-base/invalid/aliased-goto01-errors.yaml b/tests/fixtures/rules/no-goto-without-base/invalid/aliased-goto01-errors.yaml new file mode 100644 index 000000000..cc35de50a --- /dev/null +++ b/tests/fixtures/rules/no-goto-without-base/invalid/aliased-goto01-errors.yaml @@ -0,0 +1,4 @@ +- message: Found a goto() call with a url that isn't prefixed with the base path. + line: 4 + column: 8 + suggestions: null diff --git a/tests/fixtures/rules/no-goto-without-base/invalid/aliased-goto01-input.svelte b/tests/fixtures/rules/no-goto-without-base/invalid/aliased-goto01-input.svelte new file mode 100644 index 000000000..00f19edec --- /dev/null +++ b/tests/fixtures/rules/no-goto-without-base/invalid/aliased-goto01-input.svelte @@ -0,0 +1,5 @@ + diff --git a/tests/fixtures/rules/no-goto-without-base/invalid/base-not-prefixed01-errors.yaml b/tests/fixtures/rules/no-goto-without-base/invalid/base-not-prefixed01-errors.yaml new file mode 100644 index 000000000..ed8b9578e --- /dev/null +++ b/tests/fixtures/rules/no-goto-without-base/invalid/base-not-prefixed01-errors.yaml @@ -0,0 +1,8 @@ +- message: Found a goto() call with a url that isn't prefixed with the base path. + line: 6 + column: 7 + suggestions: null +- message: Found a goto() call with a url that isn't prefixed with the base path. + line: 7 + column: 7 + suggestions: null diff --git a/tests/fixtures/rules/no-goto-without-base/invalid/base-not-prefixed01-input.svelte b/tests/fixtures/rules/no-goto-without-base/invalid/base-not-prefixed01-input.svelte new file mode 100644 index 000000000..1aeff3aec --- /dev/null +++ b/tests/fixtures/rules/no-goto-without-base/invalid/base-not-prefixed01-input.svelte @@ -0,0 +1,8 @@ + diff --git a/tests/fixtures/rules/no-goto-without-base/invalid/no-base01-errors.yaml b/tests/fixtures/rules/no-goto-without-base/invalid/no-base01-errors.yaml new file mode 100644 index 000000000..658fcb47d --- /dev/null +++ b/tests/fixtures/rules/no-goto-without-base/invalid/no-base01-errors.yaml @@ -0,0 +1,4 @@ +- message: Found a goto() call with a url that isn't prefixed with the base path. + line: 4 + column: 7 + suggestions: null diff --git a/tests/fixtures/rules/no-goto-without-base/invalid/no-base01-input.svelte b/tests/fixtures/rules/no-goto-without-base/invalid/no-base01-input.svelte new file mode 100644 index 000000000..6f011fe2d --- /dev/null +++ b/tests/fixtures/rules/no-goto-without-base/invalid/no-base01-input.svelte @@ -0,0 +1,5 @@ + diff --git a/tests/fixtures/rules/no-goto-without-base/valid/absolute-uri01-input.svelte b/tests/fixtures/rules/no-goto-without-base/valid/absolute-uri01-input.svelte new file mode 100644 index 000000000..87ee8abf3 --- /dev/null +++ b/tests/fixtures/rules/no-goto-without-base/valid/absolute-uri01-input.svelte @@ -0,0 +1,6 @@ + diff --git a/tests/fixtures/rules/no-goto-without-base/valid/base-aliased01-input.svelte b/tests/fixtures/rules/no-goto-without-base/valid/base-aliased01-input.svelte new file mode 100644 index 000000000..b11e55f92 --- /dev/null +++ b/tests/fixtures/rules/no-goto-without-base/valid/base-aliased01-input.svelte @@ -0,0 +1,8 @@ + diff --git a/tests/fixtures/rules/no-goto-without-base/valid/base-prefixed01-input.svelte b/tests/fixtures/rules/no-goto-without-base/valid/base-prefixed01-input.svelte new file mode 100644 index 000000000..cd7177deb --- /dev/null +++ b/tests/fixtures/rules/no-goto-without-base/valid/base-prefixed01-input.svelte @@ -0,0 +1,8 @@ + diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/_config.json b/tests/fixtures/rules/no-inner-declarations/invalid/_config.json new file mode 100644 index 000000000..2ca520027 --- /dev/null +++ b/tests/fixtures/rules/no-inner-declarations/invalid/_config.json @@ -0,0 +1,3 @@ +{ + "options": ["functions", { "blockScopedFunctions": "disallow" }] +} diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/_requirements.json b/tests/fixtures/rules/no-inner-declarations/invalid/_requirements.json new file mode 100644 index 000000000..3a1e692a6 --- /dev/null +++ b/tests/fixtures/rules/no-inner-declarations/invalid/_requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": "^9.0.0-0" +} diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/both/_config.json b/tests/fixtures/rules/no-inner-declarations/invalid/both/_config.json index f3a3e6557..cabe15f0b 100644 --- a/tests/fixtures/rules/no-inner-declarations/invalid/both/_config.json +++ b/tests/fixtures/rules/no-inner-declarations/invalid/both/_config.json @@ -1,3 +1,3 @@ { - "options": ["both"] + "options": ["both", { "blockScopedFunctions": "disallow" }] } diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/both/_requirements.json b/tests/fixtures/rules/no-inner-declarations/invalid/both/_requirements.json new file mode 100644 index 000000000..3a1e692a6 --- /dev/null +++ b/tests/fixtures/rules/no-inner-declarations/invalid/both/_requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": "^9.0.0-0" +} diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/both/test01-errors.yaml b/tests/fixtures/rules/no-inner-declarations/invalid/both/test01-errors.yaml index 62049f3fd..4eede613c 100644 --- a/tests/fixtures/rules/no-inner-declarations/invalid/both/test01-errors.yaml +++ b/tests/fixtures/rules/no-inner-declarations/invalid/both/test01-errors.yaml @@ -3,26 +3,26 @@ column: 3 suggestions: null - message: Move variable declaration to program root. - line: 6 + line: 5 column: 11 suggestions: null - message: Move variable declaration to program root. - line: 8 + line: 6 column: 31 suggestions: null - message: Move function declaration to program root. - line: 10 + line: 8 column: 3 suggestions: null - message: Move variable declaration to function body root. - line: 13 + line: 10 column: 5 suggestions: null - message: Move function declaration to program root. - line: 18 + line: 15 column: 3 suggestions: null - message: Move variable declaration to function body root. - line: 20 + line: 16 column: 13 suggestions: null diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/both/test01-input.svelte b/tests/fixtures/rules/no-inner-declarations/invalid/both/test01-input.svelte index d7f0f6b14..2771ebca2 100644 --- a/tests/fixtures/rules/no-inner-declarations/invalid/both/test01-input.svelte +++ b/tests/fixtures/rules/no-inner-declarations/invalid/both/test01-input.svelte @@ -2,21 +2,17 @@ if (test) { function doSomething() {} } - // eslint-disable-next-line no-var -- test if (foo) var a; - // eslint-disable-next-line no-var -- test if (foo) /* some comments */ var a; if (foo) { function f() { if (bar) { - // eslint-disable-next-line no-var -- test var a; } } } if (foo) { function f() { - // eslint-disable-next-line no-var -- test if (bar) var a; } } diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/test01-errors.yaml b/tests/fixtures/rules/no-inner-declarations/invalid/test01-errors.yaml index 673e13f28..ab6c5f85d 100644 --- a/tests/fixtures/rules/no-inner-declarations/invalid/test01-errors.yaml +++ b/tests/fixtures/rules/no-inner-declarations/invalid/test01-errors.yaml @@ -3,10 +3,10 @@ column: 3 suggestions: null - message: Move function declaration to program root. - line: 10 + line: 8 column: 3 suggestions: null - message: Move function declaration to program root. - line: 18 + line: 15 column: 3 suggestions: null diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/test01-input.svelte b/tests/fixtures/rules/no-inner-declarations/invalid/test01-input.svelte index d7f0f6b14..2771ebca2 100644 --- a/tests/fixtures/rules/no-inner-declarations/invalid/test01-input.svelte +++ b/tests/fixtures/rules/no-inner-declarations/invalid/test01-input.svelte @@ -2,21 +2,17 @@ if (test) { function doSomething() {} } - // eslint-disable-next-line no-var -- test if (foo) var a; - // eslint-disable-next-line no-var -- test if (foo) /* some comments */ var a; if (foo) { function f() { if (bar) { - // eslint-disable-next-line no-var -- test var a; } } } if (foo) { function f() { - // eslint-disable-next-line no-var -- test if (bar) var a; } } diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/v8/_config.json b/tests/fixtures/rules/no-inner-declarations/invalid/v8/_config.json new file mode 100644 index 000000000..8322fb2f4 --- /dev/null +++ b/tests/fixtures/rules/no-inner-declarations/invalid/v8/_config.json @@ -0,0 +1,3 @@ +{ + "options": ["functions"] +} diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/v8/_requirements.json b/tests/fixtures/rules/no-inner-declarations/invalid/v8/_requirements.json new file mode 100644 index 000000000..84191ab69 --- /dev/null +++ b/tests/fixtures/rules/no-inner-declarations/invalid/v8/_requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": "<=8" +} diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/v8/both/_config.json b/tests/fixtures/rules/no-inner-declarations/invalid/v8/both/_config.json new file mode 100644 index 000000000..f3a3e6557 --- /dev/null +++ b/tests/fixtures/rules/no-inner-declarations/invalid/v8/both/_config.json @@ -0,0 +1,3 @@ +{ + "options": ["both"] +} diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/v8/both/_requirements.json b/tests/fixtures/rules/no-inner-declarations/invalid/v8/both/_requirements.json new file mode 100644 index 000000000..84191ab69 --- /dev/null +++ b/tests/fixtures/rules/no-inner-declarations/invalid/v8/both/_requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": "<=8" +} diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/v8/both/test01-errors.yaml b/tests/fixtures/rules/no-inner-declarations/invalid/v8/both/test01-errors.yaml new file mode 100644 index 000000000..4eede613c --- /dev/null +++ b/tests/fixtures/rules/no-inner-declarations/invalid/v8/both/test01-errors.yaml @@ -0,0 +1,28 @@ +- message: Move function declaration to program root. + line: 3 + column: 3 + suggestions: null +- message: Move variable declaration to program root. + line: 5 + column: 11 + suggestions: null +- message: Move variable declaration to program root. + line: 6 + column: 31 + suggestions: null +- message: Move function declaration to program root. + line: 8 + column: 3 + suggestions: null +- message: Move variable declaration to function body root. + line: 10 + column: 5 + suggestions: null +- message: Move function declaration to program root. + line: 15 + column: 3 + suggestions: null +- message: Move variable declaration to function body root. + line: 16 + column: 13 + suggestions: null diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/v8/both/test01-input.svelte b/tests/fixtures/rules/no-inner-declarations/invalid/v8/both/test01-input.svelte new file mode 100644 index 000000000..2771ebca2 --- /dev/null +++ b/tests/fixtures/rules/no-inner-declarations/invalid/v8/both/test01-input.svelte @@ -0,0 +1,19 @@ + diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/v8/test01-errors.yaml b/tests/fixtures/rules/no-inner-declarations/invalid/v8/test01-errors.yaml new file mode 100644 index 000000000..ab6c5f85d --- /dev/null +++ b/tests/fixtures/rules/no-inner-declarations/invalid/v8/test01-errors.yaml @@ -0,0 +1,12 @@ +- message: Move function declaration to program root. + line: 3 + column: 3 + suggestions: null +- message: Move function declaration to program root. + line: 8 + column: 3 + suggestions: null +- message: Move function declaration to program root. + line: 15 + column: 3 + suggestions: null diff --git a/tests/fixtures/rules/no-inner-declarations/invalid/v8/test01-input.svelte b/tests/fixtures/rules/no-inner-declarations/invalid/v8/test01-input.svelte new file mode 100644 index 000000000..2771ebca2 --- /dev/null +++ b/tests/fixtures/rules/no-inner-declarations/invalid/v8/test01-input.svelte @@ -0,0 +1,19 @@ + diff --git a/tests/fixtures/rules/no-inner-declarations/valid/test01-input.svelte b/tests/fixtures/rules/no-inner-declarations/valid/test01-input.svelte index 5a0cd558f..b26c0bbb7 100644 --- a/tests/fixtures/rules/no-inner-declarations/valid/test01-input.svelte +++ b/tests/fixtures/rules/no-inner-declarations/valid/test01-input.svelte @@ -7,19 +7,15 @@ function doSomething() {} })(); if (test) { - // eslint-disable-next-line no-var -- test var fn = function () {}; } if (test) { - // eslint-disable-next-line no-var -- test var fn = function expr() {}; } function decl() { - // eslint-disable-next-line no-var -- test var fn = function expr() {}; } function decl2(arg) { - // eslint-disable-next-line no-var -- test var fn; if (arg) { fn = function () {}; diff --git a/tests/fixtures/rules/no-unused-class-name/invalid/multiline-class-names01-input.svelte b/tests/fixtures/rules/no-unused-class-name/invalid/multiline-class-names01-input.svelte index 5a9a1c58a..a09893dbd 100644 --- a/tests/fixtures/rules/no-unused-class-name/invalid/multiline-class-names01-input.svelte +++ b/tests/fixtures/rules/no-unused-class-name/invalid/multiline-class-names01-input.svelte @@ -1,19 +1,20 @@ -
Hello
+
Hello
World! + ">World! diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore01-input.svelte b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore01-input.svelte index a5baa64da..fab7de052 100644 --- a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore01-input.svelte +++ b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore01-input.svelte @@ -4,6 +4,6 @@ {:else} -
    +
      {/if} diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore02-input.svelte b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore02-input.svelte index eb7e4f6fd..8650a0c78 100644 --- a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore02-input.svelte +++ b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore02-input.svelte @@ -4,6 +4,6 @@ {:else} -
        +
          {/each} diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore03-input.svelte b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore03-input.svelte index c1c204b26..7d7179065 100644 --- a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore03-input.svelte +++ b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/invalid-svelte-ignore03-input.svelte @@ -3,11 +3,11 @@ {:then name} -
            +
              {:catch name} -
                +
                  {/await}
                  @@ -15,6 +15,6 @@ {:then name} -
                    +
                      {/await}
                    diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-errors.yaml b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-errors.yaml index f0d33cb16..84bff518d 100644 --- a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-errors.yaml +++ b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-errors.yaml @@ -1,8 +1,4 @@ - message: svelte-ignore comment is used, but not warned - line: 3 - column: 19 - suggestions: null -- message: svelte-ignore comment is used, but not warned - line: 5 - column: 19 + line: 7 + column: 20 suggestions: null diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-input.svelte b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-input.svelte index 9cb4e088f..dc8b91bd2 100644 --- a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-input.svelte +++ b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-input.svelte @@ -1,9 +1,10 @@ - -{used} diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-requirements.json b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-requirements.json new file mode 100644 index 000000000..0192b1098 --- /dev/null +++ b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-requirements.json @@ -0,0 +1,3 @@ +{ + "svelte": ">=5.0.0-0" +} diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-svelte4-errors.yaml b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-svelte4-errors.yaml new file mode 100644 index 000000000..f0d33cb16 --- /dev/null +++ b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-svelte4-errors.yaml @@ -0,0 +1,8 @@ +- message: svelte-ignore comment is used, but not warned + line: 3 + column: 19 + suggestions: null +- message: svelte-ignore comment is used, but not warned + line: 5 + column: 19 + suggestions: null diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-svelte4-input.svelte b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-svelte4-input.svelte new file mode 100644 index 000000000..9cb4e088f --- /dev/null +++ b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-svelte4-input.svelte @@ -0,0 +1,9 @@ + + +{used} diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-svelte4-requirements.json b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-svelte4-requirements.json new file mode 100644 index 000000000..b650cc296 --- /dev/null +++ b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment01-svelte4-requirements.json @@ -0,0 +1,3 @@ +{ + "svelte": "^3.0.0 || ^4.0.0" +} diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment02-errors.yaml b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment02-svelte4-errors.yaml similarity index 100% rename from tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment02-errors.yaml rename to tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment02-svelte4-errors.yaml diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment02-input.svelte b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment02-svelte4-input.svelte similarity index 100% rename from tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment02-input.svelte rename to tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment02-svelte4-input.svelte diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment02-svelte4-requirements.json b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment02-svelte4-requirements.json new file mode 100644 index 000000000..b650cc296 --- /dev/null +++ b/tests/fixtures/rules/no-unused-svelte-ignore/invalid/script-comment02-svelte4-requirements.json @@ -0,0 +1,3 @@ +{ + "svelte": "^3.0.0 || ^4.0.0" +} diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/valid/.eslintrc.js b/tests/fixtures/rules/no-unused-svelte-ignore/valid/.eslintrc.js deleted file mode 100644 index a5a9d0f2b..000000000 --- a/tests/fixtures/rules/no-unused-svelte-ignore/valid/.eslintrc.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - overrides: [ - { - files: ['style-lang07-input.svelte'], - rules: { - 'prettier/prettier': 'off' - } - } - ] -}; diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/valid/element-ignore01-input.svelte b/tests/fixtures/rules/no-unused-svelte-ignore/valid/element-ignore01-input.svelte index 359728198..4f0cb2449 100644 --- a/tests/fixtures/rules/no-unused-svelte-ignore/valid/element-ignore01-input.svelte +++ b/tests/fixtures/rules/no-unused-svelte-ignore/valid/element-ignore01-input.svelte @@ -1,4 +1,4 @@ - + diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/valid/has-error-input.svelte b/tests/fixtures/rules/no-unused-svelte-ignore/valid/has-error-svelte4-input.svelte similarity index 100% rename from tests/fixtures/rules/no-unused-svelte-ignore/valid/has-error-input.svelte rename to tests/fixtures/rules/no-unused-svelte-ignore/valid/has-error-svelte4-input.svelte diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/valid/has-error-svelte4-requirements.json b/tests/fixtures/rules/no-unused-svelte-ignore/valid/has-error-svelte4-requirements.json new file mode 100644 index 000000000..b650cc296 --- /dev/null +++ b/tests/fixtures/rules/no-unused-svelte-ignore/valid/has-error-svelte4-requirements.json @@ -0,0 +1,3 @@ +{ + "svelte": "^3.0.0 || ^4.0.0" +} diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/valid/script-comment-input.svelte b/tests/fixtures/rules/no-unused-svelte-ignore/valid/script-comment-input.svelte index 4a8e38e57..337636d83 100644 --- a/tests/fixtures/rules/no-unused-svelte-ignore/valid/script-comment-input.svelte +++ b/tests/fixtures/rules/no-unused-svelte-ignore/valid/script-comment-input.svelte @@ -1,10 +1,8 @@ - - diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/valid/script-comment-requirements.json b/tests/fixtures/rules/no-unused-svelte-ignore/valid/script-comment-requirements.json new file mode 100644 index 000000000..0192b1098 --- /dev/null +++ b/tests/fixtures/rules/no-unused-svelte-ignore/valid/script-comment-requirements.json @@ -0,0 +1,3 @@ +{ + "svelte": ">=5.0.0-0" +} diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/valid/script-comment-svelte4-input.svelte b/tests/fixtures/rules/no-unused-svelte-ignore/valid/script-comment-svelte4-input.svelte new file mode 100644 index 000000000..4a8e38e57 --- /dev/null +++ b/tests/fixtures/rules/no-unused-svelte-ignore/valid/script-comment-svelte4-input.svelte @@ -0,0 +1,10 @@ + + + diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/valid/script-comment-svelte4-requirements.json b/tests/fixtures/rules/no-unused-svelte-ignore/valid/script-comment-svelte4-requirements.json new file mode 100644 index 000000000..b650cc296 --- /dev/null +++ b/tests/fixtures/rules/no-unused-svelte-ignore/valid/script-comment-svelte4-requirements.json @@ -0,0 +1,3 @@ +{ + "svelte": "^3.0.0 || ^4.0.0" +} diff --git a/tests/fixtures/rules/no-unused-svelte-ignore/valid/style-lang01-input.svelte b/tests/fixtures/rules/no-unused-svelte-ignore/valid/style-lang01-input.svelte index 9d70f1ab2..3ca99cadb 100644 --- a/tests/fixtures/rules/no-unused-svelte-ignore/valid/style-lang01-input.svelte +++ b/tests/fixtures/rules/no-unused-svelte-ignore/valid/style-lang01-input.svelte @@ -1,4 +1,4 @@ -
                    +