lint files

pull/2242/head
Audric Ackermann 4 years ago
parent add267ae69
commit 5c9b34fb86
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -14,26 +14,13 @@ module.exports = grunt => {
sourceMap: true, sourceMap: true,
importer: importOnce, importer: importOnce,
}, },
dev: {
dist: {
files: { files: {
'stylesheets/manifest.css': 'stylesheets/manifest.scss', 'stylesheets/manifest.css': 'stylesheets/manifest.scss',
}, },
}, },
}, },
watch: {
protobuf: {
files: ['./protos/SignalService.proto'],
tasks: ['exec:build-protobuf'],
},
sass: {
files: ['./stylesheets/*.scss'],
tasks: ['sass'],
},
transpile: {
files: ['./ts/**/*.ts', './ts/**/*.tsx', './ts/**/**/*.tsx', './test/ts/**.ts'],
tasks: ['exec:transpile'],
},
},
exec: { exec: {
transpile: { transpile: {
cmd: 'yarn transpile', cmd: 'yarn transpile',
@ -75,12 +62,11 @@ module.exports = grunt => {
updateLocalConfig({ commitHash: hash }); updateLocalConfig({ commitHash: hash });
}); });
grunt.registerTask('dev', ['default', 'watch']);
grunt.registerTask('date', ['gitinfo']); grunt.registerTask('date', ['gitinfo']);
grunt.registerTask('default', [ grunt.registerTask('default', [
'exec:build-protobuf', 'exec:build-protobuf',
'exec:transpile',
'sass', 'sass',
'exec:transpile',
'date', 'date',
'getCommitHash', 'getCommitHash',
]); ]);

@ -26,9 +26,6 @@
<title>Session</title> <title>Session</title>
<link href="images/sesion/session_icon_128.png" rel="shortcut icon" /> <link href="images/sesion/session_icon_128.png" rel="shortcut icon" />
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" /> <link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
<script>
var exports = {};
</script>
</head> </head>
<body id="body"> <body id="body">
@ -40,9 +37,6 @@
</div> </div>
</div> </div>
</div> </div>
<script>
var exports = {};
</script>
<script type="text/javascript"> <script type="text/javascript">
require('./ts/mains/main_renderer.js'); require('./ts/mains/main_renderer.js');
</script> </script>

@ -15,17 +15,10 @@
style-src 'self' 'unsafe-inline';" style-src 'self' 'unsafe-inline';"
/> />
<link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" /> <link href="stylesheets/manifest.css" rel="stylesheet" type="text/css" />
<script>
var exports = {};
</script>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
</body> </body>
<script>
var exports = {};
</script>
<script type="text/javascript"> <script type="text/javascript">
require('./ts/mains/debug_log_start.js'); require('./ts/mains/debug_log_start.js');
</script> </script>

@ -2,7 +2,9 @@
const { ipcRenderer } = require('electron'); const { ipcRenderer } = require('electron');
const url = require('url'); const url = require('url');
const i18n = require('./ts/util/i18n'); const i18n = require('./ts/util/i18n');
const config = url.parse(window.location.toString(), true).query; const config = url.parse(window.location.toString(), true).query;
const { locale } = config; const { locale } = config;
const localeMessages = ipcRenderer.sendSync('locale-data'); const localeMessages = ipcRenderer.sendSync('locale-data');

@ -40,7 +40,6 @@
background-color: rgba($session-color-primary, 0.3); background-color: rgba($session-color-primary, 0.3);
} }
padding: $session-margin-xs $session-margin-sm; padding: $session-margin-xs $session-margin-sm;
font-size: $session-font-xs;
text-align: center; text-align: center;
} }
} }

@ -47,3 +47,5 @@
@import 'session_slider'; @import 'session_slider';
@import 'session_conversation'; @import 'session_conversation';
@import '_session_password';

@ -86,6 +86,7 @@ class SessionPasswordPromptInner extends React.PureComponent<{}, State> {
); );
return ( return (
<div className="password">
<div className={wrapperClass}> <div className={wrapperClass}>
<div className={containerClass}> <div className={containerClass}>
<div className={infoAreaClass}> <div className={infoAreaClass}>
@ -99,6 +100,7 @@ class SessionPasswordPromptInner extends React.PureComponent<{}, State> {
{buttonGroup} {buttonGroup}
</div> </div>
</div> </div>
</div>
); );
} }

@ -16,6 +16,7 @@ global.setTimeout(() => {
states.push(window.getAppInstance()); states.push(window.getAppInstance());
} }
if (version) { if (version) {
// tslint:disable: no-inner-html
version.innerHTML = `v${window.getVersion()}`; version.innerHTML = `v${window.getVersion()}`;
} }

