forked from sindresorhus/globals
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automate update browsers default scope [wip] sindresorhus#164 sindres…
- Loading branch information
Yury Shapkarin
committed
Jul 6, 2020
1 parent
64a645b
commit aad6d7a
Showing
5 changed files
with
85 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
'use strict'; | ||
|
||
const blacklist = [ | ||
/^webkit/i, | ||
'BeforeInstallPromptEvent', | ||
/^Bluetooth/, | ||
'CDATASection', | ||
'captureEvents', | ||
'InputDeviceCapabilities', | ||
'releaseEvents', | ||
'SyncManager', | ||
/^USB/, | ||
|
||
// DevTools globals | ||
'chrome', | ||
'$_', | ||
'$0', | ||
'$1', | ||
'$2', | ||
'$3', | ||
'$4', | ||
'$', | ||
'$$', | ||
'$x', | ||
'clear', | ||
'copy', | ||
'debug', | ||
'dir', | ||
'dirxml', | ||
'getEventListeners', | ||
'inspect', | ||
'keys', | ||
'monitor', | ||
'monitorEvents', | ||
'profile', | ||
'profileEnd', | ||
'queryObjects', | ||
'table', | ||
'undebug', | ||
'unmonitor', | ||
'unmonitorEvents', | ||
'values' | ||
]; | ||
|
||
const globals = Object.getOwnPropertyNames(window) | ||
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase())) | ||
.filter(global => { | ||
for (const pattern of blacklist) { | ||
if (typeof pattern === 'string') { | ||
if (global === pattern) { | ||
return false; | ||
} | ||
} else { | ||
if (pattern.test(global)) { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
}); | ||
|
||
const ret = {}; | ||
for (const key of globals) { | ||
ret[key] = key.startsWith('on'); | ||
} | ||
|
||
copy(JSON.stringify(ret, null, '\t')); |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
|
||
const file = fs.readFileSync('./browser_vars.json'); | ||
|
||
console.log(file); |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### Usage | ||
- Run `npm run get-jshint-browser' | ||
- Open an Incognito window in Chrome Canary and paste the above into the console. | ||
You'll now have a new object in your clipboard for the `browser` field in `globals.json`. | ||
- You still need to manually filter out items from the `builtin` list. | ||
- Paste the reult to the `globals.json` to the `browser` section. |