Skip to content

Commit cb7c3c2

Browse files
committed
Create & publish eslint-config-npr-react
1 parent 742339f commit cb7c3c2

10 files changed

Lines changed: 147 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["airbnb"]
3+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
end_of_line = lf
10+
# editorconfig-tools is unable to ignore longs strings or urls
11+
max_line_length = null
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./index.js",
3+
"rules": {
4+
// disable requiring trailing commas because it might be nice to revert to
5+
// being JSON at some point, and I don't want to make big changes now.
6+
"comma-dangle": 0
7+
},
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
16.1.0 / 2017-12-13
2+
==================
3+
- Initial commit; building off of `eslint-config-airbnb` package.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# eslint-config-npr-react
2+
3+
This package provides NPR's JS .eslintrc with React plugins as an extensible shared config.
4+
5+
It extends Airbnb's full configuration with NPR's style guide.
6+
7+
## Usage
8+
9+
Our default export contains all of our ESLint rules, including ECMAScript 6+.
10+
11+
It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`. If you don't need React, see [eslint-config-npr-base](https://www.npmjs.com/package/@npr/eslint-config-npr-base).
12+
13+
If you use yarn, run `npm info "@npr/eslint-config-npr-react@latest" peerDependencies` to list the peer dependencies and versions, then run `yarn add --dev <dependency>@<version>` for each listed peer dependency. See below for npm instructions.
14+
15+
1. Install the correct versions of each package, which are listed by the command:
16+
17+
```sh
18+
npm info "@npr/eslint-config-npr-react@latest" peerDependencies
19+
```
20+
21+
Linux/OSX users can run
22+
23+
```sh
24+
(
25+
export PKG=@npr/eslint-config-npr-react;
26+
npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
27+
)
28+
```
29+
30+
Which produces and runs a command like:
31+
32+
```sh
33+
npm install --save-dev @npr/eslint-config-npr-react eslint@^#.#.# eslint-plugin-jsx-a11y@^#.#.# eslint-plugin-import@^#.#.# eslint-plugin-react@^#.#.#
34+
```
35+
36+
Windows users can either install all the peer dependencies manually, or use the [install-peerdeps](https://github.com/nathanhleung/install-peerdeps) cli tool.
37+
38+
```sh
39+
npm install -g install-peerdeps
40+
install-peerdeps --dev @npr/eslint-config-npr-react
41+
```
42+
43+
The cli will produce and run a command like:
44+
45+
```sh
46+
npm install --save-dev @npr/eslint-config-npr-react eslint@^#.#.# eslint-plugin-jsx-a11y@^#.#.# eslint-plugin-import@^#.#.# eslint-plugin-react@^#.#.#
47+
```
48+
49+
2. Add `"extends": "@npr/esling-config-npr-react"` to your .eslintrc
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
extends: [
3+
'eslint-config-airbnb',
4+
'@npr/eslint-config-npr-base',
5+
'./rules/react',
6+
].map(require.resolve),
7+
rules: {},
8+
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "@npr/eslint-config-npr-react",
3+
"version": "16.1.0",
4+
"description": "NPR's React style guide for JavaScript",
5+
"main": "index.js",
6+
"scripts": {
7+
"prelint": "editorconfig-tools check * rules/* test/*",
8+
"lint": "eslint --report-unused-disable-directives .",
9+
"tests-only": "babel-tape-runner ./test/test-*.js",
10+
"prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test)",
11+
"pretest": "npm run --silent lint",
12+
"test": "npm run --silent tests-only"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/npr/javascript.git"
17+
},
18+
"keywords": [
19+
"javascript",
20+
"style"
21+
],
22+
"author": "Stephen Thompson <apostrophest@gmail.com>",
23+
"license": "UNLICENSED",
24+
"bugs": {
25+
"url": "https://github.com/npr/javascript/issues"
26+
},
27+
"homepage": "https://github.com/npr/javascript#readme",
28+
"devDependencies": {
29+
"babel-preset-airbnb": "^2.4.0",
30+
"babel-tape-runner": "^2.0.1",
31+
"editorconfig-tools": "^0.1.1",
32+
"eslint": "^4.9.0",
33+
"eslint-find-rules": "^3.1.1",
34+
"eslint-plugin-import": "^2.7.0",
35+
"in-publish": "^2.0.0",
36+
"safe-publish-latest": "^1.1.1",
37+
"tape": "^4.8.0"
38+
},
39+
"engines": {
40+
"node": ">= 6"
41+
},
42+
"dependencies": {
43+
"@npr/eslint-config-npr-base": "^12.1.0",
44+
"eslint-config-airbnb": "^16.1.0"
45+
}
46+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
rules: {
3+
'react/jsx-indent-props': ['error', 4],
4+
'react/jsx-indent': ['error', 4],
5+
'react/jsx-filename-extension': 'off',
6+
'react/button-has-type': 'warn',
7+
'react/destructuring-assignment': 'off',
8+
'react/jsx-one-expression-per-line': 'error',
9+
'react/no-access-state-in-setstate': 'warn',
10+
}
11+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"rules": {
3+
// disabled because I find it tedious to write tests while following this rule
4+
"no-shadow": 0,
5+
// tests uses `t` for tape
6+
"id-length": [2, {"min": 2, "properties": "never", "exceptions": ["t"]}],
7+
}
8+
}

‎packages/eslint-config-npr-react/test/test-base.js‎

Whitespace-only changes.

0 commit comments

Comments
 (0)