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.
mango-scripts
Advanced tools
This is a collection of common scripts that abstract away general configuration for applications, such as linting, code style formatting, testing etc. In addition, you as a developer can override or extend all configs 👏.
Projects typically have the same set of duplicated configs for testing/linting etc or worse yet different configs and rules.
This package has been created for two reasons:
This package includes the following 4 scripts for use in applications:
Using Yarn
yarn add --dev mango-scripts
or NPM
npm install --save-dev mango-scripts
Setup your package.json file with the following:
{
"scripts": {
"format": "mango-scripts format",
"precommit": "app-scripts precommit",
"test": "mango-scripts test",
"lint": "mango-scripts lint"
}
}
And execute a script, e.g.
yarn run format
Running yarn run format
will execute Prettier which will auto format your code and ensures it conforms to a consistent style (meaning no more code style discussions 👍).
See customising section for advanced usage.
While manually formatting code is okay, it can become a pain to do this yourself repeatedly. This script adds the ability to automatically run Prettier whenever you commit code. All you need to do is to add the following to your package.json:
"precommit": "mango-scripts precommit"
Internally it uses a Git Hook (via the packages Husky and Lint Staged) to check for staged files only and runs the format script on those files.
See customising section for advanced usage.
Running yarn run test
will execute Jest.
This means you can test React components using something like:
import React from 'react';
const Input = props => <input {...props} />;
describe('My Component', () => {
it('should render an input', () => {
const wrapper = shallow(<Input type="text" />);
expect(wrapper).toMatchSnapshot();
expect(wrapper).toHaveProp('type', 'text');
});
});
Running yarn run lint
will execute ESLint. The config provided extends from Mango.
Note the config includes an override section for Jest that only applies to files in the format
**/__tests__/*.js
, however because the config is not in the root directory the ESLint parser does not pick this up. Therefore it is recommended to extend the config and place it in your root directory. See customising section for usage.
All scripts have the ability for the config used to be modified, you can either specify your own config or extend the provided config. You can also pass any cli arguments and these will be passed onto the relevant script.
To supply your own config file the format
script will automatically look for any one of the following and use them in place of the built-in config:
'--config'
argument, e.g. yarn run format --config ./file-to-config
To extend the config file simply import it and modify it, e.g. create a .prettierrc.js file with:
module.exports = {
...require('mango-scripts/configs/prettier'),
singleQuote: false,
};
In addition you can also supply your own ignore file. The format
script will automatically look for any one of the following:
'--ignore-path'
argument, e.g. yarn run format --ignore-path ./file-to-ignore-config
To supply your own config file the precommit
script will automatically look for any one of the following and use them in place of the built-in config:
'--config'
argument, e.g."precommit": "mango-scripts precommit --config ./file-to-config"
To extend the config file simply import it and modify it, e.g. create a .lint-staged.config.js file with:
module.exports = {
...require('mango-scripts/configs/prettier'),
};
To supply your own config file the test
script will automatically look for any one of the following and use them in place of the built-in config:
'--config'
argument, e.g. yarn run test --config ./file-to-config
To extend the config file simply import it and modify it, e.g. create a jest.config.js file with:
module.exports = {
...require('mango-scripts/configs/jest'),
moduleNameMapper: {
// Webpack aliases
},
};
In addition the test
script will use the built-in Babel config. To override this, it will automatically look for and use any one of the following:
.babelrc
in your project rootbabel
key in your package.jsonYou will have to then configure the Babel test setup yourself. The test
script sets the NODE_ENV to test
which will be of use to you. (See the Babel config used in src/configs/babel/config.js
to get an idea).
To supply your own config file the lint
script will automatically look for any one of the following and use them in place of the built-in config:
'--config'
argument, e.g. yarn run lint --config ./file-to-config
To extend the config file simply import it and modify it, e.g. create a .eslintrc.js file with:
module.exports = {
extends: [require.resolve('mango-scripts/configs/eslint')],
rules: {
'no-unused-vars': ['warn'],
},
};
In addition you can also supply your own ignore file. The lint
script will automatically look for any one of the following:
'--ignore-path'
argument, e.g. yarn run lint --ignore-path ./file-to-ignore-config
module.exports = {
extends: [require.resolve('mango-scripts/configs/eslint')],
};
FAQs
Common scripts (testing/linting etc) for use in projects
The npm package mango-scripts receives a total of 1 weekly downloads. As such, mango-scripts popularity was classified as not popular.
We found that mango-scripts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.