Skip to content

Latest commit

 

History

History
69 lines (44 loc) · 2.35 KB

CONTRIBUTING.md

File metadata and controls

69 lines (44 loc) · 2.35 KB

Contributing

Thank you for contributing!

Installation

git clone https://github.com/sveltejs/eslint-plugin-svelte.git
cd eslint-plugin-svelte
pnpm install

Running Tests

cd packages/eslint-plugin-svelte
pnpm run test

This is an ESLint plugin. See ESLint's Working with Plugins for API details.

The plugin lints itself. Running pnpm run lint checks the style and will fail the build if there are lint errors. Use pnpm run lint-fix to automatically fix some issues.

Other Development Tools

  • pnpm run test – runs tests.
  • pnpm run new -- [new-rule-name] – generates files for a new rule.
  • pnpm run update – updates the README and recommended configuration.

Rule Testing

Rule tests typically use fixtures. For example, for the indent rule, the test file is tests/src/rules/indent.ts and the fixtures are in tests/fixtures/rules/indent, which contains invalid and valid directories.

  • The invalid directory contains test cases where the rule should report errors.
  • The valid directory contains test cases where no errors are reported.

Fixture input files should be named *-input.svelte and are automatically collected.
If configuration is needed, include a JSON file:

  • For a specific test file (e.g., my-test-input.svelte), add my-test-config.json.
  • For all fixtures in a directory, add _config.json.

Verifying output for invalid tests requires *-errors.json and *-output.svelte (for auto-fix). These files are auto-generated if missing—delete them to recreate.

Tips:

To test only one rule (e.g., indent), run:

pnpm run test -- -g indent

Refer to this Stack Overflow post for details.

To test a single file (e.g., my-test-input.svelte), add a my-test-config.json with {"only": true}.
(Remember to remove {"only": true} before submitting a pull request.)

Preview Docs

cd docs-svelte-kit
pnpm run build && pnpm run preview

Publishing

We use changesets for version management, changelog generation, and automated releases.

For more details, see changesets-bot and its action.