Skip to content

Commit de8e7c3

Browse files
authored
style: Switch to airbnb linting + prettier formatting 🎨 (#81)
1 parent 3b0753a commit de8e7c3

36 files changed

+760
-330
lines changed

.eslintrc.json

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,68 @@
11
{
22
"parser": "babel-eslint",
3-
"extends": ["standard", "react-app", "eslint:recommended"],
3+
"extends": "airbnb",
4+
"plugins": ["react", "jsx-a11y", "import"],
5+
"env": {
6+
"browser": true,
7+
"node": true,
8+
"jest": true,
9+
"es6": true
10+
},
411
"rules": {
5-
"react/jsx-filename-extension": [
6-
1,
7-
{
8-
"extensions": [".js", ".jsx"]
9-
}
10-
],
12+
"arrow-parens": [2, "as-needed"],
13+
"comma-dangle": ["warn", "never"],
14+
"global-require": 0,
1115
"import/no-extraneous-dependencies": [
1216
2,
1317
{
1418
"devDependencies": true
1519
}
1620
],
21+
"import/no-named-as-default": 0,
1722
"import/prefer-default-export": 0,
18-
"object-curly-newline": [
19-
"error",
23+
"linebreak-style": 0,
24+
"max-len": [
25+
1,
26+
150,
27+
2,
2028
{
21-
"ObjectExpression": { "multiline": true, "minProperties": 3 },
22-
"ObjectPattern": { "multiline": true, "minProperties": 3 },
23-
"ImportDeclaration": { "multiline": true, "minProperties": 3 },
24-
"ExportDeclaration": { "multiline": true, "minProperties": 3 }
29+
"ignoreComments": true,
30+
"ignoreTrailingComments": true,
31+
"ignoreTemplateLiterals": true,
32+
"ignoreStrings": true
2533
}
2634
],
35+
"no-nested-ternary": 0,
2736
"no-underscore-dangle": 0,
37+
"no-console": 0,
38+
"no-bitwise": [
39+
2,
40+
{
41+
"allow": ["~"]
42+
}
43+
],
44+
"no-param-reassign": 0,
2845
"no-plusplus": 0,
2946
"no-shadow": 0,
30-
"no-param-reassign": 0,
47+
"no-unused-expressions": [2, { "allowShortCircuit": true }],
48+
"object-curly-newline": 0,
49+
"react/forbid-prop-types": 0,
3150
"react/require-default-props": 0,
51+
"react/jsx-filename-extension": [
52+
1,
53+
{
54+
"extensions": [".js", ".jsx"]
55+
}
56+
],
57+
"react/jsx-wrap-multilines": 0,
58+
"react/jsx-closing-tag-location": 0,
59+
"react/sort-comp": 0,
3260
"semi": [2, "never"],
33-
"quotes": ["error", "single", { "avoidEscape": true }],
34-
"jsx-a11y/href-no-hash": 0
61+
"space-infix-ops": 0,
62+
"jsx-a11y/anchor-is-valid": 0,
63+
"jsx-a11y/label-has-for": 0,
64+
"jsx-a11y/no-static-element-interactions": 0,
65+
"jsx-a11y/click-events-have-key-events": 0
3566
},
3667
"globals": {
3768
"document": true

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "webpack-dev-server",
11+
"program": "${workspaceRoot}/node_modules/webpack-dev-server/bin/webpack-dev-server.js",
12+
"cwd": "${workspaceFolder}/docs"
13+
}
14+
]
15+
}

.vscode/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"spellright.documentTypes": [
44
"markdown",
55
"latex",
6-
"plaintext",
7-
"javascript"
6+
"plaintext"
87
]
98
}

docs/index.html

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<title>React Dropdown Tree Select Demo</title>
5-
<link rel="stylesheet" href="./index.css" />
6-
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
7-
</head>
8-
<body>
9-
<div id="app"></div>
10-
<script src="bundle.js"></script>
11-
</body>
3+
4+
<head>
5+
<title>React Dropdown Tree Select Demo</title>
6+
<link rel="stylesheet" href="./index.css" />
7+
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN"
8+
crossorigin="anonymous">
9+
</head>
10+
11+
<body>
12+
<div id="app"></div>
13+
<script src="bundle.js"></script>
14+
</body>
15+
1216
</html>

docs/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from 'react'
2+
import ReactDOM from 'react-dom'
3+
import Simple from './src/stories/Simple'
4+
5+
ReactDOM.render(<Simple />, document.getElementById('app'))

docs/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import ReactDOM from 'react-dom'
33

4-
import App from './App.js'
4+
import App from './App'
55

66
import './index.css'
77

docs/src/stories/HOCReadme.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
import marked from 'marked'
22
import React from 'react'
33

4-
import HOCReadme from '../../HOC.md'
54
import 'github-markdown-css/github-markdown.css'
6-
import './utils/prism.js'
5+
6+
import './utils/prism'
7+
8+
import HOCReadme from '../../HOC.md'
79

810
export default class HOCStory extends React.Component {
9-
render () {
11+
componentDidMount() {
12+
global.Prism && global.Prism.highlightAll()
13+
}
14+
15+
render() {
1016
return (
1117
<div style={{ padding: '10px' }}>
1218
<span
1319
className="markdown-body"
20+
// eslint-disable-next-line react/no-danger
1421
dangerouslySetInnerHTML={{ __html: marked(HOCReadme) }}
1522
/>
1623
</div>
1724
)
1825
}
19-
componentDidMount () {
20-
global.Prism && global.Prism.highlightAll()
21-
}
2226
}

docs/src/stories/Options/Checkbox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import React, { PureComponent } from 'react'
22
import PropTypes from 'prop-types'
33

44
class Checkbox extends PureComponent {
5-
state = {isChecked: this.props.checked || false}
5+
state = { isChecked: this.props.checked || false }
66

77
toggleCheckboxChange = () => {
88
const { onChange, value } = this.props
99

10-
this.setState(({ isChecked }) => ({isChecked: !isChecked}))
10+
this.setState(({ isChecked }) => ({ isChecked: !isChecked }))
1111

1212
onChange(value)
1313
}

docs/src/stories/Options/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class WithOptions extends PureComponent {
3535

3636
render() {
3737
const {
38-
clearSearchOnChange, keepTreeOnSearch, simpleSelect, showPartiallySelected
39-
} = this.state
38+
clearSearchOnChange, keepTreeOnSearch, simpleSelect, showPartiallySelected
39+
} = this.state
4040

4141
return (
4242
<div>

docs/src/stories/Readme.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
import marked from 'marked'
22
import React from 'react'
33

4-
import Readme from '../../../README.md'
54
import 'github-markdown-css/github-markdown.css'
6-
import './utils/prism.js'
5+
6+
import './utils/prism'
7+
8+
import Readme from '../../../README.md'
79

810
export default class Story extends React.Component {
9-
render () {
11+
componentDidMount() {
12+
global.Prism && global.Prism.highlightAll()
13+
}
14+
15+
render() {
1016
return (
1117
<div style={{ padding: '10px' }}>
1218
<span
1319
className="markdown-body"
20+
// eslint-disable-next-line react/no-danger
1421
dangerouslySetInnerHTML={{ __html: marked(Readme) }}
1522
/>
1623
</div>
1724
)
1825
}
19-
componentDidMount () {
20-
global.Prism && global.Prism.highlightAll()
21-
}
2226
}

0 commit comments

Comments
 (0)