lint files

pull/2242/head
Audric Ackermann 2 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,
importer: importOnce,
},
dev: {
dist: {
files: {
'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: {
transpile: {
cmd: 'yarn transpile',
@ -75,12 +62,11 @@ module.exports = grunt => {
updateLocalConfig({ commitHash: hash });
});
grunt.registerTask('dev', ['default', 'watch']);
grunt.registerTask('date', ['gitinfo']);
grunt.registerTask('default', [
'exec:build-protobuf',
'exec:transpile',
'sass',
'exec:transpile',
'date',
'getCommitHash',
]);

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

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

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

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

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

@ -86,17 +86,19 @@ class SessionPasswordPromptInner extends React.PureComponent<{}, State> {
);
return (
<div className={wrapperClass}>
<div className={containerClass}>
<div className={infoAreaClass}>
{infoIcon}
<h1>{infoTitle}</h1>
<div className="password">
<div className={wrapperClass}>
<div className={containerClass}>
<div className={infoAreaClass}>
{infoIcon}
<h1>{infoTitle}</h1>
</div>
{featureElement}
{errorSection}
{buttonGroup}
</div>
{featureElement}
{errorSection}
{buttonGroup}
</div>
</div>
);

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

@ -32,8 +32,9 @@ if (environment === 'production') {
// We load config after we've made our modifications to NODE_ENV
//tslint-disable no-require-imports no-var-requires
// tslint:disable-next-line: no-require-imports no-var-requires
const c = require('config');
(c as any).environment = environment;
c.environment = environment;
// Log resulting env vars in use by config
['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-next-line: restrict-plus-operands
const encryptedBufferWithHeader = new Uint8Array(bufferOut.length + header.length);
encryptedBufferWithHeader.set(header);
encryptedBufferWithHeader.set(bufferOut, header.length);

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

@ -33,7 +33,8 @@ export function stubUtilWorker(fnName: string, returnedValue: any): sinon.SinonS
}
export function stubCreateObjectUrl() {
(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)}`;
};
}

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

@ -11,6 +11,7 @@ const StyledContent = styled.div`
const DebugLogTextArea = (props: { content: string }) => {
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%' }} />;
};
@ -49,7 +50,7 @@ const DebugLogViewAndSave = () => {
// eslint-disable-next-line more/no-then
fetch()
.then((text: any) => {
const debugLogWithSystemInfo = operatingSystemInfo + commitHashInfo + text;
const debugLogWithSystemInfo = `${operatingSystemInfo} ${commitHashInfo} ${text}`;
setContent(debugLogWithSystemInfo);
})
.catch(console.warn);

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

Loading…
Cancel
Save