All Projects → palantir → Tslint React

palantir / Tslint React

Licence: apache-2.0
📙 Lint rules related to React & JSX for TSLint.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Tslint React

Language Babel
ES2017, flow, React JSX and GraphQL grammar and transpilation for ATOM
Stars: ✭ 476 (-36.62%)
Mutual labels:  jsx
Nerv
A blazing fast React alternative, compatible with IE8 and React 16.
Stars: ✭ 5,409 (+620.24%)
Mutual labels:  jsx
Bloomer
A set of React components for Bulma CSS Framework
Stars: ✭ 683 (-9.05%)
Mutual labels:  jsx
Condenser
The greatest application front-end to the Steem Blockchain.
Stars: ✭ 516 (-31.29%)
Mutual labels:  jsx
React Projects
A collection of projects built on the React library
Stars: ✭ 602 (-19.84%)
Mutual labels:  jsx
Jsx Next
JSX for Vue 3
Stars: ✭ 660 (-12.12%)
Mutual labels:  jsx
Hyperawesome
A curated list of awesome projects built with Hyperapp & more.
Stars: ✭ 446 (-40.61%)
Mutual labels:  jsx
Tslint
🚦 An extensible linter for the TypeScript language
Stars: ✭ 5,922 (+688.55%)
Mutual labels:  tslint
Rjsx Mode
A JSX major mode for Emacs
Stars: ✭ 604 (-19.57%)
Mutual labels:  jsx
Tslint To Eslint Config
Converts your TSLint configuration to the closest possible ESLint equivalent. 🚀
Stars: ✭ 680 (-9.45%)
Mutual labels:  tslint
Awesome Preact
A curated list of amazingly awesome things regarding Preact ecosystem 🌟
Stars: ✭ 546 (-27.3%)
Mutual labels:  jsx
Vhtml
Render JSX/Hyperscript to HTML strings, without VDOM 🌈
Stars: ✭ 556 (-25.97%)
Mutual labels:  jsx
Sagui
🐒 Front-end tooling in a single dependency
Stars: ✭ 676 (-9.99%)
Mutual labels:  jsx
Atomico
Atomico a micro-library for creating webcomponents using only functions, hooks and virtual-dom.
Stars: ✭ 481 (-35.95%)
Mutual labels:  jsx
Meriyah
A 100% compliant, self-hosted javascript parser - https://meriyah.github.io/meriyah
Stars: ✭ 690 (-8.12%)
Mutual labels:  jsx
React Multistep
React multistep form component
Stars: ✭ 473 (-37.02%)
Mutual labels:  jsx
Solid
A declarative, efficient, and flexible JavaScript library for building user interfaces.
Stars: ✭ 13,115 (+1646.34%)
Mutual labels:  jsx
Vim Jsx Pretty
🔦 [Vim script] JSX and TSX syntax pretty highlighting for vim.
Stars: ✭ 717 (-4.53%)
Mutual labels:  jsx
Mdx Util
Utilities for working with MDX
Stars: ✭ 709 (-5.59%)
Mutual labels:  jsx
Ok Mdx
Browser-based MDX editor
Stars: ✭ 681 (-9.32%)
Mutual labels:  jsx

NPM version Downloads Circle CI

tslint-react

Lint rules related to React & JSX for TSLint.

Usage

tslint-react has peer dependencies on TSLint and TypeScript.

To use these lint rules with the default preset, use configuration inheritance via the extends keyword. Here's a sample configuration where tslint.json lives adjacent to your node_modules folder:

{
  "extends": ["tslint:latest", "tslint-react"],
  "rules": {
    // override tslint-react rules here
    "jsx-wrap-multiline": false
  }
}

To lint your .ts and .tsx files you can simply run tslint -c tslint.json 'src/**/*.{ts,tsx}'.

Semantic versioning

The built-in configuration preset you get with "extends": "tslint-react" is semantically versioned in a manner similar to TSLint's built-in presets and the TypeScript language itself. As new rules are added to tslint-react across minor versions, stricter checks may be enabled here. Your code is not guaranteed to continue passing checks across these version bumps. If you wish to ensure that npm upgrade or yarn upgrade never breaks your build, declare a tilde dependency on this package (e.g. "~1.0.0").

