Skip to content

Commit

Permalink
Merge pull request #7738 from vector-im/revert-7737-revert-7490-lint
Browse files Browse the repository at this point in the history
Re-apply "Run lint on travis builds and use modern node versions"
  • Loading branch information
dbkr authored Nov 23, 2018
2 parents c6f70cb + 704a599 commit b5c27ca
Show file tree
Hide file tree
Showing 18 changed files with 392 additions and 182 deletions.
25 changes: 9 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,18 @@ sudo: required
language: node_js
node_js:
# make sure we work with a range of node versions.
# As of the time of writing:
# - 4.x is still in LTS (until April 2018), but some of our deps (notably
# extract-zip) don't work with it
# - 5.x has been EOLed for nearly a year.
# - 6.x is the active 'LTS' version
# - 7.x is no longer supported
# - 8.x is the current 'current' version (until October 2017)
#
# see: https://github.com/nodejs/LTS/
#
# anything before 6.3 ships with npm 3.9 or earlier, which had problems
# with symlinks in node_modules (see
# https://github.com/npm/npm/releases/tag/v3.10.0 'FIXES AND REFACTORING').
- 6.3
- 6
- 7
# Current status of node versions: https://github.com/nodejs/LTS/
# We don't work with node 6 because it doesn't support package-lock
# files which we need to avoid the broken version of base-x
- 8
- 10
addons:
chrome: stable
install:
# clone the deps with depth 1: we know we will only ever need that one
# commit.
- scripts/fetch-develop.deps.sh --depth 1 && npm install
- npm install && scripts/fetch-develop.deps.sh --depth 1
script:
- npm run test
- npm run lint
360 changes: 291 additions & 69 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"autoprefixer": "^6.6.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-eslint": "^6.1.2",
"babel-eslint": "^8.1.1",
"babel-loader": "^7.1.5",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-async-to-bluebird": "^1.1.1",
Expand Down
1 change: 0 additions & 1 deletion src/components/structures/VectorHomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.

'use strict';

import React from 'react';
import HomePage from 'matrix-react-sdk/lib/components/structures/HomePage';
import sanitizeHtml from 'sanitize-html';
import { _t } from 'matrix-react-sdk/lib/languageHandler';
Expand Down
6 changes: 3 additions & 3 deletions src/components/views/login/VectorCustomServerDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

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

module.exports = React.createClass({
Expand Down Expand Up @@ -47,5 +47,5 @@ module.exports = React.createClass({
</div>
</div>
);
}
},
});
8 changes: 4 additions & 4 deletions src/components/views/login/VectorLoginFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

'use strict';

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

Expand All @@ -29,8 +29,8 @@ module.exports = React.createClass({
render: function() {
// FIXME: replace this with a proper Status skin
// ...except then we wouldn't be able to switch to the Status theme at runtime.
if (SettingsStore.getValue("theme") === 'status') return <div/>;
if (SettingsStore.getValue("theme") === 'status') return <div />;

return (
<div className="mx_Login_links">
<a href="https://medium.com/@RiotChat">blog</a>&nbsp;&nbsp;&middot;&nbsp;&nbsp;
Expand All @@ -39,5 +39,5 @@ module.exports = React.createClass({
<a href="https://matrix.org">{ _t('powered by Matrix') }</a>
</div>
);
}
},
});
4 changes: 2 additions & 2 deletions src/components/views/login/VectorLoginHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ module.exports = React.createClass({
return (
<div className="mx_Login_header">
<div className="mx_Login_logo">
<img src={this.props.icon || DEFAULT_LOGO_URI} alt="Riot"/>
<img src={this.props.icon || DEFAULT_LOGO_URI} alt="Riot" />
</div>
</div>
);
}
},
});
33 changes: 15 additions & 18 deletions src/vector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (process.env.NODE_ENV !== 'production') {
global.Perf = require('react-addons-perf');
}

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

import url from 'url';

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

import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
import SettingsStore, {SettingLevel} from "matrix-react-sdk/lib/settings/SettingsStore";
import SettingsStore from "matrix-react-sdk/lib/settings/SettingsStore";
import Tinter from 'matrix-react-sdk/lib/Tinter';
import SdkConfig from "matrix-react-sdk/lib/SdkConfig";

