@doochik/eslint-plugin-location

ESLint plugin for Location

Usage no npm install needed!

<script type="module">
  import doochikEslintPluginLocation from 'https://cdn.skypack.dev/@doochik/eslint-plugin-location';
</script>

README

@doochik/eslint-plugin-location

ESLint plugin for 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:

{
    "plugins": [
        "@doochik/eslint-plugin-location"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "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:

location.replace.href.replace('foo', 'bar')

Good examples:

location.replace('https://example.com')
location.href = new URL('https://example.com');
location = new URL('https://example.com');