Skip to content

Commit

Permalink
eslint: validate script imports (GoogleChrome#854)
Browse files Browse the repository at this point in the history
Add https://github.com/import-js/eslint-plugin-import for validing
script imports (eslint will fail if imported file does not exist).

Also fixes prettier errors in api-samples.
  • Loading branch information
sebastianbenz authored Mar 20, 2023
1 parent 2b485f1 commit ad857a2
Show file tree
Hide file tree
Showing 6 changed files with 1,747 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-env node */
module.exports = {
extends: ['prettier', 'eslint:recommended'],
extends: ['prettier', 'eslint:recommended', 'plugin:import/recommended'],
plugins: ['prettier'],
rules: {
'prettier/prettier': ['error'],
Expand Down
1 change: 0 additions & 1 deletion api-samples/action/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ <h2>Badge Text Color</h2>
</div>
</section>


<!-- badge - icon -->

<section id="setIcon">
Expand Down
3 changes: 1 addition & 2 deletions api-samples/action/demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ function debounce(timeout, callback) {
// .enable / .disable
// ------------------


const showToggleState = document.getElementById('show-toggle-state');
document
.getElementById('toggle-state-button')
Expand Down Expand Up @@ -164,7 +163,7 @@ document
showBadgeTextColor();
});

document
document
.getElementById('reset-badge-txt-color-button')
.addEventListener('click', async () => {
chrome.action.setBadgeTextColor({ color: '#000000' });
Expand Down
129 changes: 68 additions & 61 deletions api-samples/scripting/index.html
Original file line number Diff line number Diff line change
@@ -1,67 +1,74 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scripting Demo</title>
<link rel="stylesheet" href="index.css">
<script defer src="index.js"></script>
</head>
<body>
<form>
<h1>Scripting Demo</h1>
<div class="tabs">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Scripting Demo</title>
<link rel="stylesheet" href="index.css" />
<script defer src="index.js"></script>
</head>
<body>
<form>
<h1>Scripting Demo</h1>
<div class="tabs">
<label>
Dynamic
<input type="radio" name="type" value="dynamic" checked />
</label>
<label class="selected">
Programmatic
<input type="radio" name="type" value="programmatic" />
</label>
</div>
<label>
Dynamic
<input type="radio" name="type" value="dynamic" checked></input>
<span>Persist across sessions</span>
<select name="persist" value="no">
<option value="no">No</option>
<option value="yes">Yes</option>
</select>
</label>
<label class="selected">
Programmatic
<input type="radio" name="type" value="programmatic"></input>
<label>
<span>Run at</span>
<select name="run-at" value="document_idle">
<option value="document_start">document_start</option>
<option value="document_end">document_end</option>
<option value="document_idle">document_idle</option>
</select>
</label>
<label>
<span>World</span>
<select name="world" value="ISOLATED">
<option value="ISOLATED">ISOLATED</option>
<option value="MAIN">MAIN</option>
</select>
</label>
<label>
<span>All Frames</span>
<select name="all-frames" value="no">
<option value="no">No</option>
<option value="yes">Yes</option>
</select>
</label>
<label>
<span>Matches</span>
<input type="text" name="matches" value="https://example.com/*" />
</label>
</div>
<label>
<span>Persist across sessions</span>
<select name="persist" value="no">
<option value="no">No</option>
<option value="yes">Yes</option>
</select>
</label>
<label>
<span>Run at</span>
<select name="run-at" value="document_idle">
<option value="document_start">document_start</option>
<option value="document_end">document_end</option>
<option value="document_idle">document_idle</option>
</select>
</label>
<label>
<span>World</span>
<select name="world" value="ISOLATED">
<option value="ISOLATED">ISOLATED</option>
<option value="MAIN">MAIN</option>
</select>
</label>
<label>
<span>All Frames</span>
<select name="all-frames" value="no">
<option value="no">No</option>
<option value="yes">Yes</option>
</select>
</label>
<label>
<span>Matches</span>
<input type="text" name="matches" value='https://example.com/*'>
</label>
<p class="hint">Note: Make sure you request the required <code>host_permissions</code> in the manifest.</p>
<div class="buttons programmatic-buttons">
<button type="button" id="inject-programmatic">Execute Script</button>
</div>
<div class="buttons dynamic-buttons">
<button type="button" id="register-dynamic" disabled>Register Script</button>
<button type="button" id="unregister-dynamic" disabled>Unregister Script</button>
</div>
</form>
</body>
<p class="hint">
Note: Make sure you request the required
<code>host_permissions</code> in the manifest.
</p>
<div class="buttons programmatic-buttons">
<button type="button" id="inject-programmatic">Execute Script</button>
</div>
<div class="buttons dynamic-buttons">
<button type="button" id="register-dynamic" disabled>
Register Script
</button>
<button type="button" id="unregister-dynamic" disabled>
Unregister Script
</button>
</div>
</form>
</body>
</html>
Loading

0 comments on commit ad857a2

Please sign in to comment.