https://github.com/doochik/eslint-plugin-location
ESLint plugin for Location
https://github.com/doochik/eslint-plugin-location
Last synced: 5 months ago
JSON representation
ESLint plugin for Location
- Host: GitHub
- URL: https://github.com/doochik/eslint-plugin-location
- Owner: doochik
- License: mit
- Created: 2021-01-25T18:46:46.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-09-18T13:51:44.000Z (almost 2 years ago)
- Last Synced: 2025-10-26T16:12:21.472Z (9 months ago)
- Language: JavaScript
- Size: 208 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @doochik/eslint-plugin-location
ESLint plugin for [Location](https://developer.mozilla.org/en-US/docs/Web/API/Location).
## Installation
```
$ npm install --save-dev @doochik/eslint-plugin-location
```
## Usage
Add `@doochik/eslint-plugin-location` to the plugins section of your `.eslintrc` configuration file:
```json
{
"plugins": [
"@doochik/eslint-plugin-location"
]
}
```
Then configure the rules you want to use under the rules section.
```json
{
"rules": {
"@doochik/location/prefer-new-url": "error"
}
}
```
### Rule "location/prefer-new-url"
`location/prefer-new-url` Forbid `location.href.replace()` in favor `new URL()`.
Bad examples:
```javascript
location.replace.href.replace('foo', 'bar')
```
Good examples:
```javascript
location.replace('https://example.com')
location.href = new URL('https://example.com');
location = new URL('https://example.com');
```