close

jsx-filename-extension

Configuration

rslint.config.ts
import { defineConfig, reactPlugin } from '@rslint/core';

export default defineConfig([
  reactPlugin.configs.recommended,
  {
    rules: {
      'react/jsx-filename-extension': 'error',
    },
  },
]);

Rule Details

Restrict file extensions that may contain JSX. By default, only .jsx files may contain JSX.

Examples of incorrect code for this rule:

// In file: Component.js
var Hello = <div>Hello</div>;

Examples of correct code for this rule:

// In file: Component.jsx
var Hello = <div>Hello</div>;

Options

  • extensions: An array of allowed file extensions (default: [".jsx"]).
  • allow: "always" (default) or "as-needed".
    • "always": Allow the specified extensions whether or not they contain JSX.
    • "as-needed": Only allow the specified extensions when the file actually contains JSX.
  • ignoreFilesWithoutCode: When true, files with no code statements are ignored in "as-needed" mode.

Original Documentation