Rules

  • jsx-alignment
    • Enforces a consistent style for multiline JSX elements which promotes ease of editing via line-wise manipulations as well as maintainability via small diffs when changes are made.
    // Good:
    const element = <div
        className="foo"
        tabIndex={1}
    >
        {children}
    </div>;
    
    // Also Good:
    <Button
        appearance="pretty"
        disabled
        label="Click Me"
        size={size}
    />
    
  • jsx-ban-elements (since v3.4.0)
    • Allows blacklisting of JSX elements with an optional explanatory message in the reported failure.
  • jsx-ban-props (since v2.3.0)
    • Allows blacklisting of props in JSX with an optional explanatory message in the reported failure.
  • jsx-boolean-value (since v2.5.0)
    • When using a boolean attribute in JSX, you can set the attribute value to true or omit the value. This rule will enforce one or the other to keep consistency in your code.
    • Rule options: ["always", "never"]
    • Default is set to always.
  • jsx-curly-spacing (since v1.1.0)
    • Requires or bans spaces between curly brace characters in JSX.
    • Rule options: ["always", "never"]
    • Includes automatic code fix
  • jsx-equals-spacing (since v3.2.0)
    • Requires or bans spaces before and after the = token in JSX element attributes.
    • Rule options: ["always", "never"]
    • Includes automatic code fix
  • jsx-key (since v3.2.0)
    • Warns for missing key props in JSX element array literals and inside return statements of Array.prototype.map callbacks.
      • N.B. This rule only does a simple check for .map(...) syntax and does not inspect computed types of expressions. As such, it may produce false positives if you use APIs that look similar to .map().
    • Rule options: none
  • jsx-no-bind (since v2.6.0)
    • Forbids function binding in JSX attributes. This has the same intent as jsx-no-lambda in helping you avoid excessive re-renders.
    • Note that this currently only does a simple syntactic check, not a semantic one (it doesn't use the type checker). So it may have some rare false positives if you define your own .bind function and supply this as a parameter.
    • Rule options: none
  • jsx-no-lambda
    • Creating new anonymous functions (with either the function syntax or ES2015 arrow syntax) inside the render call stack works against pure component rendering. When doing an equality check between two lambdas, React will always consider them unequal values and force the component to re-render more often than necessary.
    • Rule options: none
  • jsx-no-multiline-js
    • Disallows multiline JS expressions inside JSX blocks to promote readability
    • Rule options: none
  • jsx-no-string-ref
    • Passing strings to the ref prop of React elements is considered a legacy feature and will soon be deprecated. Instead, use a callback.
    • Rule options: none
  • jsx-use-translation-function (since v2.4.0)
    • Enforces use of a translation function. Plain string literals are disallowed in JSX when enabled.
    • Rule options: ["allow-punctuation", "allow-htmlentities"]
    • Off by default
  • jsx-self-close (since v0.4.0)
    • Enforces that JSX elements with no children are self-closing.
    • Includes automatic code fix
    // bad
    <div className="foo"></div>
    // good
    <div className="foo" />
    
    • Rule options: none
  • jsx-space-before-trailing-slash
    • Checks that self-closing JSX elements have a space before the '/>' part.
    • Rule options: none
    • Includes automatic code fix
  • jsx-wrap-multiline (since v2.1)
    • Enforces that multiline JSX expressions are wrapped with parentheses.
    • Opening parenthesis must be followed by a newline.
    • Closing parenthesis must be preceded by a newline.
    // bad
    const button = <button type="submit">
        Submit
    </button>;
    // good
    const button = (
        <button type="submit">
            Submit
        </button>
    );
    

Development

We track rule suggestions on Github issues -- here's a useful link to view all the current suggestions. Tickets are roughly triaged by priority (P1, P2, P3).

We're happy to accept PRs for new rules, especially those marked as Status: Accepting PRs. If submitting a PR, try to follow the same style conventions as the core TSLint project.

Quick Start (requires Node v6+, yarn v0.22+):

  1. yarn
  2. yarn verify
  3. yarn lint

Changelog

See the Github release history.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].