eslint --fix

This commit is contained in:
David Baker 2021-07-01 20:43:05 +01:00
parent e3201eb20f
commit ee9be5438e
6 changed files with 301 additions and 344 deletions

View file

@ -1,15 +0,0 @@
# autogenerated file: run scripts/generate-eslint-error-ignore-file to update.
src/Markdown.js
src/NodeAnimator.js
src/components/structures/RoomDirectory.js
src/components/views/rooms/MemberList.js
src/utils/DMRoomMap.js
src/utils/MultiInviter.js
test/components/structures/MessagePanel-test.js
test/components/views/dialogs/InteractiveAuthDialog-test.js
test/mock-clock.js
src/component-index.js
test/end-to-end-tests/node_modules/
test/end-to-end-tests/element/
test/end-to-end-tests/synapse/

View file

@ -45,7 +45,7 @@
"start:all": "concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n build,reskindex \"yarn start:build\" \"yarn reskindex:watch\"", "start:all": "concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n build,reskindex \"yarn start:build\" \"yarn reskindex:watch\"",
"start:build": "babel src -w -s -d lib --verbose --extensions \".ts,.js\"", "start:build": "babel src -w -s -d lib --verbose --extensions \".ts,.js\"",
"lint": "yarn lint:types && yarn lint:js && yarn lint:style", "lint": "yarn lint:types && yarn lint:js && yarn lint:style",
"lint:js": "eslint --max-warnings 0 --ignore-path .eslintignore.errorfiles src test", "lint:js": "eslint --max-warnings 0 src test",
"lint:types": "tsc --noEmit --jsx react", "lint:types": "tsc --noEmit --jsx react",
"lint:style": "stylelint 'res/css/**/*.scss'", "lint:style": "stylelint 'res/css/**/*.scss'",
"test": "jest", "test": "jest",

View file

@ -1,23 +0,0 @@
#!/bin/sh
#
# generates .eslintignore.errorfiles to list the files which have errors in,
# so that they can be ignored in future automated linting.
out=.eslintignore.errorfiles
cd `dirname $0`/..
echo "generating $out"
{
cat <<EOF
# autogenerated file: run scripts/generate-eslint-error-ignore-file to update.
EOF
./node_modules/.bin/eslint -f json src test |
jq -r '.[] | select((.errorCount + .warningCount) > 0) | .filePath' |
sed -e 's/.*matrix-react-sdk\///';
} > "$out"
# also append rules from eslintignore file
cat .eslintignore >> $out

View file

