Skip to content

Commit 969bafb

Browse files
authored
Refactor/single extension (#1008)
* refactor(Extension): move from Extension/firefox to extension * refactor(Extension): unify extensions * refactor(Extension): fix .eslintrs.js and execute npm run fix * refactor(Extension): apply ESLint and prettier To allow ESLint to parse the most modern JavaScript a dependecy on babel has been added. This change allows us to enforce consistent formatting across the extension in the future * chore(conda): unlock node version This change was enabled by removing npm-run-all * feat(extension): use content.ts for content.js * test(custom_function): use new selenium attributes * fix(webdriver_utils): use new selenium methods
1 parent 2a62b79 commit 969bafb

File tree

85 files changed

+11395
-25945
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+11395
-25945
lines changed

.dockerignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ firefox-bin
1818
venv
1919

2020
# npm packages
21-
Extension/firefox/node_modules
21+
Extension/node_modules
2222
Extension/webext-instrumentation/node_modules
2323

2424
# built extension artifacts
25-
Extension/firefox/dist
26-
Extension/firefox/openwpm.xpi
27-
Extension/firefox/src/content.js
28-
Extension/firefox/src/feature.js
25+
Extension/dist
26+
Extension/openwpm.xpi
27+
Extension/src/content.js
28+
Extension/src/feature.js

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ docs/apidoc/
9191
node_modules
9292

9393
# built extension artifacts
94-
Extension/firefox/dist
95-
Extension/firefox/openwpm.xpi
96-
Extension/firefox/src/content.js
97-
Extension/firefox/src/feature.js
94+
Extension/dist
95+
Extension/openwpm.xpi
96+
Extension/bundled/content.js
97+
Extension/bundled/feature.js
9898

9999
datadir

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ the project as well as the one you plan to change fundamentally.
3535

3636
### Editing instrumentation
3737

38-
The instrumentation extension is included in `/Extension/firefox/`.
38+
The instrumentation extension is included in `/Extension/`.
3939
The instrumentation itself (used by the above extension) is included in
4040
`/Extension/webext-instrumentation/`.
4141
Any edits within these directories will require the extension to be re-built to produce
4242
a new `openwpm.xpi` with your updates. You can use `./scripts/build-extension.sh` to do this,
43-
or you can run `npm run build` from `Extension/firefox/`.
43+
or you can run `npm run build` from `/Extension/`.
4444

4545
### Debugging the platform
4646

Extension/.eslintrc.js

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
/* eslint-env node */
2+
/*
3+
This ESLint config aims to work with both
4+
the JavaScript and the TypeScript parts of the
5+
codebase.
6+
*/
7+
8+
module.exports = {
9+
root: true,
10+
env: {
11+
node: true,
12+
es6: true,
13+
webextensions: true,
14+
browser: true,
15+
},
16+
parser: "@babel/eslint-parser",
17+
extends: ["prettier", "eslint:recommended"],
18+
ignorePatterns: [
19+
"bundled/feature.js",
20+
"bundled/content.js",
21+
"bundled/privileged/sockets/bufferpack.js" /** This is a file we just copied in */,
22+
"build/",
23+
"dist/",
24+
"node_modules/",
25+
],
26+
plugins: [
27+
"eslint-plugin-import",
28+
"eslint-plugin-jsdoc",
29+
"eslint-plugin-unicorn",
30+
"eslint-plugin-mozilla",
31+
],
32+
rules: {
33+
"arrow-parens": ["off", "always"],
34+
"brace-style": ["off", "off"],
35+
"comma-dangle": "off",
36+
complexity: "off",
37+
"constructor-super": "error",
38+
"eol-last": "off",
39+
eqeqeq: ["warn", "smart"],
40+
"guard-for-in": "warn",
41+
"id-blacklist": "warn",
42+
"id-match": "warn",
43+
"import/no-extraneous-dependencies": ["error"],
44+
"import/no-internal-modules": "error",
45+
"jsdoc/check-alignment": "error",
46+
"jsdoc/check-indentation": "error",
47+
"jsdoc/newline-after-description": "error",
48+
"linebreak-style": "off",
49+
"max-classes-per-file": ["error", 1],
50+
"max-len": "off",
51+
"new-parens": "off",
52+
"newline-per-chained-call": "off",
53+
"no-bitwise": "warn",
54+
"no-caller": "error",
55+
"no-cond-assign": "error",
56+
"no-debugger": "error",
57+
"no-duplicate-case": "error",
58+
"no-duplicate-imports": "error",
59+
"no-empty": "warn",
60+
"no-eval": "error",
61+
"no-extra-bind": "error",
62+
"no-extra-semi": "off",
63+
"no-fallthrough": "off",
64+
"no-invalid-this": "off",
65+
"no-irregular-whitespace": "off",
66+
"no-multiple-empty-lines": "off",
67+
"no-new-func": "error",
68+
"no-new-wrappers": "error",
69+
"no-redeclare": "error",
70+
"no-return-await": "error",
71+
"no-sequences": "error",
72+
"no-sparse-arrays": "error",
73+
"no-template-curly-in-string": "error",
74+
"no-throw-literal": "error",
75+
"no-trailing-spaces": "off",
76+
"no-undef-init": "error",
77+
"no-underscore-dangle": "warn",
78+
"no-unsafe-finally": "error",
79+
"no-unused-labels": "error",
80+
"no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
81+
"no-var": "error",
82+
"object-shorthand": "error",
83+
"one-var": ["warn", "never"],
84+
"prefer-const": "error",
85+
"prefer-object-spread": "error",
86+
"quote-props": "off",
87+
radix: "error",
88+
"space-before-function-paren": "off",
89+
"space-in-parens": ["off", "never"],
90+
"spaced-comment": [
91+
"error",
92+
"always",
93+
{
94+
markers: ["/"],
95+
},
96+
],
97+
"unicorn/prefer-ternary": "error",
98+
"use-isnan": "error",
99+
"valid-typeof": "off",
100+
},
101+
overrides: [
102+
{
103+
files: ["bundled/privileged/**"],
104+
env: {
105+
es2022: true,
106+
"mozilla/browser-window": true,
107+
"mozilla/privileged": true,
108+
},
109+
globals: {
110+
Cu: "readonly",
111+
Ci: "readonly",
112+
Cc: "readonly",
113+
Cr: "readonly",
114+
ExtensionAPI: "readonly",
115+
Services: "readonly",
116+
OS: "readonly",
117+
},
118+
},
119+
{
120+
files: ["*.ts"],
121+
parser: "@typescript-eslint/parser",
122+
parserOptions: {
123+
project: "tsconfig.json",
124+
sourceType: "module",
125+
},
126+
plugins: ["@typescript-eslint"],
127+
rules: {
128+
"@typescript-eslint/adjacent-overload-signatures": "error",
129+
"@typescript-eslint/array-type": [
130+
"error",
131+
{
132+
default: "array",
133+
},
134+
],
135+
"@typescript-eslint/ban-types": [
136+
"error",
137+
{
138+
types: {
139+
Object: {
140+
message:
141+
"Avoid using the `Object` type. Did you mean `object`?",
142+
},
143+
Function: {
144+
message:
145+
"Avoid using the `Function` type. Prefer a specific function type, like `() => void`.",
146+
},
147+
Boolean: {
148+
message:
149+
"Avoid using the `Boolean` type. Did you mean `boolean`?",
150+
},
151+
Number: {
152+
message:
153+
"Avoid using the `Number` type. Did you mean `number`?",
154+
},
155+
String: {
156+
message:
157+
"Avoid using the `String` type. Did you mean `string`?",
158+
},
159+
Symbol: {
160+
message:
161+
"Avoid using the `Symbol` type. Did you mean `symbol`?",
162+
},
163+
},
164+
},
165+
],
166+
"@typescript-eslint/consistent-type-assertions": "off",
167+
"@typescript-eslint/dot-notation": "error",
168+
"@typescript-eslint/indent": "off",
169+
"@typescript-eslint/member-delimiter-style": [
170+
"off",
171+
{
172+
multiline: {
173+
delimiter: "none",
174+
requireLast: true,
175+
},
176+
singleline: {
177+
delimiter: "semi",
178+
requireLast: false,
179+
},
180+
},
181+
],
182+
"@typescript-eslint/no-empty-function": "warn",
183+
"@typescript-eslint/no-empty-interface": "error",
184+
"@typescript-eslint/no-explicit-any": "off",
185+
"@typescript-eslint/no-misused-new": "error",
186+
"@typescript-eslint/no-namespace": "error",
187+
"@typescript-eslint/no-parameter-properties": "off",
188+
"@typescript-eslint/no-shadow": [
189+
"off",
190+
{
191+
hoist: "all",
192+
},
193+
],
194+
"@typescript-eslint/no-this-alias": "error",
195+
"@typescript-eslint/no-unused-expressions": "warn",
196+
"@typescript-eslint/no-use-before-define": "off",
197+
"@typescript-eslint/no-var-requires": "error",
198+
"@typescript-eslint/prefer-for-of": "warn",
199+
"@typescript-eslint/prefer-function-type": "error",
200+
"@typescript-eslint/prefer-namespace-keyword": "error",
201+
"@typescript-eslint/quotes": "off",
202+
"@typescript-eslint/semi": ["off", null],
203+
"@typescript-eslint/triple-slash-reference": [
204+
"error",
205+
{
206+
path: "always",
207+
types: "prefer-import",
208+
lib: "always",
209+
},
210+
],
211+
"@typescript-eslint/type-annotation-spacing": "off",
212+
"@typescript-eslint/unified-signatures": "error",
213+
"no-undef": "off",
214+
"no-unused-vars": "off",
215+
"@typescript-eslint/no-unused-vars": [
216+
"error",
217+
{ argsIgnorePattern: "^_" },
218+
],
219+
},
220+
},
221+
],
222+
};
File renamed without changes.
File renamed without changes.
File renamed without changes.

Extension/.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bundled/content.js
2+
bundled/feature.js
3+
bundled/privileged/sockets/bufferpack.js
4+
dist
5+
build
6+
node_modules
File renamed without changes.

0 commit comments

Comments
 (0)