solidjs-community/eslint-plugin-solid

Solid-specific linting rules for ESLint.

266

stars

403

commits

TypeScript

primary language

Sep 11, 2026

updated

README

Solid ESLint Extension

Solid ESLint Plugin

npm version GitHub package version ESLint peer dependency CI

This package contains Solid-specific linting rules for ESLint. It can ease Solid's learning curve by finding and fixing problems around Solid's reactivity system, and can migrate some React patterns to Solid code.

It supports both Solid 1.x and Solid 2.0 APIs, requires ESLint v9 or v10 and Node.js 22+, and also runs under Oxlint as a JS plugin.

Installation

Install eslint and eslint-plugin-solid locally.

npm install --save-dev eslint eslint-plugin-solid
# or
pnpm add --save-dev eslint eslint-plugin-solid
yarn add --dev eslint eslint-plugin-solid

# optional, to create an ESLint config file
npx eslint --init
# or
pnpm eslint --init
yarn eslint --init

If you're using VSCode, you'll want to install the ESLint extension. You're encouraged to enable auto-fixing problems on save by adding the following to your settings.json file.

{
  "editor.codeActionsOnSave": {
    "source.fixAll": true
  }
}

If you're using Vite, you may want to install vite-plugin-eslint.

You may also want to check out eslint-plugin-jsx-a11y, which provides useful rules for writing accessible HTML.

Configuration

Create an eslint.config.js file at the root of your project (flat config is the only configuration system supported by ESLint v9+, and by this plugin as of v0.15.0), and use the recommended configuration to get reasonable defaults as shown below.

import js from "@eslint/js";
import solid from "eslint-plugin-solid/configs/recommended";

export default [
  js.configs.recommended, // replaces eslint:recommended
  solid,
];

TypeScript

If you're using TypeScript, use the typescript configuration instead. This disables some features that overlap with type checking.

import js from "@eslint/js";
import solid from "eslint-plugin-solid/configs/typescript";
import * as tsParser from "@typescript-eslint/parser";

export default [
  js.configs.recommended,
  {
    files: ["**/*.{ts,tsx}"],
    ...solid,
    languageOptions: {
      parser: tsParser,
      parserOptions: {
        project: "tsconfig.json",
      },
    },
  },
];

Solid 2.0

If your project targets Solid 2.0, use the v2 configuration. It sets settings: { solid: { version: 2 } }, which switches the version-aware rules (reactivity, imports, no-unknown-namespaces, event-handlers, jsx-no-undef) to strict 2.0 semantics, and enables the 2.0-specific rules: removed-api, no-single-arg-create-effect, no-accessor-as-prop as errors and prefer-structured-class as a warning. This is the config the official Solid 2.0 templates ship with.

import js from "@eslint/js";
import solid from "eslint-plugin-solid/configs/v2";

export default [js.configs.recommended, solid];

There is also a v2-strict configuration with the plugin's strongest opinions: everything in v2 plus no-module-scope-reactive-primitive and no-restated-default-options as errors, prefer-onSettled-for-side-effects as a warning, and prefer-structured-class promoted to an error.

The settings.solid.version setting also works in any custom config; version-aware rules read it directly, so you can opt individual rule configurations into 2.0 semantics without using the presets.

All configs are also available on the plugin's root export, as solid.configs.recommended, solid.configs.typescript, solid.configs.v2, and solid.configs["v2-strict"], after using import solid from 'eslint-plugin-solid'. (The configs["flat/recommended"] and configs["flat/typescript"] names from v0.14.x still work as aliases.)

These configurations do not configure global variables in ESLint. You can do this yourself manually or with a package like globals by creating a configuration with a languageOptions.globals object. We recommend setting up global variables for Browser APIs as well as at least ES2015.

Manual Configuration

If you don't want to use a preset, you can configure rules individually. Add the solid plugin, enable JSX with the parser options (or use the equivalent options for @typescript-eslint/parser or @babel/eslint-parser), and configure the rules you would like to use. Some rules have additional options you can set.

import solid from "eslint-plugin-solid";

export default [
  {
    plugins: { solid },
    languageOptions: {
      parserOptions: {
        ecmaFeatures: { jsx: true },
      },
    },
    rules: {
      "solid/reactivity": "warn",
      "solid/no-destructure": "warn",
      "solid/jsx-no-undef": "error",
    },
  },
];

Oxlint

The plugin's rules are AST-based, so they run under Oxlint's JS plugin support without modification. Add the plugin to jsPlugins in your .oxlintrc.json and enable the rules you want:

{
  "jsPlugins": ["eslint-plugin-solid"],
  "rules": {
    "solid/reactivity": "warn",
    "solid/no-destructure": "error",
    "solid/jsx-no-undef": "error"
  }
}

