Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Linter & Remove Unsafe React Lifecycle Events #553

Closed
wants to merge 15 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

add linting for no-restricted-syntax and fix 1/2 of resulting errors

  • Loading branch information
IAmThePan committed May 1, 2020
commit 3049bd1ca5ecd5fdb3e84678249bac9964196055
@@ -40,7 +40,7 @@ module.exports = {
rules: {
'arrow-parens': [2, 'as-needed', { 'requireForBlockBody': true }],
'camelcase': [0],
'class-methods-use-this': [0],
'class-methods-use-this': [0], // TODO: enable this check
'comma-dangle': [2, {
'arrays': 'only-multiline',
'objects': 'only-multiline',
@@ -54,7 +54,7 @@ module.exports = {
'lines-between-class-members': [1],
'max-len': [0],
'newline-per-chained-call': [0, { 'ignoreChainWithDepth': 2 }],
'no-mixed-operators': [0],
'no-mixed-operators': [0], // TODO: enable this check
'no-nested-ternary': [0],
'no-param-reassign': ['error', {
props: true,
@@ -66,19 +66,18 @@ module.exports = {
}],
'no-plusplus': [0],
'no-prototype-builtins': [0], // TODO: enable this check
'no-restricted-syntax': [0], // TODO: enable this check
'no-restricted-syntax': [1],
'no-tabs': [0],
'no-underscore-dangle': [0],
'no-unused-vars': [1],
'no-useless-escape': [1],
'operator-linebreak': [0],
'prefer-object-spread': ['error'],
'prefer-object-spread': [1],
'space-before-function-paren': [2, 'never'],
'template-curly-spacing': [0],

// Plugin: Import
'import/no-cycle': [0],
'import/prefer-default-export': [0],
'import/prefer-default-export': [0], // TODO: enable this check

// Plugin: React
'react/destructuring-assignment': [0],
@@ -181,7 +181,9 @@ const Click2PlayContentScript = (function(win, doc) {
});

window.addEventListener('load', () => {
for (const app_id in C2P_DATA) {
const app_ids = Object.keys(C2P_DATA);
for (let i = 0; i < app_ids.length; i++) {
const app_id = app_ids[i];
if (C2P_DATA.hasOwnProperty(app_id)) {
if (C2P_DATA[app_id].length >= 3) {
applyC2P(C2P_DATA[app_id][0], C2P_DATA[app_id][1], C2P_DATA[app_id][2]);
@@ -47,17 +47,22 @@ export default class FixedMenu extends React.Component {
getCount = (type) => {
let total = 0;
switch (type) {
case 'enable_anti_tracking':
for (const category in this.antiTrackingData) {
case 'enable_anti_tracking': {
const categories = Object.keys(this.antiTrackingData);
for (let i = 0; i < categories.length; i++) {
const category = categories[i];
if (this.antiTrackingData.hasOwnProperty(category)) {
for (const app in this.antiTrackingData[category]) {
const apps = Object.keys(this.antiTrackingData[category]);
for (let j = 0; j < apps.length; j++) {
const app = apps[j];
if (this.antiTrackingData[category][app] === 'unsafe') {
total++;
}
}
}
}
return total;
}
case 'enable_ad_block':
return this.adBlockData && this.adBlockData.totalCount || 0;
case 'enable_smart_block':
@@ -125,7 +125,9 @@ function setGhosteryDefaultBlocking() {
const categoriesBlock = ['advertising', 'pornvertising', 'site_analytics'];
log('Blocking all trackers in categories:', ...categoriesBlock);
const selected_app_ids = {};
for (const app_id in bugDb.db.apps) {
const app_ids = Object.keys(bugDb.db.apps);
for (let i = 0; i < app_ids.length; i++) {
const app_id = app_ids[i];
if (bugDb.db.apps.hasOwnProperty(app_id)) {
const category = bugDb.db.apps[app_id].cat;
if (categoriesBlock.indexOf(category) >= 0 &&
@@ -574,7 +576,9 @@ function handleGhosteryHub(name, message, callback) {
case 'BLOCKING_POLICY_EVERYTHING': {
panelData.set({ setup_block: 3 });
const selected_app_ids = {};
for (const app_id in bugDb.db.apps) {
const app_ids = Object.keys(bugDb.db.apps);
for (let i = 0; i < app_ids.length; i++) {
const app_id = app_ids[i];
if (!selected_app_ids.hasOwnProperty(app_id)) {
selected_app_ids[app_id] = 1;
}
@@ -126,7 +126,9 @@ class BugDb extends Updatable {
}
}

for (categoryName in categories) {
const categoryNames = Object.keys(categories);
for (let i = 0; i < categoryNames.length; i++) {
categoryName = categoryNames[i];
if (categories.hasOwnProperty(categoryName)) {
const category = categories[categoryName];
if (category.trackers) {
@@ -200,7 +200,9 @@ class FoundBugs {
}

// squish all the bugs into categories first
for (id in bugs) {
const ids = Object.keys(bugs);
for (let i = 0; i < ids.length; i++) {
id = ids[i];
if (bugs.hasOwnProperty(id)) {
aid = db.bugs[id].aid; // eslint-disable-line prefer-destructuring
cid = db.apps[aid].cat;
@@ -239,7 +241,9 @@ class FoundBugs {
}

// convert categories hash to array
for (cid in cats_obj) {
const cids = Object.keys(cats_obj);
for (let i = 0; i < cids.length; i++) {
cid = cids[i];
if (cats_obj.hasOwnProperty(cid)) {
cats_arr.push(cats_obj[cid]);
}
@@ -197,7 +197,9 @@ function _matchesHost(root, src_host, src_path) {
function _matchesRegex(src) {
const regexes = bugDb.db.patterns.regex;

for (const bug_id in regexes) {
const bug_ids = Object.keys(regexes);
for (let i = 0; i < bug_ids.length; i++) {
const bug_id = bug_ids[i];
if (regexes[bug_id].test(src)) {
return +bug_id;
}
@@ -220,7 +222,9 @@ function _matchesPath(src_path) {
// NOTE: we re-add the "/" in order to match patterns that include "/"
const srcPath = `/${src_path}`;

for (const path in paths) {
const pathArr = Object.keys(paths);
for (let i = 0; i < pathArr.length; i++) {
const path = pathArr[i];
if (srcPath.includes(path)) {
return paths[path];
}
ProTip! Use n and p to navigate between commits in a pull request.