@ -26,7 +26,7 @@ import { EventEmitter } from "events";
import sdk from '../../skinned-sdk'; import sdk from '../../skinned-sdk';
const MessagePanel = sdk.getComponent('structures.MessagePanel'); const MessagePanel = sdk.getComponent('structures.MessagePanel');
import {MatrixClientPeg} from '../../../src/MatrixClientPeg'; import { MatrixClientPeg } from '../../../src/MatrixClientPeg';
import Matrix from 'matrix-js-sdk'; import Matrix from 'matrix-js-sdk';
const test_utils = require('../../test-utils'); const test_utils = require('../../test-utils');
@ -79,7 +79,7 @@ describe('MessagePanel', function() {
beforeEach(function() { beforeEach(function() {
test_utils.stubClient(); test_utils.stubClient();
client = MatrixClientPeg.get(); client = MatrixClientPeg.get();
client.credentials = {userId: '@me:here'}; client.credentials = { userId: '@me:here' };
// HACK: We assume all settings want to be disabled // HACK: We assume all settings want to be disabled
SettingsStore.getValue = jest.fn((arg) => { SettingsStore.getValue = jest.fn((arg) => {
@ -120,7 +120,6 @@ describe('MessagePanel', function() {
return events; return events;
} }
// make a collection of events with some member events that should be collapsed // make a collection of events with some member events that should be collapsed
// with a MemberEventListSummary // with a MemberEventListSummary
function mkMelsEvents() { function mkMelsEvents() {

View file

@ -20,10 +20,10 @@ import ReactTestUtils from 'react-dom/test-utils';
import MatrixReactTestUtils from 'matrix-react-test-utils'; import MatrixReactTestUtils from 'matrix-react-test-utils';
import sdk from '../../../skinned-sdk'; import sdk from '../../../skinned-sdk';
import {MatrixClientPeg} from '../../../../src/MatrixClientPeg'; import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';
import * as test_utils from '../../../test-utils'; import * as test_utils from '../../../test-utils';
import {sleep} from "../../../../src/utils/promise"; import { sleep } from "../../../../src/utils/promise";
const InteractiveAuthDialog = sdk.getComponent( const InteractiveAuthDialog = sdk.getComponent(
'views.dialogs.InteractiveAuthDialog', 'views.dialogs.InteractiveAuthDialog',
@ -45,11 +45,11 @@ describe('InteractiveAuthDialog', function() {
it('Should successfully complete a password flow', function() { it('Should successfully complete a password flow', function() {
const onFinished = jest.fn(); const onFinished = jest.fn();
const doRequest = jest.fn().mockResolvedValue({a: 1}); const doRequest = jest.fn().mockResolvedValue({ a: 1 });
// tell the stub matrixclient to return a real userid // tell the stub matrixclient to return a real userid
const client = MatrixClientPeg.get(); const client = MatrixClientPeg.get();
client.credentials = {userId: "@user:id"}; client.credentials = { userId: "@user:id" };
const dlg = ReactDOM.render( const dlg = ReactDOM.render(
<InteractiveAuthDialog <InteractiveAuthDialog
@ -57,7 +57,7 @@ describe('InteractiveAuthDialog', function() {
authData={{ authData={{
session: "sess", session: "sess",
flows: [ flows: [
{"stages": ["m.login.password"]}, { "stages": ["m.login.password"] },
], ],
}} }}
makeRequest={doRequest} makeRequest={doRequest}
@ -105,7 +105,7 @@ describe('InteractiveAuthDialog', function() {
return sleep(1); return sleep(1);
}).then(sleep(1)).then(() => { }).then(sleep(1)).then(() => {
expect(onFinished).toBeCalledTimes(1); expect(onFinished).toBeCalledTimes(1);
expect(onFinished).toBeCalledWith(true, {a: 1}); expect(onFinished).toBeCalledWith(true, { a: 1 });
}); });
}); });
}); });

View file

@ -48,26 +48,25 @@ const j$ = {};
j$.Clock = function() { j$.Clock = function() {
function Clock(global, delayedFunctionSchedulerFactory, mockDate) { function Clock(global, delayedFunctionSchedulerFactory, mockDate) {
let self = this, const self = this;
realTimingFunctions = { const realTimingFunctions = {
setTimeout: global.setTimeout, setTimeout: global.setTimeout,
clearTimeout: global.clearTimeout, clearTimeout: global.clearTimeout,
setInterval: global.setInterval, setInterval: global.setInterval,
clearInterval: global.clearInterval, clearInterval: global.clearInterval,
}, };
fakeTimingFunctions = { const fakeTimingFunctions = {
setTimeout: setTimeout, setTimeout: setTimeout,
clearTimeout: clearTimeout, clearTimeout: clearTimeout,
setInterval: setInterval, setInterval: setInterval,
clearInterval: clearInterval, clearInterval: clearInterval,
}, };
installed = false, let installed = false;
delayedFunctionScheduler, let delayedFunctionScheduler;
timer; let timer;
self.install = function() { self.install = function() {
if(!originalTimingFunctionsIntact()) { if (!originalTimingFunctionsIntact()) {
throw new Error('Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?'); throw new Error('Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?');
} }
replace(global, fakeTimingFunctions); replace(global, fakeTimingFunctions);
@ -181,7 +180,6 @@ j$.Clock = function() {
return Clock; return Clock;
}(); }();
j$.DelayedFunctionScheduler = function() { j$.DelayedFunctionScheduler = function() {
function DelayedFunctionScheduler() { function DelayedFunctionScheduler() {
const self = this; const self = this;
@ -328,7 +326,6 @@ j$.DelayedFunctionScheduler = function() {
return DelayedFunctionScheduler; return DelayedFunctionScheduler;
}(); }();
j$.MockDate = function() { j$.MockDate = function() {
function MockDate(global) { function MockDate(global) {
const self = this; const self = this;
@ -368,7 +365,7 @@ j$.MockDate = function() {
return self; return self;
function FakeDate() { function FakeDate() {
switch(arguments.length) { switch (arguments.length) {
case 0: case 0:
return new GlobalDate(currentTime); return new GlobalDate(currentTime);
case 1: case 1:
@ -418,4 +415,3 @@ export function clock() {
return _clock; return _clock;
} }