For Solid 2.0 projects, add "settings": { "solid": { "version": 2 } } to activate the version-aware rule behavior, and enable the 2.0 rules (solid/removed-api, solid/no-single-arg-create-effect, solid/no-accessor-as-prop, solid/prefer-structured-class).

Rules

βœ”: Enabled in the recommended configuration.

πŸ”§: Fixable with eslint --fix/IDE auto-fix.

βœ”πŸ”§RuleDescription
βœ”πŸ”§solid/components-return-onceDisallow early returns in components. Solid components only run once, and so conditionals should be inside JSX.
βœ”πŸ”§solid/event-handlersEnforce naming DOM element event handlers consistently and prevent Solid's analysis from misunderstanding whether a prop should be an event handler.
βœ”πŸ”§solid/importsEnforce consistent imports from "solid-js", "solid-js/web", and "solid-js/store".
βœ”solid/jsx-no-duplicate-propsDisallow passing the same prop twice in JSX.
βœ”solid/jsx-no-script-urlDisallow javascript: URLs.
βœ”πŸ”§solid/jsx-no-undefDisallow references to undefined variables in JSX. Handles custom directives.
βœ”solid/jsx-uses-varsPrevent variables used in JSX from being marked as unused.
solid/no-accessor-as-propDisallow passing uncalled signal accessors or other functions as value-typed DOM element attributes.
solid/no-array-handlersDisallow usage of type-unsafe event handlers.
βœ”πŸ”§solid/no-destructureDisallow destructuring props. In Solid, props must be used with property accesses (props.foo) to preserve reactivity. This rule only tracks destructuring in the parameter list.
βœ”πŸ”§solid/no-innerhtmlDisallow usage of the innerHTML attribute, which can often lead to security vulnerabilities.
solid/no-module-scope-reactive-primitiveDisallow reactive primitives at module scope, where state is shared across SSR requests.
solid/no-proxy-apisDisallow usage of APIs that use ES6 Proxies, only to target environments that don't support them.
βœ”πŸ”§solid/no-react-depsDisallow usage of dependency arrays in createEffect and createMemo.
βœ”πŸ”§solid/no-react-specific-propsDisallow usage of React-specific className/htmlFor props, which were deprecated in v1.4.0.
πŸ”§solid/no-restated-default-optionsDisallow restating a prop or option value that is already the default.
solid/no-single-arg-create-effectRequire the two-argument createEffect(compute, effect) form used by Solid 2.0.
βœ”solid/no-unknown-namespacesEnforce using only Solid-specific namespaced attribute names (i.e. 'on:' in <div on:click={...} />).
πŸ”§solid/prefer-classlistEnforce using the classlist prop over importing a classnames helper. The classlist prop accepts an object { [class: string]: boolean } just like classnames.
βœ”πŸ”§solid/prefer-forEnforce using Solid's <For /> component for mapping an array to JSX elements.
solid/prefer-onSettled-for-side-effectsEnforce running side-effectful setup (timers, global listeners, observers) inside onSettled instead of the component body.
πŸ”§solid/prefer-showEnforce using Solid's <Show /> component for conditionally showing content. Solid's compiler covers this case, so it's a stylistic rule only.
solid/prefer-structured-classEnforce using the structured array/object forms of the class prop over manually-built class strings.
βœ”solid/reactivityEnforce that reactivity (props, signals, memos, etc.) is properly used, so changes in those values will be tracked and update the view as expected.
πŸ”§solid/removed-apiDisallow Solid 1.x APIs that were removed or renamed in Solid 2.0, with migration guidance.
βœ”πŸ”§solid/self-closing-compDisallow extra closing tags for components without children.
βœ”πŸ”§solid/style-propRequire CSS properties in the style prop to be valid and kebab-cased (ex. 'font-size'), not camel-cased (ex. 'fontSize') like in React, and that property values with dimensions are strings, not numbers with implicit 'px' units.

Troubleshooting

The rules in this plugin provide sensible guidelines as well as possible, but there may be times where you know better than the rule and want to ignore a warning. To do that, add a comment like the following:

// eslint-disable-next-line solid/reactivity
const [editedValue, setEditedValue] = createSignal(props.value);

Please note: there may also be times where a rule correctly warns about a subtle problem, even if it looks like a false positive at first. With solid/reactivity, please look at the reactivity docs before deciding to disable the rule.

When in doubt, feel free to file an issue.

Versioning

Pre-1.0.0, the rules and the recommended, typescript, v2, and v2-strict configurations will be stable across patch (0.0.x) versions, but may change across minor (0.x) versions. If you want to pin a minor version, use a tilde in your package.json.

- "eslint-plugin-solid": "^0.16.0"
+ "eslint-plugin-solid": "~0.16.0"

Contributors

joshwilsonvu

337 commits

nix6839

12 commits

Mitsunee

8 commits

ryansolid

7 commits

solidjs-community/eslint-plugin-solid

