tslint-react-perf
raw JSON → 0.3.1 verified Fri May 01 auth: no javascript deprecated
Supplemental TSLint rules for React performance best practices. Version 0.3.1 (latest). Inactive project; author recommends using React hooks (useMemo, useCallback) instead. Provides rules to prevent binding, lambdas, array/object literals in JSX props, enforce pure component patterns. Requires TypeScript and TSLint. No releases or updates since 2019.
Common errors
error Cannot find module 'tslint-react-perf' ↓
cause Package not installed or not in node_modules.
fix
Run 'npm install tslint-react-perf --save-dev' or 'yarn add tslint-react-perf --dev'.
error Could not find rule: 'jsx-no-bind-props' ↓
cause Rule not enabled in tslint.json configuration or package not extended properly.
fix
Add 'tslint-react-perf' to your extends array in tslint.json.
Warnings
deprecated Project is abandoned; author recommends using React hooks (useMemo, useCallback) instead. ↓
fix Migrate to eslint-plugin-react-hooks or rely on hooks for performance optimization.
gotcha tslint-react is also deprecated; TSLint is deprecated in favor of ESLint. ↓
fix Switch to ESLint with @typescript-eslint/parser and eslint-plugin-react.
gotcha Rules only work with TSLint; they do not work with ESLint or other linters. ↓
fix Do not attempt to use with ESLint; only applicable in TSLint-based projects.
Install
npm install tslint-react-perf yarn add tslint-react-perf pnpm add tslint-react-perf Imports
- rules wrong
import { rules } from 'tslint-react-perf'correct{ "extends": ["tslint-react-perf"] } - jsx-no-bind-props wrong
import { jsx-no-bind-props } from 'tslint-react-perf'correct{ "rules": { "jsx-no-bind-props": true } } - react-pure-components-have-simple-attributes wrong
const rule = require('tslint-react-perf')correct{ "rules": { "react-pure-components-have-simple-attributes": true } }
Quickstart
{
"extends": ["tslint:latest", "tslint-react", "tslint-react-perf"],
"rules": {
"jsx-no-lambda": true,
"jsx-no-bind": true,
"jsx-no-bind-props": true,
"jsx-no-lambda-props": true,
"jsx-no-array-literal-props": true,
"jsx-no-object-literal-props": true,
"react-component-classes-should-implement-scu": true,
"react-pure-components-have-simple-attributes": true
}
}