sindresorhus/eslint-plugin-unicorn
GitHub で見るRule proposal: `no-top-level-side-effects`
Open
#1,661 opened on 2021年12月24日
:dollar: Funded on Issuehunthelp wantednew rule
説明
Description
Opinionated, difficult/impossible to implement, and likely super annoying in practice.
Reasoning: importing a file should not have side effects
Related rules:
- https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-unassigned-import.md
- https://eslint.org/docs/rules/no-new
Fail
document.title = 'gone'
Pass
export function init () {
document.title = 'gone'
}
function init () {
document.title = 'gone'
}
// Optional? Still a side effect, but at least it's wrapped
// and not lost between many function declarations.
// Maybe a single, unassigned function call per file could be allowed
init();
// Optional? Assignments could be considered side-effect free for the sake of usability
const details = new Map();
const response = fetch(); // even if they're not, really
const memoizedFetch = mem(fetch);
// in ./polyfill.js
// Optional? Some exceptions could be made by filename
document.title = 'gone'
Backers (Total: $20.00)
- fregante ($20.00)
Submitted pull Requests
Become a backer now!
Or submit a pull request to get the deposits!
Tips
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on IssueHunt to raise funds.