Skip to content

Commit 9bb2365

Browse files
simon04perliedman
authored andcommitted
Use ESLint, Prettier for code linting+formatting (#188)
* Use ESLint, Prettier for code linting+formatting * Add .editorconfig
1 parent b848a1e commit 9bb2365

19 files changed

+1342
-1226
lines changed

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintrc.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
extends:
2+
- eslint:recommended
3+
4+
plugins:
5+
- prettier
6+
7+
env:
8+
browser: true
9+
es6: true
10+
11+
parserOptions:
12+
sourceType: module
13+
14+
rules:
15+
prettier/prettier: warn

.jshintrc

-54
This file was deleted.

.prettierrc.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
printWidth: 100
2+
singleQuote: true

Control.Geocoder.css

+71-68
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,126 @@
11
.leaflet-control-geocoder {
2-
border-radius: 4px;
3-
background: white;
4-
min-width: 26px;
5-
min-height: 26px;
2+
border-radius: 4px;
3+
background: white;
4+
min-width: 26px;
5+
min-height: 26px;
66
}
77

88
.leaflet-touch .leaflet-control-geocoder {
9-
min-width: 30px;
10-
min-height: 30px;
9+
min-width: 30px;
10+
min-height: 30px;
1111
}
1212

13-
.leaflet-control-geocoder a, .leaflet-control-geocoder .leaflet-control-geocoder-icon {
14-
border-bottom: none;
15-
display: inline-block;
13+
.leaflet-control-geocoder a,
14+
.leaflet-control-geocoder .leaflet-control-geocoder-icon {
15+
border-bottom: none;
16+
display: inline-block;
1617
}
1718

1819
.leaflet-control-geocoder .leaflet-control-geocoder-alternatives a {
19-
width: inherit;
20-
height: inherit;
21-
line-height: inherit;
20+
width: inherit;
21+
height: inherit;
22+
line-height: inherit;
2223
}
2324

24-
.leaflet-control-geocoder a:hover, .leaflet-control-geocoder .leaflet-control-geocoder-icon:hover {
25-
border-bottom: none;
26-
display: inline-block;
25+
.leaflet-control-geocoder a:hover,
26+
.leaflet-control-geocoder .leaflet-control-geocoder-icon:hover {
27+
border-bottom: none;
28+
display: inline-block;
2729
}
2830

2931
.leaflet-control-geocoder-form {
30-
display: none;
31-
vertical-align: middle;
32+
display: none;
33+
vertical-align: middle;
3234
}
3335
.leaflet-control-geocoder-expanded .leaflet-control-geocoder-form {
34-
display: inline-block;
36+
display: inline-block;
3537
}
3638
.leaflet-control-geocoder-form input {
37-
font-size: 120%;
38-
border: 0;
39-
background-color: transparent;
40-
width: 246px;
39+
font-size: 120%;
40+
border: 0;
41+
background-color: transparent;
42+
width: 246px;
4143
}
4244

4345
.leaflet-control-geocoder-icon {
44-
border-radius: 4px;
45-
width: 26px;
46-
height: 26px;
47-
border: none;
48-
background-color: white;
49-
background-image: url(images/geocoder.png);
50-
background-repeat: no-repeat;
51-
background-position: center;
52-
cursor: pointer;
46+
border-radius: 4px;
47+
width: 26px;
48+
height: 26px;
49+
border: none;
50+
background-color: white;
51+
background-image: url(images/geocoder.png);
52+
background-repeat: no-repeat;
53+
background-position: center;
54+
cursor: pointer;
5355
}
5456

5557
.leaflet-touch .leaflet-control-geocoder-icon {
56-
width: 30px;
57-
height: 30px;
58+
width: 30px;
59+
height: 30px;
5860
}
5961

6062
.leaflet-control-geocoder-throbber .leaflet-control-geocoder-icon {
61-
background-image: url(images/throbber.gif);
63+
background-image: url(images/throbber.gif);
6264
}
6365

6466
.leaflet-control-geocoder-form-no-error {
65-
display: none;
67+
display: none;
6668
}
6769

6870
.leaflet-control-geocoder-form input:focus {
69-
outline: none;
71+
outline: none;
7072
}
7173

7274
.leaflet-control-geocoder-form button {
73-
display: none;
75+
display: none;
7476
}
7577
.leaflet-control-geocoder-error {
76-
margin-top: 8px;
77-
margin-left: 8px;
78-
display: block;
79-
color: #444;
78+
margin-top: 8px;
79+
margin-left: 8px;
80+
display: block;
81+
color: #444;
8082
}
8183
.leaflet-control-geocoder-alternatives {
82-
display: block;
83-
width: 272px;
84-
list-style: none;
85-
padding: 0;
86-
margin: 0;
84+
display: block;
85+
width: 272px;
86+
list-style: none;
87+
padding: 0;
88+
margin: 0;
8789
}
8890

8991
.leaflet-control-geocoder-alternatives-minimized {
90-
display: none;
91-
height: 0;
92+
display: none;
93+
height: 0;
9294
}
9395
.leaflet-control-geocoder-alternatives li {
94-
white-space: nowrap;
95-
display: block;
96-
overflow: hidden;
97-
padding: 5px 8px;
98-
text-overflow: ellipsis;
99-
border-bottom: 1px solid #ccc;
100-
cursor: pointer;
96+
white-space: nowrap;
97+
display: block;
98+
overflow: hidden;
99+
padding: 5px 8px;
100+
text-overflow: ellipsis;
101+
border-bottom: 1px solid #ccc;
102+
cursor: pointer;
101103
}
102104

103-
.leaflet-control-geocoder-alternatives li a, .leaflet-control-geocoder-alternatives li a:hover {
104-
width: inherit;
105-
height: inherit;
106-
line-height: inherit;
107-
background: inherit;
108-
border-radius: inherit;
109-
text-align: left;
105+
.leaflet-control-geocoder-alternatives li a,
106+
.leaflet-control-geocoder-alternatives li a:hover {
107+
width: inherit;
108+
height: inherit;
109+
line-height: inherit;
110+
background: inherit;
111+
border-radius: inherit;
112+
text-align: left;
110113
}
111114

112115
.leaflet-control-geocoder-alternatives li:last-child {
113-
border-bottom: none;
116+
border-bottom: none;
114117
}
115-
.leaflet-control-geocoder-alternatives li:hover, .leaflet-control-geocoder-selected {
116-
background-color: #f5f5f5;
118+
.leaflet-control-geocoder-alternatives li:hover,
119+
.leaflet-control-geocoder-selected {
120+
background-color: #f5f5f5;
117121
}
118122
.leaflet-control-geocoder-address-detail {
119-
120123
}
121124
.leaflet-control-geocoder-address-context {
122-
color: #666;
123-
}
125+
color: #666;
126+
}

package.json

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
"build:js": "rollup --output.format=iife --name=L.Control.Geocoder --globals=leaflet:L src/index.js --output.file=dist/Control.Geocoder.js --sourcemap",
1010
"build:css": "cpr Control.Geocoder.css dist/ --overwrite",
1111
"build:img": "cpr images/ dist/images/ --overwrite",
12+
"test": "npm run lint",
13+
"lint": "npm run lint:js && npm run lint:css",
14+
"lint:js": "eslint 'src/**'",
15+
"lint:css": "prettier --list-different '*.css'",
1216
"publish": "sh ./scripts/publish.sh",
1317
"postpublish": "sh ./scripts/postpublish.sh"
1418
},
@@ -38,6 +42,9 @@
3842
"dependencies": {},
3943
"devDependencies": {
4044
"cpr": "^3.0.1",
45+
"eslint": "^4.15.0",
46+
"eslint-plugin-prettier": "^2.4.0",
47+
"prettier": "^1.9.2",
4148
"rollup": "^0.53.2"
4249
}
4350
}

0 commit comments

Comments
 (0)