
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
@shopgate/eslint-config
Advanced tools
Shopgate's reasonable approach to JavaScript.
This configuration is an extension of the airbnb codestyle which is available here.
npm i @shopgate/eslint-config --save-dev
Add the following to the .eslintrc
in your project:
{
"extends": "@shopgate/eslint-config",
...
}
No code should be left commented out.
/**
* static propTypes = {
* width: PropTypes.string.isRequired,
* color: PropTypes.string,
* height: PropTypes.string.isRequired,
* };
*/
Dangling commas are required for objects with multiple items or properties. This applies
to Array
, Object
, Import
and Export
.
// bad
const myObject = {
a: 1,
b: 2
};
// good
const myObject = {
a: 1,
b: 2,
};
// bad
import { var1, var2, var3 } from 'Variables';
// good
import {
var1,
var2,
var3,
} from 'Variables';
There should not be multiple empty lines between code blocks.
// bad
const a = 1;
const b = 1;
while (...) {
...
}
// good
const a = 1;
const b = 2;
while (...) {
...
}
All comments should beging with a capital letter. This makes comments more readable and forces more care when constructing comments.
// bad
/**
* toString() needs to be called here because...
*/
// good
/**
* This string now needs to be lowercase so that...
*/
A function should not simply call another function.
const funcA = (params) {
...
};
const funcB = (params) {
funcA(params);
};
If an object is defined with multiple properties then each property should occupy a new line.
// bad
const x = { a: 1, b: 2, c: 3 };
// good
const w = { a: 1 };
const x = {
a: 1,
b: 2,
c: 3,
};
Every Function
, Class
, Method
and Arrow Function
definition should include a
valid JSDoc specification.
// bad (missing parameter descriptions)
/**
* This is funcA. It does something complicated.
*/
const funcA = (param1, param2) {
...
};
// bad (invalid specification)
/**
* This is funcB. It also does something complicated.
* @param {Object} parameters
*/
const funcB = (param1, param2) {
...
};
// good
/**
* It does something simple because we are using our heads.
* @param {string} param1 - My first parameter.
* @param {boolean} param2 - My Second parameter.
*/
const funcC = (param1, param2) {
...
};
Proptypes should be sorted by type (required or not) and alphabetically.
// bad
static propTypes = {
width: PropTypes.string.isRequired,
color: PropTypes.string,
height: PropTypes.string.isRequired,
};
// good
static propTypes = {
height: PropTypes.string.isRequired,
width: PropTypes.string.isRequired,
color: PropTypes.string,
};
FAQs
Eslint configuration for the Shopgate Connect projects.
We found that @shopgate/eslint-config demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.