Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nuxt/eslint-plugin-nuxt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.0.0
Choose a base ref
...
head repository: nuxt/eslint-plugin-nuxt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.0.0
Choose a head ref

Commits on Dec 19, 2020

  1. Copy the full SHA
    07299c0 View commit details
  2. chore(deps): update all non-major dependencies (#123)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Dec 19, 2020
    Copy the full SHA
    26bf676 View commit details
  3. chore(deps): update actions/setup-node action to v2 (#126)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Dec 19, 2020
    Copy the full SHA
    c81a2dc View commit details
  4. chore(deps): lock file maintenance (#124)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Dec 19, 2020
    Copy the full SHA
    4119c77 View commit details

Commits on Jan 18, 2021

  1. chore(deps): update all non-major dependencies (#129)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Jan 18, 2021
    Copy the full SHA
    2e6f76d View commit details
  2. chore(deps): lock file maintenance (#128)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Jan 18, 2021
    Copy the full SHA
    3494616 View commit details

Commits on Jan 23, 2021

  1. chore(deps): update all non-major dependencies (#130)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Jan 23, 2021
    Copy the full SHA
    21d16d9 View commit details

Commits on Jan 25, 2021

  1. chore(deps): lock file maintenance (#131)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Jan 25, 2021
    Copy the full SHA
    3231ed7 View commit details

Commits on Jan 31, 2021

  1. chore(deps): update devdependency eslint to ^7.19.0 (#132)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Jan 31, 2021
    Copy the full SHA
    505a575 View commit details

Commits on Feb 1, 2021

  1. chore(deps): lock file maintenance (#133)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Feb 1, 2021
    Copy the full SHA
    5d00844 View commit details

Commits on Feb 10, 2021

  1. chore(deps): update all non-major dependencies (#134)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Feb 10, 2021
    Copy the full SHA
    999e456 View commit details
  2. Copy the full SHA
    ac2a96e View commit details
  3. chore(deps): lock file maintenance (#135)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Feb 10, 2021
    Copy the full SHA
    5fb5cef View commit details

Commits on Feb 14, 2021

  1. chore(deps): update all non-major dependencies (#138)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Feb 14, 2021
    Copy the full SHA
    7f83e21 View commit details

Commits on Feb 16, 2021

  1. chore(deps): update dependency eslint-plugin-vue to ^7.6.0 (#140)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Feb 16, 2021
    Copy the full SHA
    0f7d226 View commit details
  2. chore(deps): lock file maintenance (#139)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Feb 16, 2021
    Copy the full SHA
    5c230d8 View commit details

Commits on Feb 19, 2021

  1. chore(deps): update devdependency standard-version to ^9.1.1 (#141)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Feb 19, 2021
    Copy the full SHA
    24dc965 View commit details

Commits on Mar 1, 2021

  1. Copy the full SHA
    2f3e010 View commit details
  2. Copy the full SHA
    c4bb52f View commit details

Commits on Mar 6, 2021

  1. chore(deps): update all non-major dependencies (#144)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Mar 6, 2021
    Copy the full SHA
    a7d5850 View commit details

Commits on Mar 10, 2021

  1. chore(deps): lock file maintenance (#145)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Mar 10, 2021
    Copy the full SHA
    7722a3a View commit details

Commits on Mar 16, 2021

  1. chore(deps): update devdependency eslint to ^7.22.0 (#146)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Mar 16, 2021
    Copy the full SHA
    13ffd6d View commit details
  2. Copy the full SHA
    033f763 View commit details

Commits on Mar 22, 2021

  1. chore(deps): update dependency eslint-plugin-vue to ^7.8.0 (#149)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Mar 22, 2021
    Copy the full SHA
    973b92f View commit details
  2. chore(deps): lock file maintenance (#148)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Mar 22, 2021
    Copy the full SHA
    5d4bed3 View commit details

Commits on May 26, 2021

  1. Copy the full SHA
    84a3f8f View commit details
  2. chore(deps): update devdependency jest to v27 (#156)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored May 26, 2021
    Copy the full SHA
    f94c8d6 View commit details
  3. chore(deps): update all non-major dependencies (#150)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored May 26, 2021
    Copy the full SHA
    51aefce View commit details

Commits on Jun 13, 2021

  1. chore(deps): update all non-major dependencies (#157)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Jun 13, 2021
    Copy the full SHA
    9c331ee View commit details
  2. chore(deps): lock file maintenance (#151)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Jun 13, 2021
    Copy the full SHA
    b2ea0ed View commit details

Commits on Oct 24, 2021

  1. chore: update dependencies

    Clark Du committed Oct 24, 2021
    Copy the full SHA
    72930a9 View commit details
  2. chore(ci): drop node 10

    Clark Du committed Oct 24, 2021
    Copy the full SHA
    e223f94 View commit details
  3. chore: upgrade to husky v7

    Clark Du committed Oct 24, 2021
    Copy the full SHA
    1391b4d View commit details
  4. Copy the full SHA
    59d9445 View commit details
  5. Copy the full SHA
    b4b59d9 View commit details
  6. chore(deps): lock file maintenance (#159)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Oct 24, 2021
    Copy the full SHA
    9f06035 View commit details
  7. chore(release): 2.0.2

    Clark Du committed Oct 24, 2021
    Copy the full SHA
    4de1ceb View commit details
  8. chore(release): 3.0.0

    Clark Du committed Oct 24, 2021
    Copy the full SHA
    61b3cb7 View commit details
Showing with 1,816 additions and 2,946 deletions.
  1. +2 −2 .github/workflows/ci.yaml
  2. +1 −0 .husky/.gitignore
  3. +4 −0 .husky/pre-commit
  4. +16 −0 CHANGELOG.md
  5. +10 −2 docs/rules/no-env-in-hooks.md
  6. +20 −1 lib/rules/__tests__/no-env-in-hooks.test.js
  7. +2 −2 lib/rules/no-env-in-hooks.js
  8. +19 −19 package.json
  9. +1,742 −2,920 yarn.lock
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -15,10 +15,10 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [10, 12]
node: [12, 14, 17]

steps:
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,22 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [3.0.0](https://github.com/nuxt/eslint-plugin-nuxt/compare/v2.0.2...v3.0.0) (2021-10-24)

### [2.0.2](https://github.com/nuxt/eslint-plugin-nuxt/compare/v2.0.0...v2.0.2) (2021-10-24)


### Bug Fixes

* disallow `process.browser` in `no-env-in-hooks` ([#127](https://github.com/nuxt/eslint-plugin-nuxt/issues/127)) ([07299c0](https://github.com/nuxt/eslint-plugin-nuxt/commit/07299c0ef16dc8efeef19bb2a29df9381aa99e77))

### [2.0.1](https://github.com/nuxt/eslint-plugin-nuxt/compare/v2.0.0...v2.0.1) (2021-10-24)


### Bug Fixes

* disallow `process.browser` in `no-env-in-hooks` ([#127](https://github.com/nuxt/eslint-plugin-nuxt/issues/127)) ([07299c0](https://github.com/nuxt/eslint-plugin-nuxt/commit/07299c0ef16dc8efeef19bb2a29df9381aa99e77))

## [2.0.0](https://github.com/nuxt/eslint-plugin-nuxt/compare/v1.0.0...v2.0.0) (2020-11-14)

## [1.0.0](https://github.com/nuxt/eslint-plugin-nuxt/compare/v0.5.2...v1.0.0) (2020-05-12)
12 changes: 10 additions & 2 deletions docs/rules/no-env-in-hooks.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# nuxt/no-env-in-hooks

> Disallow `process.server` and `process.client` in the following lifecycle hooks: `beforeMount`, `mounted`, `beforeUpdate`, `updated`, `activated`, `deactivated`, `beforeDestroy` and `destroyed`.
> Disallow `process.server`, `process.client` and `process.browser` in the following lifecycle hooks: `beforeMount`, `mounted`, `beforeUpdate`, `updated`, `activated`, `deactivated`, `beforeDestroy` and `destroyed`.
- :gear: This rule is included in `"plugin:nuxt/base"`.

## Rule Details

This rule is for preventing using `process.server/process.client` in client only Vue lifecycle hooks since they're only executed in client side.
This rule is for preventing using `process.server`/`process.client`/`process.browser` in client only Vue lifecycle hooks since they're only executed in client side.

Examples of **incorrect** code for this rule:

@@ -22,6 +22,11 @@ export default {
if (process.client) {
const foo = 'bar'
}
},
beforeDestroy() {
if (process.browser) {
const foo = 'bar'
}
}
}

@@ -38,6 +43,9 @@ export default {
},
beforeMount() {
const foo = 'bar'
},
beforeDestroy() {
const foo = 'bar'
}
}

21 changes: 20 additions & 1 deletion lib/rules/__tests__/no-env-in-hooks.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @fileoverview disallow `process.server/process.client` in `Vue Lifecycle Hooks`
* @fileoverview disallow `process.server`/`process.client`/`process.browser` in `Vue Lifecycle Hooks`
* @author Xin Du <clark.duxin@gmail.com>
*/
'use strict'
@@ -34,6 +34,9 @@ ruleTester.run('no-env-in-hooks', rule, {
},
beforeMount() {
const foo = 'bar'
},
beforeDestroy() {
const foo = 'bar'
}
}
`,
@@ -55,6 +58,11 @@ ruleTester.run('no-env-in-hooks', rule, {
if(process.client) {
const foo = 'bar'
}
},
beforeDestroy() {
if(process.browser) {
const foo = 'bar'
}
}
}
`,
@@ -64,6 +72,9 @@ ruleTester.run('no-env-in-hooks', rule, {
}, {
message: 'Unexpected process.client in beforeMount.',
type: 'MemberExpression'
}, {
message: 'Unexpected process.browser in beforeDestroy.',
type: 'MemberExpression'
}],
parserOptions
},
@@ -80,6 +91,11 @@ ruleTester.run('no-env-in-hooks', rule, {
if(process['server']) {
const foo = 'bar'
}
},
beforeDestroy() {
if(process['browser']) {
const foo = 'bar'
}
}
}
`,
@@ -89,6 +105,9 @@ ruleTester.run('no-env-in-hooks', rule, {
}, {
message: 'Unexpected process.server in beforeMount.',
type: 'MemberExpression'
}, {
message: 'Unexpected process.browser in beforeDestroy.',
type: 'MemberExpression'
}],
parserOptions
}
4 changes: 2 additions & 2 deletions lib/rules/no-env-in-hooks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @fileoverview disallow process.server and process.client in the following lifecycle hooks: beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy and destroyed
* @fileoverview disallow process.server, process.client and process.browser in the following lifecycle hooks: beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy and destroyed
* @author Xin Du <clark.duxin@gmail.com>
*/
'use strict'
@@ -27,7 +27,7 @@ module.exports = {
const forbiddenNodes = []
const options = context.options[0] || {}

const ENV = ['server', 'client']
const ENV = ['server', 'client', 'browser']
const HOOKS = new Set(['beforeMount', 'mounted', 'beforeUpdate', 'updated', 'activated', 'deactivated', 'beforeDestroy', 'destroyed'].concat(options.methods || []))

// ----------------------------------------------------------------------
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-nuxt",
"version": "2.0.0",
"version": "3.0.0",
"description": "ESLint plugin for Nuxt.js",
"author": "Clark Du <clarkdo@gmail.com>",
"license": "MIT",
@@ -25,33 +25,33 @@
"scripts": {
"test": "jest --silent",
"lint": "eslint ./",
"release": "standard-version"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
"release": "standard-version",
"postinstall": "husky install",
"prepublishOnly": "pinst --disable",
"postpublish": "pinst --enable",
"prepare": "husky install"
},
"lint-staged": {
"*.js": [
"eslint"
]
},
"devDependencies": {
"eslint": "^7.13.0",
"eslint-config-standard": "^16.0.1",
"eslint-plugin-import": "^2.22.1",
"eslint": "^8.1.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.1.0",
"husky": "^4.3.0",
"jest": "^26.6.3",
"lint-staged": "^10.5.1",
"standard-version": "^9.0.0"
"eslint-plugin-promise": "^5.1.1",
"eslint-plugin-standard": "^5.0.0",
"husky": "^7.0.4",
"jest": "^27.3.1",
"lint-staged": "^11.2.4",
"pinst": "^2.1.6",
"standard-version": "^9.3.2"
},
"dependencies": {
"eslint-plugin-vue": "^7.1.0",
"semver": "^7.3.2",
"vue-eslint-parser": "^7.1.1"
"eslint-plugin-vue": "^7.20.0",
"semver": "^7.3.5",
"vue-eslint-parser": "^8.0.0"
}
}
4,662 changes: 1,742 additions & 2,920 deletions yarn.lock

Large diffs are not rendered by default.