Solid-specific linting rules for ESLint.

266

stars

403

commits

TypeScript

primary language

Sep 11, 2026

updated

README

Solid ESLint Extension

Solid ESLint Plugin

npm version GitHub package version ESLint peer dependency CI

This package contains Solid-specific linting rules for ESLint. It can ease Solid's learning curve by finding and fixing problems around Solid's reactivity system, and can migrate some React patterns to Solid code.

It supports both Solid 1.x and Solid 2.0 APIs, requires ESLint v9 or v10 and Node.js 22+, and also runs under Oxlint as a JS plugin.

Installation

Install eslint and eslint-plugin-solid locally.

npm install --save-dev eslint eslint-plugin-solid
# or
pnpm add --save-dev eslint eslint-plugin-solid
yarn add --dev eslint eslint-plugin-solid

# optional, to create an ESLint config file
npx eslint --init
# or
pnpm eslint --init
yarn eslint --init

If you're using VSCode, you'll want to install the ESLint extension. You're encouraged to enable auto-fixing problems on save by adding the following to your settings.json file.

{
  "editor.codeActionsOnSave": {
    "source.fixAll": true
  }
}

If you're using Vite, you may want to install vite-plugin-eslint.

You may also want to check out eslint-plugin-jsx-a11y, which provides useful rules for writing accessible HTML.

Configuration

Create an eslint.config.js file at the root of your project (flat config is the only configuration system supported by ESLint v9+, and by this plugin as of v0.15.0), and use the recommended configuration to get reasonable defaults as shown below.

import js from "@eslint/js";
import solid from "eslint-plugin-solid/configs/recommended";

export default [
  js.configs.recommended, // replaces eslint:recommended
  solid,
];

TypeScript

If you're using TypeScript, use the typescript configuration instead. This disables some features that overlap with type checking.

import js from "@eslint/js";
import solid from "eslint-plugin-solid/configs/typescript";
import * as tsParser from "@typescript-eslint/parser";

export default [
  js.configs.recommended,
  {
    files: ["**/*.{ts,tsx}"],
    ...solid,
    languageOptions: {
      parser: tsParser,
      parserOptions: {
        project: "tsconfig.json",
      },
    },
  },
];

Solid 2.0

If your project targets Solid 2.0, use the v2 configuration. It sets settings: { solid: { version: 2 } }, which switches the version-aware rules (reactivity, imports, no-unknown-namespaces, event-handlers, jsx-no-undef) to strict 2.0 semantics, and enables the 2.0-specific rules: removed-api, no-single-arg-create-effect, no-accessor-as-prop as errors and prefer-structured-class as a warning. This is the config the official Solid 2.0 templates ship with.

import js from "@eslint/js";
import solid from "eslint-plugin-solid/configs/v2";

export default [js.configs.recommended, solid];

There is also a v2-strict configuration with the plugin's strongest opinions: everything in v2 plus no-module-scope-reactive-primitive and no-restated-default-options as errors, prefer-onSettled-for-side-effects as a warning, and prefer-structured-class promoted to an error.

The settings.solid.version setting also works in any custom config; version-aware rules read it directly, so you can opt individual rule configurations into 2.0 semantics without using the presets.

All configs are also available on the plugin's root export, as solid.configs.recommended, solid.configs.typescript, solid.configs.v2, and solid.configs["v2-strict"], after using import solid from 'eslint-plugin-solid'. (The configs["flat/recommended"] and configs["flat/typescript"] names from v0.14.x still work as aliases.)

These configurations do not configure global variables in ESLint. You can do this yourself manually or with a package like globals by creating a configuration with a languageOptions.globals object. We recommend setting up global variables for Browser APIs as well as at least ES2015.

Manual Configuration

If you don't want to use a preset, you can configure rules individually. Add the solid plugin, enable JSX with the parser options (or use the equivalent options for @typescript-eslint/parser or @babel/eslint-parser), and configure the rules you would like to use. Some rules have additional options you can set.

import solid from "eslint-plugin-solid";

export default [
  {
    plugins: { solid },
    languageOptions: {
      parserOptions: {
        ecmaFeatures: { jsx: true },
      },
    },
    rules: {
      "solid/reactivity": "warn",
      "solid/no-destructure": "warn",
      "solid/jsx-no-undef": "error",
    },
  },
];

Oxlint

The plugin's rules are AST-based, so they run under Oxlint's JS plugin support without modification. Add the plugin to jsPlugins in your .oxlintrc.json and enable the rules you want:

{
  "jsPlugins": ["eslint-plugin-solid"],
  "rules": {
    "solid/reactivity": "warn",
    "solid/no-destructure": "error",
    "solid/jsx-no-undef": "error"
  }
}

For Solid 2.0 projects, add "settings": { "solid": { "version": 2 } } to activate the version-aware rule behavior, and enable the 2.0 rules (solid/removed-api, solid/no-single-arg-create-effect, solid/no-accessor-as-prop, solid/prefer-structured-class).

Rules

βœ”: Enabled in the recommended configuration.

πŸ”§: Fixable with eslint --fix/IDE auto-fix.

βœ”πŸ”§RuleDescription
βœ”πŸ”§solid/components-return-onceDisallow early returns in components. Solid components only run once, and so conditionals should be inside JSX.
βœ”πŸ”§solid/event-handlersEnforce naming DOM element event handlers consistently and prevent Solid's analysis from misunderstanding whether a prop should be an event handler.
βœ”πŸ”§solid/importsEnforce consistent imports from "solid-js", "solid-js/web", and "solid-js/store".
βœ”solid/jsx-no-duplicate-propsDisallow passing the same prop twice in JSX.
βœ”solid/jsx-no-script-urlDisallow javascript: URLs.
βœ”πŸ”§solid/jsx-no-undefDisallow references to undefined variables in JSX. Handles custom directives.
βœ”solid/jsx-uses-varsPrevent variables used in JSX from being marked as unused.
solid/no-accessor-as-propDisallow passing uncalled signal accessors or other functions as value-typed DOM element attributes.
solid/no-array-handlersDisallow usage of type-unsafe event handlers.
βœ”πŸ”§solid/no-destructureDisallow destructuring props. In Solid, props must be used with property accesses (props.foo) to preserve reactivity. This rule only tracks destructuring in the parameter list.
βœ”πŸ”§solid/no-innerhtmlDisallow usage of the innerHTML attribute, which can often lead to security vulnerabilities.
solid/no-module-scope-reactive-primitiveDisallow reactive primitives at module scope, where state is shared across SSR requests.
solid/no-proxy-apisDisallow usage of APIs that use ES6 Proxies, only to target environments that don't support them.
βœ”πŸ”§solid/no-react-depsDisallow usage of dependency arrays in createEffect and createMemo.
βœ”πŸ”§solid/no-react-specific-propsDisallow usage of React-specific className/htmlFor props, which were deprecated in v1.4.0.
πŸ”§solid/no-restated-default-optionsDisallow restating a prop or option value that is already the default.
solid/no-single-arg-create-effectRequire the two-argument createEffect(compute, effect) form used by Solid 2.0.
βœ”solid/no-unknown-namespacesEnforce using only Solid-specific namespaced attribute names (i.e. 'on:' in <div on:click={...} />).
πŸ”§solid/prefer-classlistEnforce using the classlist prop over importing a classnames helper. The classlist prop accepts an object { [class: string]: boolean } just like classnames.
βœ”πŸ”§solid/prefer-forEnforce using Solid's <For /> component for mapping an array to JSX elements.
solid/prefer-onSettled-for-side-effectsEnforce running side-effectful setup (timers, global listeners, observers) inside onSettled instead of the component body.
πŸ”§solid/prefer-showEnforce using Solid's <Show /> component for conditionally showing content. Solid's compiler covers this case, so it's a stylistic rule only.
solid/prefer-structured-classEnforce using the structured array/object forms of the class prop over manually-built class strings.
βœ”solid/reactivityEnforce that reactivity (props, signals, memos, etc.) is properly used, so changes in those values will be tracked and update the view as expected.
πŸ”§solid/removed-apiDisallow Solid 1.x APIs that were removed or renamed in Solid 2.0, with migration guidance.
βœ”πŸ”§solid/self-closing-compDisallow extra closing tags for components without children.
βœ”πŸ”§solid/style-propRequire CSS properties in the style prop to be valid and kebab-cased (ex. 'font-size'), not camel-cased (ex. 'fontSize') like in React, and that property values with dimensions are strings, not numbers with implicit 'px' units.

Troubleshooting

The rules in this plugin provide sensible guidelines as well as possible, but there may be times where you know better than the rule and want to ignore a warning. To do that, add a comment like the following:

// eslint-disable-next-line solid/reactivity
const [editedValue, setEditedValue] = createSignal(props.value);

Please note: there may also be times where a rule correctly warns about a subtle problem, even if it looks like a false positive at first. With solid/reactivity, please look at the reactivity docs before deciding to disable the rule.

When in doubt, feel free to file an issue.

Versioning

Pre-1.0.0, the rules and the recommended, typescript, v2, and v2-strict configurations will be stable across patch (0.0.x) versions, but may change across minor (0.x) versions. If you want to pin a minor version, use a tilde in your package.json.

- "eslint-plugin-solid": "^0.16.0"
+ "eslint-plugin-solid": "~0.16.0"

Contributors

joshwilsonvu

337 commits

nix6839

12 commits

Mitsunee

8 commits

ryansolid

7 commits

Languages

TypeScript

92.2%

JavaScript

7.8%