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:build": "babel src -w -s -d lib --verbose --extensions \".ts,.js\"",
"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:style": "stylelint 'res/css/**/*.scss'",
"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';
const MessagePanel = sdk.getComponent('structures.MessagePanel');
import {MatrixClientPeg} from '../../../src/MatrixClientPeg';
import { MatrixClientPeg } from '../../../src/MatrixClientPeg';
import Matrix from 'matrix-js-sdk';
const test_utils = require('../../test-utils');
@ -79,7 +79,7 @@ describe('MessagePanel', function() {
beforeEach(function() {
test_utils.stubClient();
client = MatrixClientPeg.get();
client.credentials = {userId: '@me:here'};
client.credentials = { userId: '@me:here' };
// HACK: We assume all settings want to be disabled
SettingsStore.getValue = jest.fn((arg) => {
@ -120,7 +120,6 @@ describe('MessagePanel', function() {
return events;
}
// make a collection of events with some member events that should be collapsed
// with a MemberEventListSummary
function mkMelsEvents() {

View file

@ -20,10 +20,10 @@ import ReactTestUtils from 'react-dom/test-utils';
import MatrixReactTestUtils from 'matrix-react-test-utils';
import sdk from '../../../skinned-sdk';
import {MatrixClientPeg} from '../../../../src/MatrixClientPeg';
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';
import * as test_utils from '../../../test-utils';
import {sleep} from "../../../../src/utils/promise";
import { sleep } from "../../../../src/utils/promise";
const InteractiveAuthDialog = sdk.getComponent(
'views.dialogs.InteractiveAuthDialog',
@ -45,11 +45,11 @@ describe('InteractiveAuthDialog', function() {
it('Should successfully complete a password flow', function() {
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
const client = MatrixClientPeg.get();
client.credentials = {userId: "@user:id"};
client.credentials = { userId: "@user:id" };
const dlg = ReactDOM.render(
<InteractiveAuthDialog
@ -57,7 +57,7 @@ describe('InteractiveAuthDialog', function() {
authData={{
session: "sess",
flows: [
{"stages": ["m.login.password"]},
{ "stages": ["m.login.password"] },
],
}}
makeRequest={doRequest}
@ -105,7 +105,7 @@ describe('InteractiveAuthDialog', function() {
return sleep(1);
}).then(sleep(1)).then(() => {
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() {
function Clock(global, delayedFunctionSchedulerFactory, mockDate) {
let self = this,
realTimingFunctions = {
const self = this;
const realTimingFunctions = {
setTimeout: global.setTimeout,
clearTimeout: global.clearTimeout,
setInterval: global.setInterval,
clearInterval: global.clearInterval,
},
fakeTimingFunctions = {
};
const fakeTimingFunctions = {
setTimeout: setTimeout,
clearTimeout: clearTimeout,
setInterval: setInterval,
clearInterval: clearInterval,
},
installed = false,
delayedFunctionScheduler,
timer;
};
let installed = false;
let delayedFunctionScheduler;
let timer;
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?');
}
replace(global, fakeTimingFunctions);
@ -181,7 +180,6 @@ j$.Clock = function() {
return Clock;
}();
j$.DelayedFunctionScheduler = function() {
function DelayedFunctionScheduler() {
const self = this;
@ -328,7 +326,6 @@ j$.DelayedFunctionScheduler = function() {
return DelayedFunctionScheduler;
}();
j$.MockDate = function() {
function MockDate(global) {
const self = this;
@ -368,7 +365,7 @@ j$.MockDate = function() {
return self;
function FakeDate() {
switch(arguments.length) {
switch (arguments.length) {
case 0:
return new GlobalDate(currentTime);
case 1:
@ -418,4 +415,3 @@ export function clock() {
return _clock;
}