Expand All @@ -73,12 +71,12 @@ function checkBrowserFeatures(featureList) {
console.error("Cannot check features - Modernizr global is missing.");
return false;
}
var featureComplete = true;
for (var i = 0; i < featureList.length; i++) {
let featureComplete = true;
for (let i = 0; i < featureList.length; i++) {
if (window.Modernizr[featureList[i]] === undefined) {
console.error(
"Looked for feature '%s' but Modernizr has no results for this. " +
"Has it been configured correctly?", featureList[i]
"Has it been configured correctly?", featureList[i],
);
return false;
}
Expand All @@ -99,7 +97,7 @@ function getScreenFromLocation(location) {
return {
screen: fragparts.location.substring(1),
params: fragparts.params,
}
};
}

// Here, we do some crude URL analysis to allow
Expand All @@ -124,10 +122,10 @@ function onHashChange(ev) {
// so a web page can update the URL bar appropriately.
function onNewScreen(screen) {
console.log("newscreen "+screen);
var hash = '#/' + screen;
const hash = '#/' + screen;
lastLocationHashSet = hash;
window.location.hash = hash;
};
}

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

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

// as quickly as we possibly can, set a default theme...
const styleElements = Object.create(null);
let a;
const theme = SettingsStore.getValue("theme");
for (let i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
Expand All @@ -280,7 +277,7 @@ async function loadApp() {
// in case it is the first time loading Riot.
// `InstallTrigger` is a Object which only exists on Firefox
// (it is used for their Plugins) and can be used as a
// feature check.
// feature check.
// Firefox loads css always before js. This is why we dont use
// onload or it's EventListener as thoose will never trigger.
if (typeof InstallTrigger !== 'undefined') {
Expand Down Expand Up @@ -332,19 +329,19 @@ async function loadApp() {
initialScreenAfterLogin={getScreenFromLocation(window.location)}
defaultDeviceDisplayName={platform.getDefaultDeviceDisplayName()}
/>,
document.getElementById('matrixchat')
document.getElementById('matrixchat'),
);
} else {
console.error("Browser is missing required features.");
// take to a different landing page to AWOOOOOGA at the user
var CompatibilityPage = sdk.getComponent("structures.CompatibilityPage");
const CompatibilityPage = sdk.getComponent("structures.CompatibilityPage");
window.matrixChat = ReactDOM.render(
<CompatibilityPage onAccept={function() {
if (window.localStorage) window.localStorage.setItem('mx_accepts_unsupported_browser', true);
console.log("User accepts the compatibility risks.");
loadApp();
}} />,
document.getElementById('matrixchat')
document.getElementById('matrixchat'),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/vector/indexeddb-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ import {IndexedDBStoreWorker} from 'matrix-js-sdk/lib/indexeddb-worker.js';

const remoteWorker = new IndexedDBStoreWorker(postMessage);

onmessage = remoteWorker.onMessage;
export const onmessage = remoteWorker.onMessage;
2 changes: 1 addition & 1 deletion src/vector/platform/ElectronPlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import rageshake from 'matrix-react-sdk/lib/rageshake/rageshake';
remote.autoUpdater.on('update-downloaded', onUpdateDownloaded);

// try to flush the rageshake logs to indexeddb before quit.
ipcRenderer.on('before-quit', function () {
ipcRenderer.on('before-quit', function() {
console.log('riot-desktop closing');
rageshake.flush();
});
Expand Down
6 changes: 3 additions & 3 deletions src/vector/platform/VectorBasePlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export default class VectorBasePlatform extends BasePlatform {
// This needs to be in in a try block as it will throw
// if there are more than 100 badge count changes in
// its internal queue
let bgColor = "#d00",
notif = this.notificationCount;
let bgColor = "#d00";
let notif = this.notificationCount;

if (this.errorDidOccur) {
notif = notif || "×";
Expand Down Expand Up @@ -114,7 +114,7 @@ export default class VectorBasePlatform extends BasePlatform {
dis.dispatch({
action: 'check_updates',
value: false,
})
});
}

getUpdateCheckStatusEnum() {
Expand Down
2 changes: 1 addition & 1 deletion src/vector/platform/WebPlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Promise from 'bluebird';
import url from 'url';
import UAParser from 'ua-parser-js';

var POKE_RATE_MS = 10 * 60 * 1000; // 10 min
const POKE_RATE_MS = 10 * 60 * 1000; // 10 min

export default class WebPlatform extends VectorBasePlatform {
constructor() {
Expand Down
8 changes: 4 additions & 4 deletions src/vector/url_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ import qs from 'querystring';
export function parseQsFromFragment(location) {
// if we have a fragment, it will start with '#', which we need to drop.
// (if we don't, this will return '').
var fragment = location.hash.substring(1);
const fragment = location.hash.substring(1);

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

var result = {
const result = {
location: decodeURIComponent(hashparts[0]),
params: {}
params: {},
};

if (hashparts.length > 1) {
Expand Down
4 changes: 2 additions & 2 deletions test/all-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// ideally these unit tests could be run under nodejs rather than in a browser
// via karma, but having two separate test frameworks in the same project
// seems confusing
var unit_tests = require.context('./unit-tests', true, /\.js$/);
const unit_tests = require.context('./unit-tests', true, /\.js$/);
unit_tests.keys().forEach(unit_tests);

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

0 comments on commit b5c27ca

Please sign in to comment.