Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

eslint-plugin-nuxt

nuxt729.7kMIT4.0.0

ESLint plugin for Nuxt.js

nuxt, eslint, eslintplugin

readme

eslint-plugin-nuxt

Standard JS Circle CI npm version npm downloads

:sparkles: ESLint plugin for Nuxt.js

:cd: Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev
success Saved 1 new dependencies

Next, install eslint-plugin-nuxt:

$ npm install eslint-plugin-nuxt --save-dev
success Saved 1 new dependencies

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-nuxt globally.

:rocket: Usage

Add nuxt to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

  1. Use our preset to extend recommended defaults:
{
  "extends": [
    "plugin:nuxt/recommended"
  ]
}
  1. Or specify individual rules manually:
{
    "plugins": [
        "nuxt"
    ],
    "rules": {
        "nuxt/rule-name": 2
    }
}

:gear: Configs

This plugin provides four predefined configs:

  • plugin:nuxt/base - Settings and rules to enable correct ESLint parsing
  • plugin:nuxt/recommended - Above, plus rules to enforce subjective community defaults to ensure consistency

:bulb: Rules

Base Rules

{
  "extends": "plugin:nuxt/base"
}

| | Rule ID | Description | |:---|:--------|:------------| | | nuxt/no-env-in-context | Disallow context.isServer/context.isClient in asyncData/fetch/nuxtServerInit | | | nuxt/no-env-in-hooks | Disallow process.server/process.client in client only Vue lifecycle hooks like: mounted, beforeMount, updated... | | | nuxt/no-globals-in-created | Disallow window/document in created/beforeCreate | | | nuxt/no-this-in-fetch-data | Disallow this in asyncData/fetch | | | nuxt/no-cjs-in-config | Disallow require/modules.exports/exports in nuxt.config.js |

Include all the below rules, as well as all priority rules in above categories, with:

{
  "extends": "plugin:nuxt/recommended"
}

| | Rule ID | Description | |:---|:--------|:------------| | | nuxt/no-timing-in-fetch-data | Disallow setTimeout/setInterval in asyncData/fetch |

Other Rules

| | Rule ID | Description | |:---|:--------|:------------| | | nuxt/require-func-head | Enforce head property in component to be a function. |

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

4.0.0 (2022-08-31)

3.2.0 (2022-03-13)

Features

  • add base config (fb94d7b)
  • add no-env-in-context (42ada82)
  • add no-env-in-hooks (016f609)
  • add no-env-in-mounted (4b32052)
  • add no-this-in-fetch (94552c7)
  • add no-timing-in-fetch-data (1436642)
  • add rule no-this-in-async-data (96ce607)
  • init no-this-in-async-data (cb03b4d)
  • init no-this-in-fetch (581005a)
  • move ssr to base (1da2f0c)
  • rule: add no-globals-in-created (09eaa50)
  • rule: add require-func-head in recommended (#62) (f7e7b87)
  • rule: no commonjs api in nuxt config (eb02e0e)
  • upgrade eslint to v7 (3e46242)
  • upgrade eslint-plugin-vue to v6 (b5b1bf4)

Bug Fixes

  • correct category for no-timing-in-fetch-data (ae6b499)
  • disallow process.browser in no-env-in-hooks (#127) (e421323)
  • enable no-this-in-fetch only for nuxt < 2.12 (a0e3f73)
  • incompatible version of vue-eslint-parser (a0e355f)
  • not-null check for hooks (ee73e8b)
  • nuxt/require-func-head doesnt work with factories (11492e2), closes #94
  • remove require-func-head from recommend (25d108c), closes #93
  • rule not found (976f28d)
  • undefined value in nuxt/no-env-in-context (b9fed00)
  • use filename instead of full path (d22e011)
  • wrong index file (f95cf1d)

3.1.0 (2021-11-28)

3.0.0 (2021-10-24)

2.0.2 (2021-10-24)

Bug Fixes

  • disallow process.browser in no-env-in-hooks (#127) (07299c0)

2.0.1 (2021-10-24)

Bug Fixes

  • disallow process.browser in no-env-in-hooks (#127) (07299c0)

2.0.0 (2020-11-14)

1.0.0 (2020-05-12)

Features

Bug Fixes

  • nuxt/require-func-head doesnt work with factories (5480fd0), closes #94
  • remove require-func-head from recommend (580ffa2), closes #93

0.5.2 (2020-03-20)

Bug Fixes

  • enable no-this-in-fetch only for nuxt < 2.12 (66fc2e0)

0.5.1 (2020-02-09)

Features

  • rule: add require-func-head in recommended (#62) (7d0926f)

Bug Fixes

  • correct category for no-timing-in-fetch-data (bbf6ce9)

0.5.0 (2019-11-09)

Features

  • upgrade eslint-plugin-vue to v6 (ecf42f2)

0.4.3 (2019-03-12)

Bug Fixes

  • incompatible version of vue-eslint-parser (9bb12ae)

0.4.2 (2019-02-21)

Bug Fixes

  • use filename instead of full path (4c62a37)

0.3.0 (2018-12-19)

Bug Fixes

  • not-null check for hooks (daa93f3)

Features

0.2.0 (2018-12-10)

Features

0.1.3 (2018-12-10)

0.1.2 (2018-12-10)

Bug Fixes

  • rule not found (c63f657)
  • undefined value in nuxt/no-env-in-context (17cb2d9)

0.1.1 (2018-12-10)

Bug Fixes

0.1.0 (2018-12-10)

Features

  • add base config (bf0759a)
  • rule: add no-globals-in-created (d8736e9)
  • add no-env-in-context (71b09e9)
  • add no-this-in-fetch (fe4d381)
  • add no-timing-in-fetch-data (2945b70)
  • add rule no-this-in-async-data (9a56aae)
  • init no-this-in-async-data (e23f4ed)
  • init no-this-in-fetch (4bf0385)