npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-svelte-gym

v1.0.1

Published

ESLint rules for validating svelte-gym test harness pages

Downloads

29

Readme

eslint-plugin-svelte-gym

ESLint rules for validating svelte-gym test harness pages. Catches common setup mistakes at lint time so your component playgrounds work correctly.

Installation

npm install --save-dev eslint-plugin-svelte-gym

Note: This plugin requires eslint >= 8.0.0 and svelte-eslint-parser for Svelte file support.

Usage

Add svelte-gym to the plugins section of your ESLint configuration and use the recommended preset:

// .eslintrc.cjs
module.exports = {
  plugins: ['svelte-gym'],
  extends: ['plugin:svelte-gym/recommended']
};

Or configure individual rules manually:

module.exports = {
  plugins: ['svelte-gym'],
  rules: {
    'svelte-gym/require-restore-props': 'warn',
    'svelte-gym/no-duplicate-prop-names': 'warn',
    'svelte-gym/require-props-state': 'error',
    'svelte-gym/single-component-in-test': 'error'
  }
};

Rules

| Rule | Default | Description | |------|---------|-------------| | require-restore-props | ⚠️ warn | Require restoreProps() call when TestHarness is imported | | no-duplicate-prop-names | ⚠️ warn | Disallow duplicate name props across Gym components | | require-props-state | 🛑 error | Require the props object passed to restoreProps() to use $state() | | single-component-in-test | 🛑 error | Require componentToTest snippet to contain exactly one component |

require-restore-props

Default: warn · Category: Best Practices

Warns when a Svelte file imports TestHarness from svelte-gym but does not call restoreProps() anywhere in the script block. Without restoreProps(), URL parameters will not be restored into component state.

<!-- ❌ Bad -->
<script>
  import { TestHarness } from 'svelte-gym';
  let props = $state({ color: 'red' });
</script>

<!-- ✅ Good -->
<script>
  import { TestHarness, restoreProps } from 'svelte-gym';
  let props = $state({ color: 'red' });
  restoreProps(props);
</script>

no-duplicate-prop-names

Default: warn · Category: Best Practices

Warns when multiple Gym* components use the same name prop value, which causes permalink parameter collisions.

<!-- ❌ Bad — both controls write to the same URL parameter -->
<GymSlider name="size" ... />
<GymTextbox name="size" ... />

<!-- ✅ Good -->
<GymSlider name="width" ... />
<GymTextbox name="label" ... />

require-props-state

Default: error · Category: Possible Errors

Errors when restoreProps(props) is called but props was not declared with $state(). Without $state(), URL-restored values will be set but won't trigger Svelte reactivity.

<!-- ❌ Bad -->
<script>
  import { restoreProps } from 'svelte-gym';
  let props = { color: 'red' };
  restoreProps(props);
</script>

<!-- ✅ Good -->
<script>
  import { restoreProps } from 'svelte-gym';
  let props = $state({ color: 'red' });
  restoreProps(props);
</script>

single-component-in-test

Default: error · Category: Possible Errors

Errors when the componentToTest snippet contains more than one child element, or when its child is a plain HTML element instead of a component. This enforces testing components in isolation — wrapping in <div> or <section> may make things look correct in the harness but behave differently in production.

<!-- ❌ Bad — wrapper div hides real layout behavior -->
{#snippet componentToTest()}
  <div>
    <MyComponent {...props} />
  </div>
{/snippet}

<!-- ❌ Bad — multiple elements -->
{#snippet componentToTest()}
  <MyComponent {...props} />
  <AnotherComponent />
{/snippet}

<!-- ✅ Good -->
{#snippet componentToTest()}
  <MyComponent {...props} />
{/snippet}

License

MIT