1.1.0 • Published 1 year ago

eslint-plugin-no-window-func v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

eslint-plugin-no-window-func

An ESLint plugin that disallows variable declarations using the names of methods on the window object. This helps prevent potential conflicts and unexpected behaviors in your JavaScript code.

Installation

You can install the plugin using npm:

npm install eslint-plugin-no-window-func --save-dev

Usage

To use this plugin, add it to your ESLint configuration file (.eslintrc.js, .eslintrc.json, etc.).

Example .eslintrc.js Configuration

module.exports = {
    "plugins": [
        "no-window-func"
    ],
    "rules": {
        "no-window-func/no-window-func": "error"
    }
};

Example Code

/* eslint no-window-func/no-window-func: "error" */
const alert = "test";  // This will cause an ESLint error
const myVar = "test";  // This is fine

Rule Details

This rule disallows variable names that match any of the methods on the window object. The following is a list of disallowed names:

  • alert
  • atob
  • blur
  • btoa
  • cancelAnimationFrame
  • cancelIdleCallback
  • captureEvents
  • clearInterval
  • clearTimeout
  • close
  • confirm
  • createImageBitmap
  • fetch
  • focus
  • getComputedStyle
  • getSelection
  • matchMedia
  • moveBy
  • moveTo
  • open
  • postMessage
  • print
  • prompt
  • queueMicrotask
  • releaseEvents
  • reportError
  • requestAnimationFrame
  • requestIdleCallback
  • resizeBy
  • resizeTo
  • scroll
  • scrollBy
  • scrollTo
  • setInterval
  • setTimeout
  • stop

Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch (git checkout -b my-new-feature).
  3. Commit your changes (git commit -am 'Add some feature').
  4. Push to the branch (git push origin my-new-feature).
  5. Create a new Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

Inspired by the need to maintain clean and conflict-free JavaScript code by preventing the use of window object method names as variable names.

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago