Skip to content

Commit

Permalink
Refactor contentScripts to use ES6 imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromepl committed Aug 27, 2022
1 parent cb305ef commit 27327da
Show file tree
Hide file tree
Showing 41 changed files with 1,168 additions and 511 deletions.
28 changes: 11 additions & 17 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
env:
browser: true
es2021: true
extends: 'eslint:recommended'
extends:
- eslint:recommended
- plugin:import/recommended
globals:
chrome: readonly
$: readonly
store: readonly # From utils/storageManager
load: readonly # From utils/storageManager
loadAll: readonly # From utils/storageManager
clearPage: readonly # From utils/storageManager
update: readonly # From utils/storageManager
addHighlightError: readonly # From utils/errorManager
highlight: readonly # From utils/highlight
highlightV3: readonly # From utils/highlightV3
highlightV4: readonly # From utils/highlightV4
highlight_legacy: readonly # From utils/highlight_legacy
HIGHLIGHT_CLASS: readonly # From utils/highlight
DELETED_CLASS: readonly # From utils/highlight
onHighlightMouseEnterOrClick: readonly # From hoverTools/hoverTools
onHighlightMouseLeave: readonly # From hoverTools/hoverTools
highlightOnSelection: readonly # From contentScripts/highlighterCursor
ignorePatterns:
- lib/*
- config/*
Expand Down Expand Up @@ -94,7 +81,9 @@ rules:
jsx-quotes: error
key-spacing: 'off'
keyword-spacing: 'off'
linebreak-style: 'off'
linebreak-style:
- error
- unix
lines-around-comment: error
lines-between-class-members: error
max-classes-per-file: error
Expand Down Expand Up @@ -246,3 +235,8 @@ rules:
yoda:
- error
- never
import/order: ["error", {
"groups": ["index", "sibling", "parent", "internal", "external", "builtin", "object", "type"],
"newlines-between": "always",
"alphabetize": { "order": "asc", "caseInsensitive": true },
}]
6 changes: 6 additions & 0 deletions contentScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Use a dynamic import as a work-around to content scripts not supporting JS modules (ES6)
(async () => {
const src = chrome.runtime.getURL('src/contentScripts/index.js');
const contentScript = await import(src);
contentScript.initialize();
})();
14 changes: 3 additions & 11 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,10 @@
],
"js": [
"lib/jquery-2.1.3.min.js",
"src/utils/storageManager.js",
"src/utils/highlight.js",
"src/utils/highlightV3.js",
"src/utils/highlightV4.js",
"src/utils/highlight_legacy.js",
"src/utils/errorManager.js",
"src/hoverTools/hoverTools.js",
"src/contentScripts/loadHighlights.js",
"src/contentScripts/highlighterCursor.js"
"contentScript.js"
],
"css": [
"src/hoverTools/hoverTools.css"
"src/contentScripts/hoverTools/index.css"
],
"all_frames": true
}
Expand Down Expand Up @@ -83,7 +75,7 @@
"resources": [
"images/*.png",
"images/*.svg",
"src/hoverTools/hoverTools.html"
"src/contentScripts/*"
],
"matches": [
"<all_urls>"
Expand Down
Loading

0 comments on commit 27327da

Please sign in to comment.