From 85758e170f99d63e0a12777dfadf6c9177b5b42d Mon Sep 17 00:00:00 2001
From: Pierre-Marie Dartus
Date: Tue, 12 Mar 2019 14:02:24 +0100
Subject: [PATCH] restrict usage of global properties attached on the window
object
---
package.json | 3 ++-
recommended.js | 11 +++--------
yarn.lock | 5 +++++
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/package.json b/package.json
index 4cd64d3..1c8567c 100644
--- a/package.json
+++ b/package.json
@@ -19,7 +19,8 @@
"@lwc/eslint-plugin-lwc": "^0.6.0",
"babel-eslint": "^10.0.1",
"eslint-plugin-import": "^2.14.0",
- "eslint-plugin-jest": "^22.0.0"
+ "eslint-plugin-jest": "^22.0.0",
+ "eslint-restricted-globals": "^0.2.0"
},
"devDependencies": {
"eslint": "^5.9.0",
diff --git a/recommended.js b/recommended.js
index cc14ccd..ca6a25d 100644
--- a/recommended.js
+++ b/recommended.js
@@ -1,5 +1,7 @@
'use strict';
+const restrictedGlobals = require('eslint-restricted-globals');
+
module.exports = {
plugins: ['import', 'jest'],
@@ -75,14 +77,7 @@ module.exports = {
// Variables
// https://eslint.org/docs/rules/#variables
'no-label-var': 'error',
- 'no-restricted-globals': [
- 'error',
- {
- name: 'event',
- message:
- 'Use local parameter instead of accessing the current event out of the global object.',
- },
- ],
+ 'no-restricted-globals': ['error'].concat(restrictedGlobals),
'no-shadow': 'error',
'no-shadow-restricted-names': 'error',
'no-undef-init': 'error',
diff --git a/yarn.lock b/yarn.lock
index 39f8fdf..b6142da 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -650,6 +650,11 @@ eslint-plugin-jest@^22.0.0:
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.1.0.tgz#9a4dfa3367563e8301560a7fb92ec309096dbca3"
integrity sha512-WcQd5LxEoAS20zuWEAd8CX0pVC+gGInZPcsoYvK5w7BrEJNmltyTxYYh1r0ct4GsahD2GvNySlcTcLtK2amFZA==
+eslint-restricted-globals@^0.2.0:
+ version "0.2.0"
+ resolved "https://registry.yarnpkg.com/eslint-restricted-globals/-/eslint-restricted-globals-0.2.0.tgz#7729f326af97bec7a7e56d9f7d9c064b79285c50"
+ integrity sha512-kwYJALm5KS2QW3Mc1PgObO4V+pTR6RQtRT65L1GQILlEnAhabUQqGAX7/qUjoQR4KZJKehWpBtyDEiDecwmY9A==
+
eslint-scope@3.7.1:
version "3.7.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"