Skip to content

Commit 7c0a6b4

Browse files
committed
Format
1 parent 94edbe2 commit 7c0a6b4

File tree

4 files changed

+77
-22
lines changed

4 files changed

+77
-22
lines changed

webextensions/edge/background.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ chrome.scripting.registerContentScripts([{
88
js: ['content-main.js'],
99
allFrames: true,
1010
runAt: 'document_start',
11-
world: "MAIN",
11+
world: 'MAIN',
1212
}]);
1313

1414
chrome.scripting.registerContentScripts([{
@@ -17,17 +17,17 @@ chrome.scripting.registerContentScripts([{
1717
js: ['content-isolated.js'],
1818
allFrames: true,
1919
runAt: 'document_start',
20-
world: "ISOLATED",
20+
world: 'ISOLATED',
2121
}]);
2222

2323

24-
chrome.runtime.onMessage.addListener((message, sender, _sendResponse) => {
25-
console.log("accept message.");
24+
chrome.runtime.onMessage.addListener((message, _sender, _sendResponse) => {
25+
console.log('accept message.');
2626
if (message === 'cancel') {
2727
const query = new String('Q ' + BROWSER);
2828
chrome.runtime.sendNativeMessage(SERVER_NAME, query);
2929
}
3030
return true;
3131
});
3232

33-
console.log("service worker started.");
33+
console.log('service worker started.');

webextensions/edge/content-isolated.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
window.addEventListener("beforeprint", (event) => {
2-
console.log("Before print");
3-
console.log("window.isPrintEnabled", window.isPrintEnabled || false);
1+
window.addEventListener('beforeprint', _event => {
2+
console.log('Before print');
3+
console.log('window.isPrintEnabled', window.isPrintEnabled || false);
44
const isPrintEnabled = window.isPrintEnabled;
55
window.isPrintEnabled = false;
66
if (!isPrintEnabled) {
7-
chrome.runtime.sendMessage({ type: 'cancel' }, response => {
7+
chrome.runtime.sendMessage({ type: 'cancel' }, _response => {
88
});
99
}
1010
});
1111

12-
window.addEventListener('message', function(event) {
12+
window.addEventListener('message', event => {
1313
if (event.source !== window) return;
1414
if (event.data.type && event.data.type === 'FROM_PRINT_CANCELER_CONTENT_SCRIPT_MAIN') {
1515
console.log('receive message from window.print');

webextensions/edge/content-main.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
const originalPrint = window.print.bind(window);
22
window.print = function ()
33
{
4-
console.log("overloaded window.print");
5-
window.postMessage({ type: 'FROM_PRINT_CANCELER_CONTENT_SCRIPT_MAIN' });
6-
if (originalPrint)
7-
{
8-
setTimeout(function() {
9-
originalPrint();
10-
}, 200);
11-
}
4+
console.log('overloaded window.print');
5+
window.postMessage({ type: 'FROM_PRINT_CANCELER_CONTENT_SCRIPT_MAIN' });
6+
if (originalPrint)
7+
{
8+
setTimeout(function() {
9+
originalPrint();
10+
}, 200);
11+
}
1212
};

webextensions/eslint.config.mjs

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,72 @@ export default defineConfig([
77
{
88
files: ["**/*.{js,mjs,cjs}"],
99
plugins: { js },
10-
extends: ["js/recommended"]
10+
extends: ["js/recommended"],
1111
},
1212
{
13-
files: ["**/*.{js,mjs,cjs}"],
13+
files: ["**/*.{js,mjs,cjs}"],
14+
ignores: ["!**/.eslintrc.js", "**/eslint.config.mjs"],
1415
languageOptions: {
1516
globals: {
1617
...globals.browser,
1718
chrome: "readonly",
1819
module: "readonly",
1920
exports: "readonly",
20-
}
21-
}
21+
},
22+
},
23+
rules: {
24+
"no-const-assign": "error",
25+
26+
"prefer-const": ["warn", {
27+
destructuring: "any",
28+
ignoreReadBeforeAssign: false,
29+
}],
30+
31+
"no-var": "error",
32+
33+
"no-unused-vars": ["warn", {
34+
vars: "all",
35+
args: "after-used",
36+
argsIgnorePattern: "^_",
37+
caughtErrors: "all",
38+
caughtErrorsIgnorePattern: "^_",
39+
}],
40+
41+
"no-use-before-define": ["error", {
42+
functions: false,
43+
classes: true,
44+
}],
45+
46+
"no-unused-expressions": "error",
47+
"no-unused-labels": "error",
48+
49+
"no-undef": ["error", {
50+
typeof: true,
51+
}],
52+
53+
indent: ["warn", 2, {
54+
SwitchCase: 1,
55+
MemberExpression: 1,
56+
57+
CallExpression: {
58+
arguments: "first",
59+
},
60+
61+
VariableDeclarator: {
62+
var: 2,
63+
let: 2,
64+
const: 3,
65+
},
66+
}],
67+
68+
"no-underscore-dangle": ["warn", {
69+
allowAfterThis: true,
70+
}],
71+
72+
quotes: ["warn", "single", {
73+
avoidEscape: true,
74+
allowTemplateLiterals: true,
75+
}],
76+
},
2277
},
2378
]);

0 commit comments

Comments
 (0)