Skip to content

Commit b5c27ca

Browse files
authored
Merge pull request #7738 from vector-im/revert-7737-revert-7490-lint
Re-apply "Run lint on travis builds and use modern node versions"
2 parents c6f70cb + 704a599 commit b5c27ca

18 files changed

+392
-182
lines changed

.travis.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,18 @@ sudo: required
1111
language: node_js
1212
node_js:
1313
# make sure we work with a range of node versions.
14-
# As of the time of writing:
15-
# - 4.x is still in LTS (until April 2018), but some of our deps (notably
16-
# extract-zip) don't work with it
17-
# - 5.x has been EOLed for nearly a year.
18-
# - 6.x is the active 'LTS' version
19-
# - 7.x is no longer supported
20-
# - 8.x is the current 'current' version (until October 2017)
2114
#
22-
# see: https://github.com/nodejs/LTS/
23-
#
24-
# anything before 6.3 ships with npm 3.9 or earlier, which had problems
25-
# with symlinks in node_modules (see
26-
# https://github.com/npm/npm/releases/tag/v3.10.0 'FIXES AND REFACTORING').
27-
- 6.3
28-
- 6
29-
- 7
15+
# Current status of node versions: https://github.com/nodejs/LTS/
16+
# We don't work with node 6 because it doesn't support package-lock
17+
# files which we need to avoid the broken version of base-x
18+
- 8
19+
- 10
3020
addons:
3121
chrome: stable
3222
install:
3323
# clone the deps with depth 1: we know we will only ever need that one
3424
# commit.
35-
- scripts/fetch-develop.deps.sh --depth 1 && npm install
25+
- npm install && scripts/fetch-develop.deps.sh --depth 1
26+
script:
27+
- npm run test
28+
- npm run lint

package-lock.json

Lines changed: 291 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"autoprefixer": "^6.6.0",
8585
"babel-cli": "^6.26.0",
8686
"babel-core": "^6.26.3",
87-
"babel-eslint": "^6.1.2",
87+
"babel-eslint": "^8.1.1",
8888
"babel-loader": "^7.1.5",
8989
"babel-plugin-add-module-exports": "^0.2.1",
9090
"babel-plugin-transform-async-to-bluebird": "^1.1.1",

src/components/structures/VectorHomePage.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717

1818
'use strict';
1919

20-
import React from 'react';
2120
import HomePage from 'matrix-react-sdk/lib/components/structures/HomePage';
2221
import sanitizeHtml from 'sanitize-html';
2322
import { _t } from 'matrix-react-sdk/lib/languageHandler';

src/components/views/login/VectorCustomServerDialog.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
var React = require("react");
19-
var sanitizeHtml = require("sanitize-html");
18+
const React = require("react");
19+
const sanitizeHtml = require("sanitize-html");
2020
import { _t } from 'matrix-react-sdk/lib/languageHandler';
2121

2222
module.exports = React.createClass({
@@ -47,5 +47,5 @@ module.exports = React.createClass({
4747
</div>
4848
</div>
4949
);
50-
}
50+
},
5151
});

src/components/views/login/VectorLoginFooter.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
'use strict';
1818

19-
var React = require('react');
19+
const React = require('react');
2020
import { _t } from 'matrix-react-sdk/lib/languageHandler';
2121
import SettingsStore from 'matrix-react-sdk/lib/settings/SettingsStore';
2222

@@ -29,8 +29,8 @@ module.exports = React.createClass({
2929
render: function() {
3030
// FIXME: replace this with a proper Status skin
3131
// ...except then we wouldn't be able to switch to the Status theme at runtime.
32-
if (SettingsStore.getValue("theme") === 'status') return <div/>;
33-
32+
if (SettingsStore.getValue("theme") === 'status') return <div />;
33+
3434
return (
3535
<div className="mx_Login_links">
3636
<a href="https://medium.com/@RiotChat">blog</a>&nbsp;&nbsp;&middot;&nbsp;&nbsp;
@@ -39,5 +39,5 @@ module.exports = React.createClass({
3939
<a href="https://matrix.org">{ _t('powered by Matrix') }</a>
4040
</div>
4141
);
42-
}
42+
},
4343
});

src/components/views/login/VectorLoginHeader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ module.exports = React.createClass({
3535
return (
3636
<div className="mx_Login_header">
3737
<div className="mx_Login_logo">
38-
<img src={this.props.icon || DEFAULT_LOGO_URI} alt="Riot"/>
38+
<img src={this.props.icon || DEFAULT_LOGO_URI} alt="Riot" />
3939
</div>
4040
</div>
4141
);
42-
}
42+
},
4343
});

