eslint-plugin-no-tsx-without-jsx
v0.0.3
Published
An ESLint plugin that enforces JSX presence in `.tsx` files to maintain clear file type distinctions in TypeScript projects.
Readme
eslint-plugin-no-tsx-without-jsx
An ESLint plugin that enforces JSX presence in .tsx files to maintain clear file type distinctions in TypeScript projects.
Why?
Using .tsx extensions for files without JSX can cause confusion and inconsistency. This plugin ensures that .tsx files contain JSX elements
Installation
npm install eslint-plugin-no-tsx-without-jsx --save-devUsage
- Add to your ESLint configuration:
{
"plugins": ["no-tsx-without-jsx"],
"rules": {
"no-tsx-without-jsx/no-tsx-without-jsx": "error"
}
}- Example valid/invalid usage:
✅ Valid (contains JSX):
// myComponent.tsx
const MyComponent = () => <div>Hello</div>;❌ Invalid (no JSX):
// utility.tsx
export function utility() {
return 42;
} // Should be utility.tsInspiration
This plugin was inspired by the discussion in jsx-eslint/eslint-plugin-react#3843
Related
- ESLint - Pluggable JavaScript linter
- TypeScript ESLint - TypeScript support for ESLint
