Skip to content

Commit

Permalink
lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilb committed Apr 20, 2022
1 parent add267a commit 5c9b34f
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 65 deletions.
20 changes: 3 additions & 17 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
]);
Expand Down
6 changes: 0 additions & 6 deletions background.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -40,9 +37,6 @@
</div>
</div>
</div>
<script>
var exports = {};
</script>
<script type="text/javascript">
require('./ts/mains/main_renderer.js');
</script>
Expand Down
7 changes: 0 additions & 7 deletions debug_log.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 2 additions & 0 deletions debug_log_preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 0 additions & 1 deletion stylesheets/_session_password.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 2 additions & 0 deletions stylesheets/manifest.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@

@import 'session_slider';
@import 'session_conversation';

@import '_session_password';
22 changes: 12 additions & 10 deletions ts/components/SessionPasswordPrompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
);
Expand Down
1 change: 1 addition & 0 deletions ts/mains/about_start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ global.setTimeout(() => {
states.push(window.getAppInstance());
}
if (version) {
// tslint:disable: no-inner-html
version.innerHTML = `v${window.getVersion()}`;
}

Expand Down
3 changes: 2 additions & 1 deletion ts/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
1 change: 1 addition & 0 deletions ts/node/encrypt_attachment_buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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', () => {});
Expand Down
3 changes: 2 additions & 1 deletion ts/test/test-utils/utils/stubbing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`;
};
}
Expand Down
39 changes: 20 additions & 19 deletions ts/test/types/initializeAttachmentMetadata_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion ts/views/DebugLogView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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%' }} />;
};

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions ts/webworker/workers/util.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5c9b34f

Please sign in to comment.