src/vector/index.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if (process.env.NODE_ENV !== 'production') {
3434
global.Perf = require('react-addons-perf');
3535
}
3636

37-
import RunModernizrTests from './modernizr'; // this side-effects a global
37+
import './modernizr';
3838
import ReactDOM from 'react-dom';
3939
import sdk from 'matrix-react-sdk';
4040
import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg';
@@ -43,16 +43,14 @@ import VectorConferenceHandler from 'matrix-react-sdk/lib/VectorConferenceHandle
4343
import Promise from 'bluebird';
4444
import request from 'browser-request';
4545
import * as languageHandler from 'matrix-react-sdk/lib/languageHandler';
46-
// Also import _t directly so we can call it just `_t` as this is what gen-i18n.js expects
47-
import { _t } from 'matrix-react-sdk/lib/languageHandler';
4846

4947
import url from 'url';
5048

5149
import {parseQs, parseQsFromFragment} from './url_utils';
5250
import Platform from './platform';
5351

5452
import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
55-
import SettingsStore, {SettingLevel} from "matrix-react-sdk/lib/settings/SettingsStore";
53+
import SettingsStore from "matrix-react-sdk/lib/settings/SettingsStore";
5654
import Tinter from 'matrix-react-sdk/lib/Tinter';
5755
import SdkConfig from "matrix-react-sdk/lib/SdkConfig";
5856

