Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit 3dfc938

Browse files
author
Alec Gibson
committed
Use .gitignore for defining ESLint's ignore pattern
This change uses our `.gitignore` file to define which files ESLint should ignore, so that all of our committed JavaScript has a consistent style.
1 parent a551de3 commit 3dfc938

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed

examples/leaderboard/server/index.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
var http = require("http");
2-
var ShareDB = require("sharedb");
3-
var connect = require("connect");
1+
var http = require('http');
2+
var ShareDB = require('sharedb');
3+
var connect = require('connect');
44
var serveStatic = require('serve-static');
55
var ShareDBMingoMemory = require('sharedb-mingo-memory');
66
var WebSocketJSONStream = require('@teamwork/websocket-json-stream');
77
var WebSocket = require('ws');
8-
var util = require('util');
98

109
// Start ShareDB
11-
var share = ShareDB({db: new ShareDBMingoMemory()});
10+
var share = new ShareDB({db: new ShareDBMingoMemory()});
1211

1312
// Create a WebSocket server
1413
var app = connect();
1514
app.use(serveStatic('.'));
1615
var server = http.createServer(app);
1716
var wss = new WebSocket.Server({server: server});
1817
server.listen(8080);
19-
console.log("Listening on http://localhost:8080");
18+
console.log('Listening on http://localhost:8080');
2019

2120
// Connect any incoming WebSocket connection with ShareDB
2221
wss.on('connection', function(ws, req) {
@@ -27,11 +26,13 @@ wss.on('connection', function(ws, req) {
2726
// Create initial documents
2827
var connection = share.connect();
2928
connection.createFetchQuery('players', {}, {}, function(err, results) {
30-
if (err) { throw err; }
29+
if (err) {
30+
throw err;
31+
}
3132

3233
if (results.length === 0) {
33-
var names = ["Ada Lovelace", "Grace Hopper", "Marie Curie",
34-
"Carl Friedrich Gauss", "Nikola Tesla", "Claude Shannon"];
34+
var names = ['Ada Lovelace', 'Grace Hopper', 'Marie Curie',
35+
'Carl Friedrich Gauss', 'Nikola Tesla', 'Claude Shannon'];
3536

3637
names.forEach(function(name, index) {
3738
var doc = connection.get('players', ''+index);

examples/textarea/client.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@ var sharedb = require('sharedb/lib/client');
22
var StringBinding = require('sharedb-string-binding');
33

44
// Open WebSocket connection to ShareDB server
5-
const WebSocket = require('reconnecting-websocket');
5+
var WebSocket = require('reconnecting-websocket');
66
var socket = new WebSocket('ws://' + window.location.host);
77
var connection = new sharedb.Connection(socket);
88

99
var element = document.querySelector('textarea');
1010
var statusSpan = document.getElementById('status-span');
11-
statusSpan.innerHTML = "Not Connected"
11+
statusSpan.innerHTML = 'Not Connected';
1212

13-
element.style.backgroundColor = "gray";
14-
socket.onopen = function(){
15-
statusSpan.innerHTML = "Connected"
16-
element.style.backgroundColor = "white";
13+
element.style.backgroundColor = 'gray';
14+
socket.onopen = function() {
15+
statusSpan.innerHTML = 'Connected';
16+
element.style.backgroundColor = 'white';
1717
};
1818

19-
socket.onclose = function(){
20-
statusSpan.innerHTML = "Closed"
21-
element.style.backgroundColor = "gray";
19+
socket.onclose = function() {
20+
statusSpan.innerHTML = 'Closed';
21+
element.style.backgroundColor = 'gray';
2222
};
2323

2424
socket.onerror = function() {
25-
statusSpan.innerHTML = "Error"
26-
element.style.backgroundColor = "red";
27-
}
25+
statusSpan.innerHTML = 'Error';
26+
element.style.backgroundColor = 'red';
27+
};
2828

2929
// Create local Doc instance mapped to 'examples' collection document with id 'textarea'
3030
var doc = connection.get('examples', 'textarea');
3131
doc.subscribe(function(err) {
3232
if (err) throw err;
33-
33+
3434
var binding = new StringBinding(element, doc, ['content']);
3535
binding.setup();
3636
});

examples/textarea/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function createDoc(callback) {
1414
doc.fetch(function(err) {
1515
if (err) throw err;
1616
if (doc.type === null) {
17-
doc.create({ content: '' }, callback);
17+
doc.create({content: ''}, callback);
1818
return;
1919
}
2020
callback();

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"scripts": {
2525
"test": "./node_modules/.bin/mocha && npm run lint",
2626
"test-cover": "node_modules/istanbul/lib/cli.js cover node_modules/mocha/bin/_mocha",
27-
"lint": "./node_modules/.bin/eslint 'lib/**/*.js' 'test/**/*.js'"
27+
"lint": "./node_modules/.bin/eslint --ignore-path .gitignore '**/*.js'",
28+
"lint:fix": "npm run lint -- --fix"
2829
},
2930
"repository": {
3031
"type": "git",

0 commit comments

Comments
 (0)