Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including eslint-config-nrk with all npm packages installed. Try it out:

require("eslint/package.json"); // eslint is a peer dependency. var eslintConfigNrk = require("eslint-config-nrk")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

eslint-config-nrk v5.1.0

A shared ESLint configuration for and by JavaScript developers at NRK.

eslint-config-nrk Build Status Coverage Status npm version

A shared ESLint configuration for and by JavaScript developers at NRK.

Installation

Get started by running this command in the root of your project (npm is also supported):

yarn add eslint eslint-config-nrk --dev

Then add an .eslintrc.json file to the root of your project (see Documentation below) before running the eslint command, with the following:

{
  "extends": [
    "nrk"
  ]
}

NOTE: eslint plugins are available for most modern text editors, like Atom, emacs, vim, Sublime Text, etc.

Documentation

Basic configuration

eslint is configured by adding an .eslintrc.json file to the root of a project where env and extends are specified. Refer to the eslint documentation for more configuration options.

The following example shows a typical setup for linting both browser and Node.js (CommonJS) code:

{
  "env": {
    "browser": true,
    "node": true
  },
  "extends": [
    "nrk"
  ]
}

React configuration

For supporting React projects, also add the nrk/rules/react extension:

{
  "env": {
    "browser": true,
    "node": true
  },
  "extends": [
    "nrk",
    "nrk/rules/react"
  ]
}

Then install eslint-plugin-react:

yarn add eslint-plugin-react --dev

JSX

For supporting JSX, also add the nrk/rules/jsx extension:

{
  "env": {
    "browser": true,
    "node": true
  },
  "extends": [
    "nrk",
    "nrk/rules/react",
    "nrk/rules/jsx"
  ]
}

It is necessary to configure eslint to lint files matching the .jsx extension:

eslint . --ext=.js,.jsx

Please note that the nrk/rules/jsx configuration is always using the latest version of React. When using an older version, please refer to the eslint-plugin-react documentation.

Legacy ES5 projects

This configuration is available as a way of migrating to a more modern codebase (recommended).

{
  "env": {
    "browser": true,
    "node": true
  },
  "extends": [
    "nrk/es5"
  ]
}
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free