@@ -73,12 +71,12 @@ function checkBrowserFeatures(featureList) {
7371
console.error("Cannot check features - Modernizr global is missing.");
7472
return false;
7573
}
76-
var featureComplete = true;
77-
for (var i = 0; i < featureList.length; i++) {
74+
let featureComplete = true;
75+
for (let i = 0; i < featureList.length; i++) {
7876
if (window.Modernizr[featureList[i]] === undefined) {
7977
console.error(
8078
"Looked for feature '%s' but Modernizr has no results for this. " +
81-
"Has it been configured correctly?", featureList[i]
79+
"Has it been configured correctly?", featureList[i],
8280
);
8381
return false;
8482
}
@@ -99,7 +97,7 @@ function getScreenFromLocation(location) {
9997
return {
10098
screen: fragparts.location.substring(1),
10199
params: fragparts.params,
102-
}
100+
};
103101
}
104102

105103
// Here, we do some crude URL analysis to allow
@@ -124,10 +122,10 @@ function onHashChange(ev) {
124122
// so a web page can update the URL bar appropriately.
125123
function onNewScreen(screen) {
126124
console.log("newscreen "+screen);
127-
var hash = '#/' + screen;
125+
const hash = '#/' + screen;
128126
lastLocationHashSet = hash;
129127
window.location.hash = hash;
130-
};
128+
}
131129

132130
// We use this to work out what URL the SDK should
133131
// pass through when registering to allow the user to
@@ -164,7 +162,7 @@ function makeRegistrationUrl(params) {
164162
return url;
165163
}
166164

167-
function getConfig(configJsonFilename) {
165+
export function getConfig(configJsonFilename) {
168166
return new Promise(function(resolve, reject) {
169167
request(
170168
{ method: "GET", url: configJsonFilename },
@@ -200,9 +198,9 @@ function onTokenLoginCompleted() {
200198
// if we did a token login, we're now left with the token, hs and is
201199
// url as query params in the url; a little nasty but let's redirect to
202200
// clear them.
203-
var parsedUrl = url.parse(window.location.href);
201+
const parsedUrl = url.parse(window.location.href);
204202
parsedUrl.search = "";
205-
var formatted = url.format(parsedUrl);
203+
const formatted = url.format(parsedUrl);
206204
console.log("Redirecting to " + formatted + " to drop loginToken " +
207205
"from queryparams");
208206
window.location.href = formatted;
@@ -256,7 +254,6 @@ async function loadApp() {
256254
}
257255

258256
// as quickly as we possibly can, set a default theme...
259-
const styleElements = Object.create(null);
260257
let a;
261258
const theme = SettingsStore.getValue("theme");
262259
for (let i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
@@ -280,7 +277,7 @@ async function loadApp() {
280277
// in case it is the first time loading Riot.
281278
// `InstallTrigger` is a Object which only exists on Firefox
282279
// (it is used for their Plugins) and can be used as a
283-
// feature check.
280+
// feature check.
284281
// Firefox loads css always before js. This is why we dont use
285282
// onload or it's EventListener as thoose will never trigger.
286283
if (typeof InstallTrigger !== 'undefined') {
@@ -332,19 +329,19 @@ async function loadApp() {
332329
initialScreenAfterLogin={getScreenFromLocation(window.location)}
333330
defaultDeviceDisplayName={platform.getDefaultDeviceDisplayName()}
334331
/>,
335-
document.getElementById('matrixchat')
332+
document.getElementById('matrixchat'),
336333
);
337334
} else {
338335
console.error("Browser is missing required features.");
339336
// take to a different landing page to AWOOOOOGA at the user
340-
var CompatibilityPage = sdk.getComponent("structures.CompatibilityPage");
337+
const CompatibilityPage = sdk.getComponent("structures.CompatibilityPage");
341338
window.matrixChat = ReactDOM.render(
342339
<CompatibilityPage onAccept={function() {
343340
if (window.localStorage) window.localStorage.setItem('mx_accepts_unsupported_browser', true);
344341
console.log("User accepts the compatibility risks.");
345342
loadApp();
346343
}} />,
347-
document.getElementById('matrixchat')
344+
document.getElementById('matrixchat'),
348345
);
349346
}
350347
}

src/vector/indexeddb-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ import {IndexedDBStoreWorker} from 'matrix-js-sdk/lib/indexeddb-worker.js';
1818

1919
const remoteWorker = new IndexedDBStoreWorker(postMessage);
2020

21-
onmessage = remoteWorker.onMessage;
21+
export const onmessage = remoteWorker.onMessage;

src/vector/platform/ElectronPlatform.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import rageshake from 'matrix-react-sdk/lib/rageshake/rageshake';
2727
remote.autoUpdater.on('update-downloaded', onUpdateDownloaded);
2828

2929
// try to flush the rageshake logs to indexeddb before quit.
30-
ipcRenderer.on('before-quit', function () {
30+
ipcRenderer.on('before-quit', function() {
3131
console.log('riot-desktop closing');
3232
rageshake.flush();
3333
});

src/vector/platform/VectorBasePlatform.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export default class VectorBasePlatform extends BasePlatform {
6060
// This needs to be in in a try block as it will throw
6161
// if there are more than 100 badge count changes in
6262
// its internal queue
63-
let bgColor = "#d00",
64-
notif = this.notificationCount;
63+
let bgColor = "#d00";
64+
let notif = this.notificationCount;
6565

6666
if (this.errorDidOccur) {
6767
notif = notif || "×";
@@ -114,7 +114,7 @@ export default class VectorBasePlatform extends BasePlatform {
114114
dis.dispatch({
115115
action: 'check_updates',
116116
value: false,
117-
})
117+
});
118118
}
119119

120120
getUpdateCheckStatusEnum() {

src/vector/platform/WebPlatform.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Promise from 'bluebird';
2626
import url from 'url';
2727
import UAParser from 'ua-parser-js';
2828

29-
var POKE_RATE_MS = 10 * 60 * 1000; // 10 min
29+
const POKE_RATE_MS = 10 * 60 * 1000; // 10 min
3030

3131
export default class WebPlatform extends VectorBasePlatform {
3232
constructor() {

src/vector/url_utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ import qs from 'querystring';
2323
export function parseQsFromFragment(location) {
2424
// if we have a fragment, it will start with '#', which we need to drop.
2525
// (if we don't, this will return '').
26-
var fragment = location.hash.substring(1);
26+
const fragment = location.hash.substring(1);
2727

2828
// our fragment may contain a query-param-like section. we need to fish
2929
// this out *before* URI-decoding because the params may contain ? and &
3030
// characters which are only URI-encoded once.
31-
var hashparts = fragment.split('?');
31+
const hashparts = fragment.split('?');
3232

33-
var result = {
33+
const result = {
3434
location: decodeURIComponent(hashparts[0]),
35-
params: {}
35+
params: {},
3636
};
3737

3838
if (hashparts.length > 1) {

test/all-tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// ideally these unit tests could be run under nodejs rather than in a browser
77
// via karma, but having two separate test frameworks in the same project
88
// seems confusing
9-
var unit_tests = require.context('./unit-tests', true, /\.js$/);
9+
const unit_tests = require.context('./unit-tests', true, /\.js$/);
1010
unit_tests.keys().forEach(unit_tests);
1111

12-
var app_tests = require.context('./app-tests', true, /\.jsx?$/);
12+
const app_tests = require.context('./app-tests', true, /\.jsx?$/);
1313
app_tests.keys().forEach(app_tests);

0 commit comments

Comments
 (0)