Disallow side effects at the top level of files
You'll first need to install ESLint:
npm i eslint --save-dev
Next, install eslint-plugin-top
:
npm install eslint-plugin-top --save-dev
Add top
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": ["top"]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"top/no-top-level-variables": 2,
"top/no-top-level-side-effect": 2
}
}