eslint-config-nrk
An open/shared JavaScript coding standard configuration for NRK.no. Uses eslint
2.x. If you're on version 1.x of eslint
, see the 1.x branch.
Installation
Execute these commands in the root of your project:
npm install --save-dev eslint
npm install --save-dev eslint-config-nrk
Usage with React
If you are using React, you also need to install eslint-plugin-react
within your project:
npm install --save-dev eslint-plugin-react
If you use the *.jsx
extension, tell eslint
explicitly to lint those files as well:
eslint . --ext=.js,.jsx
Configuration
eslint
is configured by adding an .eslintrc.json
file to the root of your project, where
you specify enviroment(s)
and extend the nrk
config. The following setup will lint your ES6 codebase:
{
"env": {
"browser": true
},
"extends": [
"nrk"
]
}
For React-support, you need to add the react
extension as well:
{
"env": {
"browser": true
},
"extends": [
"nrk",
"nrk/rules/react"
]
}
For JSX-support, add the jsx
extension:
{
"env": {
"browser": true
},
"extends": [
"nrk",
"nrk/rules/react",
"nrk/rules/jsx"
]
}
Please note that the default config is for version 15 of React. If you use an older version, please refer to the documentation
.
Legacy ES5 projects
{
"env": {
"browser": true
},
"extends": [
"nrk/es5"
]
}
See the ESlint config docs for more information.