Skip to content

bjoerniesanders/eslint-plugins

Repository files navigation

ESLint Plugin: No Restricted Time Functions

This ESLint plugin aids in avoiding potential timezone-related issues in JavaScript applications when using date-fns library. Some functions such as endOfDay or endOfMonth from date-fns operate on the local timezone. If your application server resides in a different timezone than your users, it could potentially lead to bugs.

This plugin provides ESLint rules to highlight the usage of such functions and encourages developers to consider the implications of timezones in their applications.

🔧 Installation

Install this plugin via npm:

npm i @bsand/eslint-plugin-time-functions@latest --save-dev

⚙️ Usage

After installation, you can configure this plugin in your ESLint configuration file (.eslintrc).

🔎 Rules

  • no-restricted-time-functions: This rule prevents the use of certain JavaScript time functions that could lead to timezone-related bugs.

📚 Solution

For handling timezone-sensitive functions, consider utilizing timezone-aware methods or libraries. For example, here's a solution provided on Stack Overflow for using date-fns with timezones.

🤝 Contributing

We value and appreciate contributions from the community. If you have suggestions for improvements or notice any bugs, please feel free to create a pull request or open an issue in our repository.

⚖️ License

This project is licensed under the MIT license.

👤 About

This project is maintained by @bsand, a JavaScript enthusiast who is passionate about building better and safer JavaScript applications.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published