solidjs-community / eslint-plugin-solid

Solid-specific linting rules for ESLint.
MIT License
206 stars 24 forks source link

Forbidden elements #108

Closed kdabir closed 8 months ago

kdabir commented 9 months ago

Describe the need Disallow certain elements from the solid component markup

Suggested Solution Something similar to react plugins forbid elements https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/forbid-elements.md

Possible Alternatives If there is way we could just reuse the react plugin, we need to know how (just documenting that would be awesome)

Additional context N/A

joshwilsonvu commented 8 months ago

You should be able to use the eslint-plugin-react rule as-is! Not every React rule translates to Solid, but this and several others do. You'll want to install the plugin and add it to the "plugins" section, without extending the plugin:react/recommended" preset. Then configure any react rules you want in the "rules" section.

{
  "plugins": [
    "solid",
    "react"
  ],
  "rules": {
    "react/forbid-elements": [1, { "forbid": ["button"] }]
  }
}

Hopefully this helps or you've already got it working! Let me know if there are any issues.