Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@ioffice/tslint-config-ioffice
Advanced tools
1.1 Remove them. To prevent them make sure to use noUnusedParameters
in your
tsconfig.json
file.
// bad
function foo(a, b, c) {
return a + b;
}
// good
function foo(a, b) {
return a + b;
}
2.1 When you must use function expressions (as when passing an anonymous function), use arrow function notation.
// bad
[1, 2, 3].map(function (x) {
const y = x + 1;
return x * y;
});
// good
[1, 2, 3].map((x) => {
const y = x + 1;
return x * y;
});
// good
[0, null, 1, null, 2].filter(x => x !== null);
3.1 Use braces with all multi-line blocks.
// bad
if (test)
return false;
// good
if (test) return false;
// good
if (test) {
return false;
}
// bad
function foo() { return false; }
// good
function bar() {
return false;
}
3.2 If you're using multi-line blocks with if
and else
, put else
on the same line as
your if
block's closing brace.
// bad
if (test) {
thing1();
thing2();
}
else {
thing3();
}
// good
if (test) {
thing1();
thing2();
} else {
thing3();
}
4.1 Use soft tabs set to 2 spaces.
// bad
function foo() {
const name;
}
// bad
function bar() {
const name;
}
// good
function baz() {
const name;
}
4.2 Add spaces inside curly braces.
// bad
const foo = {clark: 'kent'};
// good
const foo = { clark: 'kent' };
5.1 Leading commas: Nope.
// bad
const story = [
once
, upon
, aTime
];
// good
const story = [
once,
upon,
aTime,
];
// bad
const hero = {
firstName: 'Ada'
, lastName: 'Lovelace'
, birthYear: 1815
, superPower: 'computers'
};
// good
const hero = {
firstName: 'Ada',
lastName: 'Lovelace',
birthYear: 1815,
superPower: 'computers',
};
6.1 Always use modules (import
/export
) over a non-standard module system. You can always
transpile to your preferred module system.
// bad
const iOfficeStyleGuide = require('./iOfficeStyleGuide');
module.exports = iOfficeStyleGuide.ts;
// ok
import * as iOfficeStyleGuide from './iOfficeStyleGuide';
const ts = iOfficeStyleGuide.ts;
export {
ts,
};
// best
import { ts } from './iOfficeStyleGuide';
export {
ts,
};
6.2 Do not use default exports. Use a single named export
which declares all the classes,
functions, objects and interfaces that the module is exporting.
// bad
export class A {}
export class B {}
export default A;
// good
class C {}
class D {}
export {
C,
D,
};
// bad
export default function() {
}
// good
function A() {
}
export { A };
// good
function A() {
}
export { A };
FAQs
IOFFICE TypeScript Style Guide
We found that @ioffice/tslint-config-ioffice demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.