@ -32,8 +32,9 @@ if (environment === 'production') {
// We load config after we've made our modifications to NODE_ENV // We load config after we've made our modifications to NODE_ENV
//tslint-disable no-require-imports no-var-requires //tslint-disable no-require-imports no-var-requires
// tslint:disable-next-line: no-require-imports no-var-requires
const c = require('config'); const c = require('config');
(c as any).environment = environment; c.environment = environment;
// Log resulting env vars in use by config // Log resulting env vars in use by config
['NODE_ENV', 'NODE_APP_INSTANCE', 'NODE_CONFIG_DIR', 'NODE_CONFIG'].forEach(s => { ['NODE_ENV', 'NODE_APP_INSTANCE', 'NODE_CONFIG_DIR', 'NODE_CONFIG'].forEach(s => {

@ -53,6 +53,7 @@ export async function encryptAttachmentBufferNode(
); );
//tslint-disable restrict-plus-operands //tslint-disable restrict-plus-operands
// tslint:disable-next-line: restrict-plus-operands
const encryptedBufferWithHeader = new Uint8Array(bufferOut.length + header.length); const encryptedBufferWithHeader = new Uint8Array(bufferOut.length + header.length);
encryptedBufferWithHeader.set(header); encryptedBufferWithHeader.set(header);
encryptedBufferWithHeader.set(bufferOut, header.length); encryptedBufferWithHeader.set(bufferOut, header.length);

@ -3,6 +3,7 @@ import { beforeEach } from 'mocha';
import Sinon from 'sinon'; import Sinon from 'sinon';
import * as DecryptedAttachmentsManager from '../../../../session/crypto/DecryptedAttachmentsManager'; import * as DecryptedAttachmentsManager from '../../../../session/crypto/DecryptedAttachmentsManager';
import { TestUtils } from '../../../test-utils'; import { TestUtils } from '../../../test-utils';
// tslint:disable: chai-vague-errors no-unused-expression
describe('DecryptedAttachmentsManager', () => { describe('DecryptedAttachmentsManager', () => {
// tslint:disable-next-line: no-empty // tslint:disable-next-line: no-empty
@ -49,7 +50,7 @@ describe('DecryptedAttachmentsManager', () => {
beforeEach(() => { beforeEach(() => {
readFileContent = Sinon.stub(DecryptedAttachmentsManager, 'readFileContent').resolves( readFileContent = Sinon.stub(DecryptedAttachmentsManager, 'readFileContent').resolves(
Buffer.from(new String('this is a test')) Buffer.from('this is a test')
); );
getItemById = TestUtils.stubDataItem('getItemById') getItemById = TestUtils.stubDataItem('getItemById')
.withArgs('local_attachment_encrypted_key') .withArgs('local_attachment_encrypted_key')
@ -133,7 +134,7 @@ describe('DecryptedAttachmentsManager', () => {
expect(resolved2.startsWith(now2.slice(0, 9))).to.be.true; expect(resolved2.startsWith(now2.slice(0, 9))).to.be.true;
}); });
}); });
}); }); // tslint:disable: no-empty
it.skip('cleanUpOldDecryptedMedias', () => {}); it.skip('cleanUpOldDecryptedMedias', () => {});
it.skip('getDecryptedBlob', () => {}); it.skip('getDecryptedBlob', () => {});

@ -33,7 +33,8 @@ export function stubUtilWorker(fnName: string, returnedValue: any): sinon.SinonS
} }
export function stubCreateObjectUrl() { export function stubCreateObjectUrl() {
(global as any).URL = {}; (global as any).URL = {};
(global as any).URL.createObjectURL = function() { (global as any).URL.createObjectURL = () => {
// tslint:disable-next-line: insecure-random
return `${Date.now()}:${Math.floor(Math.random() * 1000)}`; return `${Date.now()}:${Math.floor(Math.random() * 1000)}`;
}; };
} }

@ -6,6 +6,7 @@ import {
hasVisualMediaAttachmentInMessage, hasVisualMediaAttachmentInMessage,
} from '../../types/message/initializeAttachmentMetadata'; } from '../../types/message/initializeAttachmentMetadata';
import { generateFakeIncomingPrivateMessage, stubWindowLog } from '../test-utils/utils'; import { generateFakeIncomingPrivateMessage, stubWindowLog } from '../test-utils/utils';
// tslint:disable: chai-vague-errors no-unused-expression
// tslint:disable-next-line: max-func-body-length // tslint:disable-next-line: max-func-body-length
describe('initializeAttachmentMetadata', () => { describe('initializeAttachmentMetadata', () => {
@ -16,7 +17,7 @@ describe('initializeAttachmentMetadata', () => {
it('no attachments should return false', () => { it('no attachments should return false', () => {
const msgModel = generateFakeIncomingPrivateMessage(); const msgModel = generateFakeIncomingPrivateMessage();
expect(hasFileAttachmentInMessage(msgModel)).to.be.false; expect(hasFileAttachmentInMessage(msgModel)).to.be.eq(false);
}); });
it('empty list attachments should return false', () => { it('empty list attachments should return false', () => {
@ -203,81 +204,81 @@ describe('initializeAttachmentMetadata', () => {
}); });
describe('getAttachmentMetadata', () => { describe('getAttachmentMetadata', () => {
it('no attachments should return false x3', async () => { it('no attachments should return false x3', () => {
const msgModel = generateFakeIncomingPrivateMessage(); const msgModel = generateFakeIncomingPrivateMessage();
const mt = await getAttachmentMetadata(msgModel); const mt = getAttachmentMetadata(msgModel);
expect(mt.hasAttachments).to.be.eq(0); expect(mt.hasAttachments).to.be.eq(0);
expect(mt.hasFileAttachments).to.be.eq(0); expect(mt.hasFileAttachments).to.be.eq(0);
expect(mt.hasVisualMediaAttachments).to.be.eq(0); expect(mt.hasVisualMediaAttachments).to.be.eq(0);
}); });
it('empty attachments [] should return false x3', async () => { it('empty attachments [] should return false x3', () => {
const msgModel = generateFakeIncomingPrivateMessage(); const msgModel = generateFakeIncomingPrivateMessage();
msgModel.set('attachments', []); msgModel.set('attachments', []);
const mt = await getAttachmentMetadata(msgModel); const mt = getAttachmentMetadata(msgModel);
expect(mt.hasAttachments).to.be.eq(0); expect(mt.hasAttachments).to.be.eq(0);
expect(mt.hasFileAttachments).to.be.eq(0); expect(mt.hasFileAttachments).to.be.eq(0);
expect(mt.hasVisualMediaAttachments).to.be.eq(0); expect(mt.hasVisualMediaAttachments).to.be.eq(0);
}); });
it('has one image attachment only', async () => { it('has one image attachment only', () => {
const msgModel = generateFakeIncomingPrivateMessage(); const msgModel = generateFakeIncomingPrivateMessage();
msgModel.set('attachments', [{ contentType: 'image/jpeg' }]); msgModel.set('attachments', [{ contentType: 'image/jpeg' }]);
const mt = await getAttachmentMetadata(msgModel); const mt = getAttachmentMetadata(msgModel);
expect(mt.hasAttachments).to.be.eq(1); expect(mt.hasAttachments).to.be.eq(1);
expect(mt.hasFileAttachments).to.be.eq(0); expect(mt.hasFileAttachments).to.be.eq(0);
expect(mt.hasVisualMediaAttachments).to.be.eq(1); expect(mt.hasVisualMediaAttachments).to.be.eq(1);
}); });
it('has two image attachment only', async () => { it('has two image attachment only', () => {
const msgModel = generateFakeIncomingPrivateMessage(); const msgModel = generateFakeIncomingPrivateMessage();
msgModel.set('attachments', [{ contentType: 'image/jpeg' }, { contentType: 'image/jpeg' }]); msgModel.set('attachments', [{ contentType: 'image/jpeg' }, { contentType: 'image/jpeg' }]);
const mt = await getAttachmentMetadata(msgModel); const mt = getAttachmentMetadata(msgModel);
expect(mt.hasAttachments).to.be.eq(1); expect(mt.hasAttachments).to.be.eq(1);
expect(mt.hasFileAttachments).to.be.eq(0); expect(mt.hasFileAttachments).to.be.eq(0);
expect(mt.hasVisualMediaAttachments).to.be.eq(1); expect(mt.hasVisualMediaAttachments).to.be.eq(1);
}); });
it('has one audio attachment only', async () => { it('has one audio attachment only', () => {
const msgModel = generateFakeIncomingPrivateMessage(); const msgModel = generateFakeIncomingPrivateMessage();
msgModel.set('attachments', [{ contentType: 'audio/mp3' }]); msgModel.set('attachments', [{ contentType: 'audio/mp3' }]);
const mt = await getAttachmentMetadata(msgModel); const mt = getAttachmentMetadata(msgModel);
expect(mt.hasAttachments).to.be.eq(1); expect(mt.hasAttachments).to.be.eq(1);
expect(mt.hasFileAttachments).to.be.eq(0); expect(mt.hasFileAttachments).to.be.eq(0);
expect(mt.hasVisualMediaAttachments).to.be.eq(0); expect(mt.hasVisualMediaAttachments).to.be.eq(0);
}); });
it('has one file attachment only', async () => { it('has one file attachment only', () => {
const msgModel = generateFakeIncomingPrivateMessage(); const msgModel = generateFakeIncomingPrivateMessage();
msgModel.set('attachments', [{ contentType: 'whatever' }]); msgModel.set('attachments', [{ contentType: 'whatever' }]);
const mt = await getAttachmentMetadata(msgModel); const mt = getAttachmentMetadata(msgModel);
expect(mt.hasAttachments).to.be.eq(1); expect(mt.hasAttachments).to.be.eq(1);
expect(mt.hasFileAttachments).to.be.eq(1); expect(mt.hasFileAttachments).to.be.eq(1);
expect(mt.hasVisualMediaAttachments).to.be.eq(0); expect(mt.hasVisualMediaAttachments).to.be.eq(0);
}); });
it('has two file attachment only', async () => { it('has two file attachment only', () => {
const msgModel = generateFakeIncomingPrivateMessage(); const msgModel = generateFakeIncomingPrivateMessage();
msgModel.set('attachments', [{ contentType: 'whatever' }, { contentType: 'whatever' }]); msgModel.set('attachments', [{ contentType: 'whatever' }, { contentType: 'whatever' }]);
const mt = await getAttachmentMetadata(msgModel); const mt = getAttachmentMetadata(msgModel);
expect(mt.hasAttachments).to.be.eq(1); expect(mt.hasAttachments).to.be.eq(1);
expect(mt.hasFileAttachments).to.be.eq(1); expect(mt.hasFileAttachments).to.be.eq(1);
expect(mt.hasVisualMediaAttachments).to.be.eq(0); expect(mt.hasVisualMediaAttachments).to.be.eq(0);
}); });
it('has two attachments with undefined contenttype', async () => { it('has two attachments with undefined contenttype', () => {
const msgModel = generateFakeIncomingPrivateMessage(); const msgModel = generateFakeIncomingPrivateMessage();
msgModel.set('attachments', [{ contentType: undefined }, { contentType: undefined }]); msgModel.set('attachments', [{ contentType: undefined }, { contentType: undefined }]);
const mt = await getAttachmentMetadata(msgModel); const mt = getAttachmentMetadata(msgModel);
expect(mt.hasAttachments).to.be.eq(1); expect(mt.hasAttachments).to.be.eq(1);
expect(mt.hasFileAttachments).to.be.eq(0); expect(mt.hasFileAttachments).to.be.eq(0);
expect(mt.hasVisualMediaAttachments).to.be.eq(0); expect(mt.hasVisualMediaAttachments).to.be.eq(0);
}); });
it('has two attachments with null contenttype', async () => { it('has two attachments with null contenttype', () => {
const msgModel = generateFakeIncomingPrivateMessage(); const msgModel = generateFakeIncomingPrivateMessage();
msgModel.set('attachments', [{ contentType: null }, { contentType: null }]); msgModel.set('attachments', [{ contentType: null }, { contentType: null }]);
const mt = await getAttachmentMetadata(msgModel); const mt = getAttachmentMetadata(msgModel);
expect(mt.hasAttachments).to.be.eq(1); expect(mt.hasAttachments).to.be.eq(1);
expect(mt.hasFileAttachments).to.be.eq(1); expect(mt.hasFileAttachments).to.be.eq(1);
expect(mt.hasVisualMediaAttachments).to.be.eq(0); expect(mt.hasVisualMediaAttachments).to.be.eq(0);

@ -11,6 +11,7 @@ const StyledContent = styled.div`
const DebugLogTextArea = (props: { content: string }) => { const DebugLogTextArea = (props: { content: string }) => {
console.warn('DebugLogTextArea ', props.content); console.warn('DebugLogTextArea ', props.content);
// tslint:disable-next-line: react-a11y-input-elements
return <textarea spellCheck="false" rows={10} value={props.content} style={{ height: '100%' }} />; return <textarea spellCheck="false" rows={10} value={props.content} style={{ height: '100%' }} />;
}; };
@ -49,7 +50,7 @@ const DebugLogViewAndSave = () => {
// eslint-disable-next-line more/no-then // eslint-disable-next-line more/no-then
fetch() fetch()
.then((text: any) => { .then((text: any) => {
const debugLogWithSystemInfo = operatingSystemInfo + commitHashInfo + text; const debugLogWithSystemInfo = `${operatingSystemInfo} ${commitHashInfo} ${text}`;
setContent(debugLogWithSystemInfo); setContent(debugLogWithSystemInfo);
}) })
.catch(console.warn); .catch(console.warn);

@ -105,6 +105,7 @@ async function verifyAllSignatures(
if (valid) { if (valid) {
return unchecked.base64EncodedData; return unchecked.base64EncodedData;
} }
// tslint:disable: no-console
console.info('got an opengroup message with an invalid signature'); console.info('got an opengroup message with an invalid signature');
return null; return null;
} catch (e) { } catch (e) {

Loading…
Cancel
Save