Skip to content

Commit

Permalink
fix!: deny majority of window properties and methods (#33)
Browse files Browse the repository at this point in the history
Closes: #32
  • Loading branch information
tpoisseau authored Mar 21, 2024
1 parent fd0b659 commit 1675274
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 11 deletions.
10 changes: 1 addition & 9 deletions base.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ module.exports = {
{ files: ['*.jsx'] },
],
rules: {
'no-restricted-globals': [
'error',
'close',
'open',
'event',
'name',
'status',
'length',
],
'no-restricted-globals': ['error', ...require('./noRestrictedGlobals')],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',

Expand Down
4 changes: 4 additions & 0 deletions eslintrc.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends:
- cheminfo
- ./base.js

81 changes: 81 additions & 0 deletions noRestrictedGlobals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
module.exports = [
'alert',
'blur',
'caches',
'captureEvents',
'clientInformation',
'close',
'closed',
'confirm',
'createImageBitmap',
'crossOriginIsolated',
'customElements',
'devicePixelRatio',
'dump',
'event',
'external',
'find',
'focus',
'frameElement',
'frames',
'fullScreen',
'getComputedStyle',
'getDefaultComputedStyle',
'getSelection',
'history',
'innerHeight',
'innerWidth',
'InstallTrigger',
'isSecureContext',
'length',
'location',
'locationbar',
'matchMedia',
'menubar',
'messenger',
'moveBy',
'moveTo',
'mozInnerScreenX',
'mozInnerScreenY',
'name',
'open',
'opener',
'origin',
'outerHeight',
'outerWidth',
'pageXOffset',
'pageYOffset',
'parent',
'personalbar',
'postMessage',
'print',
'prompt',
'releaseEvents',
'resizeBy',
'resizeTo',
'screen',
'screenLeft',
'screenTop',
'screenX',
'screenY',
'scroll',
'scrollbars',
'scrollBy',
'scrollByLines',
'scrollByPages',
'scrollMaxX',
'scrollMaxY',
'scrollTo',
'scrollX',
'scrollY',
'self',
'setResizable',
'speechSynthesis',
'status',
'statusbar',
'stop',
'toolbar',
'top',
'updateCommands',
'visualViewport',
];
Empty file added test/ok.js
Empty file.
11 changes: 9 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
'use strict';

// Make sure the library can be required.
require('..');
// make sure config is valid
const { ESLint } = require('eslint');

const eslint = new ESLint({ overrideConfigFile: 'eslintrc.test.yml' });

eslint.lintFiles(['test/ok.js']).catch(error => {
console.error(error);
process.exit(1);
});

0 comments on commit 1675274

Please sign in to comment.