Skip to content

Commit db69983

Browse files
authored
Merge pull request #1057 from ccoenen/eslint
switching to eslint for code checking
2 parents f9aa001 + 858a595 commit db69983

File tree

13 files changed

+75
-44
lines changed

13 files changed

+75
-44
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
lib/ot
2+
public/vendor
3+
public/build

.eslintrc.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
"root": true,
3+
"extends": "standard",
4+
"env": {
5+
"node": true
6+
},
7+
"rules": {
8+
// at some point all of these should return to their default "error" state
9+
// but right now, this is not a good choice, because too many places are
10+
// wrong.
11+
"import/first": ["warn"],
12+
"indent": ["warn"],
13+
"no-multiple-empty-lines": ["warn"],
14+
"no-multi-spaces": ["warn"],
15+
"object-curly-spacing": ["warn"],
16+
"one-var": ["warn"],
17+
"quotes": ["warn"],
18+
"semi": ["warn"],
19+
"space-infix-ops": ["warn"]
20+
}
21+
};

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
CodiMD
22
===
33

4-
[![Standard - JavaScript Style Guide][standardjs-image]][standardjs-url]
5-
64
[![#CodiMD on matrix.org][matrix.org-image]][matrix.org-url]
75
[![build status][travis-image]][travis-url]
86
[![version][github-version-badge]][github-release-page]
@@ -373,7 +371,5 @@ See more at [http://operational-transformation.github.io/](http://operational-tr
373371
[travis-url]: https://travis-ci.org/hackmdio/codimd
374372
[github-version-badge]: https://img.shields.io/github/release/hackmdio/codimd.svg
375373
[github-release-page]: https://github.com/hackmdio/codimd/releases
376-
[standardjs-image]: https://cdn.rawgit.com/feross/standard/master/badge.svg
377-
[standardjs-url]: https://github.com/feross/standard
378374
[poeditor-image]: https://img.shields.io/badge/POEditor-translate-blue.svg
379375
[poeditor-url]: https://poeditor.com/join/project/1OpGjF2Jir

lib/models/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ if (config.dbURL) {
2525
// https://github.com/sequelize/sequelize/issues/6485
2626
function stripNullByte (value) {
2727
value = '' + value
28+
// eslint-disable-next-line no-control-regex
2829
return value ? value.replace(/\u0000/g, '') : value
2930
}
3031
sequelize.stripNullByte = stripNullByte

lib/models/user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = function (sequelize, DataTypes) {
5050
}, {
5151
instanceMethods: {
5252
verifyPassword: function (attempt) {
53-
if (scrypt.verifyKdfSync(new Buffer(this.password, 'hex'), attempt)) {
53+
if (scrypt.verifyKdfSync(Buffer.from(this.password, 'hex'), attempt)) {
5454
return this
5555
} else {
5656
return false

lib/realtime.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ function getStatus (callback) {
242242
}
243243
})
244244
models.User.count().then(function (regcount) {
245+
// eslint-disable-next-line standard/no-callback-literal
245246
return callback ? callback({
246247
onlineNotes: Object.keys(notes).length,
247248
onlineUsers: Object.keys(users).length,
@@ -283,7 +284,7 @@ function extractNoteIdFromSocket (socket) {
283284
if (!referer) {
284285
return false
285286
}
286-
var hostUrl = url.parse(referer)
287+
var hostUrl = url.URL.parse(referer)
287288
var noteId = config.urlPath ? hostUrl.pathname.slice(config.urlPath.length + 1, hostUrl.pathname.length).split('/')[1] : hostUrl.pathname.split('/')[1]
288289
return noteId
289290
} else {

lib/web/imageRouter/filesystem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ exports.uploadImage = function (imagePath, callback) {
1616
return
1717
}
1818

19-
callback(null, url.resolve(config.serverURL + '/uploads/', path.basename(imagePath)))
19+
callback(null, url.URL.resolve(config.serverURL + '/uploads/', path.basename(imagePath)))
2020
}

package.json

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"main": "app.js",
66
"license": "AGPL-3.0",
77
"scripts": {
8-
"test": "npm run-script standard && npm run-script jsonlint",
8+
"test": "npm run-script eslint && npm run-script jsonlint",
9+
"eslint": "node_modules/.bin/eslint lib public app.js",
910
"jsonlint": "find . -not -path './node_modules/*' -type f -name '*.json' -o -type f -name '*.json.example' | while read json; do echo $json ; jq . $json; done",
10-
"standard": "node ./node_modules/standard/bin/cmd.js",
11+
"standard": "echo 'standard is no longer being used, use `npm run eslint` instead!' && exit 1",
1112
"dev": "webpack --config webpack.dev.js --progress --colors --watch",
1213
"build": "webpack --config webpack.prod.js --progress --colors --bail",
1314
"postinstall": "bin/heroku",
@@ -169,6 +170,12 @@
169170
"css-loader": "^1.0.0",
170171
"doctoc": "^1.3.0",
171172
"ejs-loader": "^0.3.1",
173+
"eslint": "^5.9.0",
174+
"eslint-config-standard": "^12.0.0",
175+
"eslint-plugin-import": "^2.14.0",
176+
"eslint-plugin-node": "^8.0.0",
177+
"eslint-plugin-promise": "^4.0.1",
178+
"eslint-plugin-standard": "^4.0.0",
172179
"exports-loader": "^0.7.0",
173180
"expose-loader": "^0.7.5",
174181
"file-loader": "^2.0.0",
@@ -180,7 +187,6 @@
180187
"mini-css-extract-plugin": "^0.4.1",
181188
"optimize-css-assets-webpack-plugin": "^5.0.0",
182189
"script-loader": "^0.7.2",
183-
"standard": "^9.0.1",
184190
"string-loader": "^0.0.1",
185191
"style-loader": "^0.21.0",
186192
"uglifyjs-webpack-plugin": "^1.2.7",
@@ -190,34 +196,6 @@
190196
"webpack-merge": "^4.1.4",
191197
"webpack-parallel-uglify-plugin": "^1.1.0"
192198
},
193-
"standard": {
194-
"globals": [
195-
"$",
196-
"CodeMirror",
197-
"Cookies",
198-
"moment",
199-
"editor",
200-
"ui",
201-
"Spinner",
202-
"modeType",
203-
"Idle",
204-
"serverurl",
205-
"key",
206-
"gapi",
207-
"Dropbox",
208-
"FilePicker",
209-
"ot",
210-
"MediaUploader",
211-
"hex2rgb",
212-
"num_loaded",
213-
"Visibility",
214-
"inlineAttachment"
215-
],
216-
"ignore": [
217-
"lib/ot",
218-
"public/vendor"
219-
]
220-
},
221199
"optionalDependencies": {
222200
"bufferutil": "^4.0.0",
223201
"utf-8-validate": "^5.0.1"

public/.eslintrc.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// this config file is used in concert with the root .eslintrc.js in the root dir.
2+
module.exports = {
3+
"env": {
4+
"browser": true
5+
},
6+
"globals": {
7+
"$": false,
8+
"CodeMirror": false,
9+
"Cookies": false,
10+
"moment": false,
11+
"editor": false,
12+
"ui": false,
13+
"Spinner": false,
14+
"modeType": false,
15+
"Idle": false,
16+
"serverurl": false,
17+
"key": false,
18+
"gapi": false,
19+
"Dropbox": false,
20+
"FilePicker": false,
21+
"ot": false,
22+
"MediaUploader": false,
23+
"hex2rgb": false,
24+
"num_loaded": false,
25+
"Visibility": false,
26+
"inlineAttachment": false
27+
}
28+
};

public/js/history.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export function getStorageHistory (callback) {
218218
if (typeof data === 'string') { data = JSON.parse(data) }
219219
callback(data)
220220
}
221+
// eslint-disable-next-line standard/no-callback-literal
221222
callback([])
222223
}
223224

0 commit comments

Comments
 (0)