Skip to content

Commit 5bb89c1

Browse files
committed
Merge branch 'develop'
2 parents 7eb8b02 + 88db73a commit 5bb89c1

File tree

6 files changed

+1909
-41
lines changed

6 files changed

+1909
-41
lines changed

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
'extends': './index.js',
3+
}

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
eslint-config-planck
22
====================
33

4-
ESLint config for [Planck framework](https://takram.com/projects/planck) and related source codes based on [Airbnb’s](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb).
4+
ESLint config for [Planck framework](https://takram.com/projects/planck) and related source codes based on [Airbnb’s](https://github.com/airbnb/javascript).
55

66
[![License](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat
77
)](http://mit-license.org)
@@ -13,15 +13,13 @@ ESLint config for [Planck framework](https://takram.com/projects/planck) and rel
1313

1414
```sh
1515
npm install @takram/eslint-config-planck
16-
17-
# Install peer dependencies
1816
```
1917

2018
## License
2119

2220
The MIT License
2321

24-
Copyright (C) 2016-Present Shota Matsuda
22+
Copyright (C) 2017-Present Shota Matsuda
2523

2624
Permission is hereby granted, free of charge, to any person obtaining a
2725
copy of this software and associated documentation files (the "Software"),

example.js

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
//
2+
// The MIT License
3+
//
4+
// Copyright (C) 2017-Present Shota Matsuda
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a
7+
// copy of this software and associated documentation files (the "Software"),
8+
// to deal in the Software without restriction, including without limitation
9+
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
10+
// and/or sell copies of the Software, and to permit persons to whom the
11+
// Software is furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19+
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22+
// DEALINGS IN THE SOFTWARE.
23+
//
24+
25+
// arrow-body-style
26+
{
27+
const veryLongNameFunction = () => {
28+
return 'this is very long but still a single statement'
29+
}
30+
veryLongNameFunction()
31+
}
32+
33+
// arrow-parens
34+
{
35+
const f = a => b => c => {
36+
return a + b + c
37+
}
38+
f(1)(2)(3)
39+
}
40+
41+
// class-methods-use-this
42+
{
43+
class T {
44+
f() {}
45+
}
46+
new T().f()
47+
}
48+
49+
// no-bitwise
50+
{
51+
function f(v) {}
52+
const v = 1 << 24
53+
f(v)
54+
}
55+
56+
// no-empty
57+
try {
58+
throw new Error()
59+
} catch (error) {}
60+
61+
// new-cap
62+
{
63+
class T {
64+
f() {}
65+
}
66+
const indirectClass = T
67+
const t = new indirectClass()
68+
t.f()
69+
}
70+
71+
// no-mixed-operators
72+
{
73+
function f() {}
74+
const v = 1 * 2 + 3
75+
f(v)
76+
}
77+
78+
// no-nested-ternary
79+
{
80+
function f(a, b) {
81+
return (a > b) ? 1 : (a < b) ? -1 : 0
82+
}
83+
f(1, 2)
84+
}
85+
86+
// no-plusplus
87+
{
88+
function f() {}
89+
let i = 0
90+
++i
91+
i++
92+
f(i)
93+
}
94+
95+
// no-shadow
96+
{
97+
function f() {}
98+
const a = 0
99+
{
100+
const a = 0
101+
f(a)
102+
}
103+
f(a)
104+
}
105+
106+
// no-unused-vars
107+
{
108+
function f(a) {}
109+
f()
110+
}

index.js

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,16 @@
2222
// DEALINGS IN THE SOFTWARE.
2323
//
2424

25-
/* eslint-disable quote-props */
26-
2725
module.exports = {
28-
'parserOptions': {
29-
'ecmaVersion': 2017,
30-
'sourceType': 'module',
31-
'ecmaFeatures': {
32-
'generators': false,
33-
'objectLiteralDuplicateProperties': false,
34-
},
35-
},
36-
37-
'extends': 'airbnb',
26+
extends: 'airbnb',
3827

39-
'rules': {
28+
rules: {
4029
// Prefer line length limit over this rule
4130
'arrow-body-style': 0,
4231

4332
// Won't cause any problem
4433
'arrow-parens': ['error', 'as-needed', {
45-
'requireForBlockBody': false,
34+
requireForBlockBody: false,
4635
}],
4736

4837
// Insane
@@ -53,32 +42,45 @@ module.exports = {
5342

5443
// Allow for catch statements
5544
'no-empty': ['error', {
56-
'allowEmptyCatch': true,
45+
allowEmptyCatch: true,
5746
}],
5847

5948
// Limit to 80 except import/export expressions
60-
'max-len': ['error', {
61-
'code': 80,
62-
'ignorePattern': '^\\s*(import|export)',
49+
'max-len': ['error', 80, 2, {
50+
ignoreUrls: true,
51+
ignoreComments: false,
52+
ignoreRegExpLiterals: true,
53+
ignoreStrings: true,
54+
ignoreTemplateLiterals: true,
6355
}],
6456

6557
// Allow for names ending with "Class"
6658
'new-cap': ['error', {
67-
'newIsCap': true,
68-
'newIsCapExceptions': [],
69-
'newIsCapExceptionPattern': 'Class$',
70-
'capIsNew': false,
59+
newIsCap: true,
60+
newIsCapExceptions: [],
61+
newIsCapExceptionPattern: 'Class$',
62+
capIsNew: false,
63+
capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'],
7164
}],
7265

7366
// We know the math
7467
'no-mixed-operators': ['error', {
75-
'groups': [
68+
groups: [
69+
['%', '**'],
70+
['%', '+'],
71+
['%', '-'],
72+
['%', '*'],
73+
['%', '/'],
74+
['**', '+'],
75+
['**', '-'],
76+
['**', '*'],
77+
['**', '/'],
7678
['&', '|', '^', '~', '<<', '>>', '>>>'],
7779
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
7880
['&&', '||'],
7981
['in', 'instanceof'],
8082
],
81-
'allowSamePrecedence': false,
83+
allowSamePrecedence: false,
8284
}],
8385

8486
// Not sure and we need to format codes carefully
@@ -92,11 +94,12 @@ module.exports = {
9294

9395
// Insane for arguments
9496
'no-unused-vars': ['error', {
95-
'vars': 'all',
96-
'args': 'none',
97+
vars: 'all',
98+
args: 'none',
99+
ignoreRestSiblings: true,
97100
}],
98101

99102
// Prefer simpler syntax
100-
'semi': ['error', 'never'],
103+
semi: ['error', 'never'],
101104
},
102105
}

0 commit comments

Comments
 (0)