This repository has been archived by the owner on Mar 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c14eac
commit 07299c0
Showing
3 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <[email protected]> | ||
*/ | ||
'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 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <[email protected]> | ||
*/ | ||
'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 || [])) | ||
|
||
// ---------------------------------------------------------------------- | ||
|