Note: This is a fork of the great eslint-plugin-react.
Inferno specific linting rules for ESLint Rules are mostly same, but propType related rules have been removed.
Install ESLint either locally or globally.
$ npm install eslint --save-devIf you installed ESLint globally, you have to install Inferno plugin globally too. Otherwise, install it locally.
$ npm install eslint-plugin-inferno --save-devAdd plugins section and specify ESLint-plugin-Inferno as a plugin.
{
"plugins": [
"inferno"
]
}You can also specify some settings that will be shared across all the plugin rules.
{
"settings": {
"inferno": {
"pragma": "Inferno" // Pragma to use, default to "Inferno"
}
}
}If it is not already the case you must also configure ESLint to support JSX.
With ESLint 1.x.x:
{
"ecmaFeatures": {
"jsx": true
}
}With ESLint 2.x.x or 3.x.x:
{
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
}
}Finally, enable all of the rules that you would like to use. Use our preset to get reasonable defaults quickly, and/or choose your own:
"rules": {
"inferno/jsx-uses-inferno": "error",
"inferno/jsx-uses-vars": "error",
}These rules have been removed, because they are invalid in Inferno
- react/boolean-prop-naming: Enforces consistent naming for boolean props
- react/default-props-match-prop-types: Prevent extraneous defaultProps on components
- react/display-name: Prevent missing
displayNamein a Inferno component definition - react/forbid-prop-types: Forbid certain propTypes
- react/forbid-foreign-prop-types: Forbid foreign propTypes
- react/no-deprecated: Prevent usage of deprecated methods
- react/no-unused-prop-types: Prevent definitions of unused prop types
- react/prop-types: Prevent missing props validation in a Inferno component definition
- react/sort-prop-types: Enforce propTypes declarations alphabetical sorting
- react/require-default-props: Enforce a defaultProps definition for every prop that is not a required prop
- inferno/forbid-component-props: Forbid certain props on Components
- inferno/forbid-elements: Forbid certain elements
- inferno/no-array-index-key: Prevent using Array index in
keyprops - inferno/no-children-prop: Prevent passing children as props
- inferno/no-danger: Prevent usage of dangerous JSX properties
- inferno/no-danger-with-children: Prevent problem with children and props.dangerouslySetInnerHTML
- inferno/no-did-mount-set-state: Prevent usage of
setStateincomponentDidMount - inferno/no-did-update-set-state: Prevent usage of
setStateincomponentDidUpdate - inferno/no-direct-mutation-state: Prevent direct mutation of
this.state - inferno/no-find-dom-node: Prevent usage of
findDOMNode - inferno/no-is-mounted: Prevent usage of
isMounted - inferno/no-multi-comp: Prevent multiple component definition per file
- inferno/no-redundant-should-component-update: Prevent usage of
shouldComponentUpdatewhen extending Inferno.PureComponent - inferno/no-render-return-value: Prevent usage of the return value of
Inferno.render - inferno/no-set-state: Prevent usage of
setState - inferno/no-typos: Prevent common casing typos
- inferno/no-string-refs: Prevent using string references in
refattribute. - inferno/no-unescaped-entities: Prevent invalid characters from appearing in markup
- inferno/no-unknown-property: Prevent usage of unknown DOM property (fixable)
- inferno/no-will-update-set-state: Prevent usage of
setStateincomponentWillUpdate - inferno/prefer-es6-class: Enforce ES5 or ES6 class for Inferno Components
- inferno/prefer-stateless-function: Enforce stateless Inferno Components to be written as a pure function
- inferno/inferno-in-jsx-scope: Prevent missing
Infernowhen using JSX - inferno/require-optimization: Enforce Inferno components to have a
shouldComponentUpdatemethod - inferno/require-render-return: Enforce ES5 or ES6 class for returning value in render function
- inferno/self-closing-comp: Prevent extra closing tags for components without children (fixable)
- inferno/sort-comp: Enforce component methods order (fixable)
- inferno/style-prop-object: Enforce style prop value being an object
- inferno/void-dom-elements-no-children: Prevent void DOM elements (e.g.
<img />,<br />) from receiving children
- inferno/jsx-boolean-value: Enforce boolean attributes notation in JSX (fixable)
- inferno/jsx-closing-bracket-location: Validate closing bracket location in JSX (fixable)
- inferno/jsx-closing-tag-location: Validate closing tag location in JSX (fixable)
- inferno/jsx-curly-spacing: Enforce or disallow spaces inside of curly braces in JSX attributes and expressions (fixable)
- inferno/jsx-equals-spacing: Enforce or disallow spaces around equal signs in JSX attributes (fixable)
- inferno/jsx-filename-extension: Restrict file extensions that may contain JSX
- inferno/jsx-first-prop-new-line: Enforce position of the first prop in JSX (fixable)
- inferno/jsx-handler-names: Enforce event handler naming conventions in JSX
- inferno/jsx-indent: Validate JSX indentation (fixable)
- inferno/jsx-indent-props: Validate props indentation in JSX (fixable)
- inferno/jsx-key: Validate JSX has key prop when in array or iterator
- inferno/jsx-max-props-per-line: Limit maximum of props on a single line in JSX (fixable)
- inferno/jsx-no-bind: Prevent usage of
.bind()and arrow functions in JSX props - inferno/jsx-no-comment-textnodes: Prevent comments from being inserted as text nodes
- inferno/jsx-no-duplicate-props: Prevent duplicate props in JSX
- inferno/jsx-no-literals: Prevent usage of unwrapped JSX strings
- inferno/jsx-no-target-blank: Prevent usage of unsafe
target='_blank' - inferno/jsx-no-undef: Disallow undeclared variables in JSX
- inferno/jsx-curly-brace-presence: Enforce curly braces or disallow unnecessary curly braces in JSX
- inferno/jsx-pascal-case: Enforce PascalCase for user-defined JSX components
- inferno/jsx-sort-props: Enforce props alphabetical sorting (fixable)
- inferno/jsx-space-before-closing: Validate spacing before closing bracket in JSX (fixable)
- inferno/jsx-tag-spacing: Validate whitespace in and around the JSX opening and closing brackets (fixable)
- inferno/jsx-uses-inferno: Prevent Inferno to be incorrectly marked as unused
- inferno/jsx-uses-vars: Prevent variables used in JSX to be incorrectly marked as unused
- inferno/jsx-wrap-multilines: Prevent missing parentheses around multilines JSX (fixable)
- JSX accessibility: eslint-plugin-jsx-a11y
This plugin exports a recommended configuration that enforce Inferno good practices.
To enable this configuration use the extends property in your .eslintrc config file:
{
"extends": ["eslint:recommended", "plugin:inferno/recommended"]
}See ESLint documentation for more information about extending configuration files.
The rules enabled in this configuration are:
- inferno/jsx-key
- inferno/jsx-no-comment-textnodes
- inferno/jsx-no-duplicate-props
- inferno/jsx-no-undef
- inferno/jsx-uses-inferno
- inferno/jsx-no-target-blank
- inferno/jsx-uses-vars
- inferno/no-direct-mutation-state
- inferno/no-find-dom-node
- inferno/no-children-prop
- inferno/no-danger-with-children
- inferno/no-render-return-value
- inferno/inferno-in-jsx-scope
- inferno/no-direct-mutation-state
- inferno/no-find-dom-node
- inferno/no-is-mounted
- inferno/no-string-refs
- inferno/no-unescaped-entities
- inferno/no-unknown-property
This plugin also exports an all configuration that includes every available rule.
This pairs well with the eslint:all rule.
{
"plugins": [
"inferno"
],
"extends": ["eslint:all", "plugin:inferno/all"]
}Note: These configurations will import eslint-plugin-inferno and enable JSX in parser options.
ESLint-plugin-Inferno is licensed under the MIT License.