From ba76cab20baa27371217317912da9d63ef6e7898 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Sun, 3 Mar 2019 15:22:09 -0500 Subject: [PATCH] Fix some lint errors --- scripts/check.js | 4 +-- test/js/matchingTest.js | 64 ++++++++++++++++++------------------ test/js/serializationTest.js | 12 +++---- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/scripts/check.js b/scripts/check.js index 2c768a1..50e00c6 100644 --- a/scripts/check.js +++ b/scripts/check.js @@ -49,10 +49,10 @@ let p = Promise.reject(new Error('Usage: node check.js --location --h const ruleDiscovery = commander.discover && !commander.dat const parseOptions = { - keepRuleText: !!ruleDiscovery, + keepRuleText: !!ruleDiscovery } -if (commander.host && (commander.location || commander.list) || commander.stats) { +if ((commander.host && (commander.location || commander.list)) || commander.stats) { p.catch(() => {}) if (commander.uuid) { p = makeAdBlockClientFromListUUID(commander.uuid, parseOptions) diff --git a/test/js/matchingTest.js b/test/js/matchingTest.js index c25b63c..1ff6c14 100644 --- a/test/js/matchingTest.js +++ b/test/js/matchingTest.js @@ -207,7 +207,7 @@ describe('matching', function () { }) }) - describe("Filters with unknown options are ignored", function () { + describe('Filters with unknown options are ignored', function () { it('known unsupported options are not blocked', function () { const client = new AdBlockClient() client.parse('adv$ping') @@ -317,7 +317,7 @@ describe('matching', function () { }) }) describe('domain filtered rules', function () { - describe('All exclude domain rules', function() { + describe('All exclude domain rules', function () { before(function () { this.client = new AdBlockClient() this.client.parse('wp-content/$domain=~aaaaa.com|~bbbbb.com|~ccccc.com') @@ -325,137 +325,137 @@ describe('matching', function () { it('filter has all anti domains but with different input domain should block', function () { assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'www.brianbondy.com')) + FilterOptions.image, 'www.brianbondy.com')) }) it('filter has all anti domains and with a same input domain should not block', function () { assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'aaaaa.com')) + FilterOptions.image, 'aaaaa.com')) }) }) - describe('All include domain rules', function() { + describe('All include domain rules', function () { before(function () { this.client = new AdBlockClient() this.client.parse('wp-content/$domain=aaaaa.com|bbbbb.com|ccccc.com') }) it('filter has all anti=false domains but with different input domain should not block', function () { assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'www.brianbondy.com')) + FilterOptions.image, 'www.brianbondy.com')) }) it('filter has all anti=false domains and with a same domain should not block', function () { assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'aaaaa.com')) + FilterOptions.image, 'aaaaa.com')) }) }) - describe('Rule with blocking parent domain and subdomain which is allowed', function() { + describe('Rule with blocking parent domain and subdomain which is allowed', function () { before(function () { this.client = new AdBlockClient() this.client.parse('wp-content/$domain=example.com|~foo.example.com|x.com|y.com|z.com') }) it('for test URL of unrelated domain should not match', function () { assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'brianbondy.com')) + FilterOptions.image, 'brianbondy.com')) }) it('for test URL of parent should block', function () { assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'example.com')) + FilterOptions.image, 'example.com')) }) it('for test URL of subdomain should allow', function () { assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'foo.example.com')) + FilterOptions.image, 'foo.example.com')) }) it('for test URL of deeper subdomain should allow', function () { assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'boo.foo.example.com')) + FilterOptions.image, 'boo.foo.example.com')) }) it('for test URL of subdomain of top level rule should block', function () { assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'boo.example.com')) + FilterOptions.image, 'boo.example.com')) }) }) - describe('Rule with anti-block parent domain and subdomain which is blocked', function() { + describe('Rule with anti-block parent domain and subdomain which is blocked', function () { before(function () { this.client = new AdBlockClient() this.client.parse('wp-content/$domain=~example.com|foo.example.com|x.com|z.com|y.com') }) it('for test URL of unrelated domain should not match', function () { assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'brianbondy.com')) + FilterOptions.image, 'brianbondy.com')) }) it('for test URL of parent should not block', function () { assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'example.com')) + FilterOptions.image, 'example.com')) }) it('for test URL of subdomain should block', function () { assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'foo.example.com')) + FilterOptions.image, 'foo.example.com')) }) it('for test URL of deeper subdomain should block', function () { assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'boo.foo.example.com')) + FilterOptions.image, 'boo.foo.example.com')) }) it('for test URL of subdomain of top level rule should allow', function () { assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'boo.example.com')) + FilterOptions.image, 'boo.example.com')) }) }) - describe('Three level deep rules', function() { + describe('Three level deep rules', function () { before(function () { this.client = new AdBlockClient() this.client.parse('wp-content/$domain=example.com|~brave.example.com|foo.brave.example.com') }) it('for test URL of unrelated domain should not match', function () { assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'brianbondy.com')) + FilterOptions.image, 'brianbondy.com')) }) it('for test URL of parent should block', function () { assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'example.com')) + FilterOptions.image, 'example.com')) }) it('for test URL of exception subdomain should allow', function () { assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'brave.example.com')) + FilterOptions.image, 'brave.example.com')) }) it('for test URL of deeper subdomain should block', function () { assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'foo.brave.example.com')) + FilterOptions.image, 'foo.brave.example.com')) }) }) - describe('Three level deep rules reversed', function() { + describe('Three level deep rules reversed', function () { before(function () { this.client = new AdBlockClient() this.client.parse('wp-content/$domain=~example.com|brave.example.com|~foo.brave.example.com') }) it('for test URL of unrelated domain should not match since there is a blocking domain', function () { assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'brianbondy.com')) + FilterOptions.image, 'brianbondy.com')) }) it('for test URL of parent should allow', function () { assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'example.com')) + FilterOptions.image, 'example.com')) }) it('for test URL of exception subdomain should block', function () { assert(this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'brave.example.com')) + FilterOptions.image, 'brave.example.com')) }) it('for test URL of deeper subdomain should allow', function () { assert(!this.client.matches('https://www.sportsnet.ca/wp-content/plugins', - FilterOptions.image, 'foo.brave.example.com')) + FilterOptions.image, 'foo.brave.example.com')) }) }) - describe('first-party host', function() { + describe('first-party host', function () { before(function () { this.client = new AdBlockClient() this.client.parse('analytics.brave.com^\n@@https://analytics.*/piwik.$~third-party') }) it('for same host finds exception', function () { assert(!this.client.matches('https://analytics.brave.com/piwik.js', - FilterOptions.image, 'analytics.brave.com')) + FilterOptions.image, 'analytics.brave.com')) }) it('for same diff host does not find exception', function () { assert(this.client.matches('https://analytics.brave.com/piwik.js', - FilterOptions.image, 'batcommunity.org')) + FilterOptions.image, 'batcommunity.org')) }) it('findMatchingFilters for same host finds exception', function () { const queryResult = this.client.findMatchingFilters('https://analytics.brave.com/piwik.js', FilterOptions.script, 'analytics.brave.com') diff --git a/test/js/serializationTest.js b/test/js/serializationTest.js index 96744cc..b8355f1 100644 --- a/test/js/serializationTest.js +++ b/test/js/serializationTest.js @@ -54,14 +54,14 @@ describe('serialization', function () { assert(!this.data.toString().includes('Adblock Plus')) }) - describe("deserializing input", function () { + describe('deserializing input', function () { it('does not throw on valid input', function () { const client = new AdBlockClient() client.deserialize(this.data) }) it('throws on invalid input', function () { - const badInput = "not-good-data" + const badInput = 'not-good-data' let caughtError = false const newClient = new AdBlockClient() // Check to make sure the below doesn't throw @@ -73,14 +73,14 @@ describe('serialization', function () { assert(caughtError) }) }) - describe("tags", function () { + describe('tags', function () { it('preserves filter tags', function () { const client = new AdBlockClient() - client.parse("testfilter$third-party,tag=blah"); + client.parse('testfilter$third-party,tag=blah') const filters1 = client.getFilters('filters') console.log('filters1', filters1) assert.equal(filters1.length, 1) - assert.equal(filters1[0].tag, "blah") + assert.equal(filters1[0].tag, 'blah') const data = client.serialize() const client2 = new AdBlockClient() @@ -88,7 +88,7 @@ describe('serialization', function () { const filters2 = client2.getFilters('filters') console.log('filters2', filters2) assert.equal(filters2.length, 1) - assert.equal(filters2[0].tag, "blah") + assert.equal(filters2[0].tag, 'blah') }) }) })