Skip to content

Commit

Permalink
chore: fix ESLint no-plusplus
Browse files Browse the repository at this point in the history
  • Loading branch information
nschonni committed Dec 27, 2021
1 parent a2c8541 commit 7bb9331
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 30 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
doc/api
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"no-shadow": "off",
"consistent-return": "warn",
"no-param-reassign": "off",
"no-plusplus": "off",
"strict": "off",
"global-require": "off",
"no-restricted-syntax": "warn",
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
6 changes: 3 additions & 3 deletions lib/exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function findSet(shortname) {
set.push(records[k]);
}
}
count++;
count += 1;
if (typeof set === 'string') return _findSet(set);
return set;
}
Expand All @@ -31,8 +31,8 @@ const Exceptions = function () {};
Exceptions.prototype.has = function (shortname, rule, key, extra) {
const set = findSet(shortname);
if (set === undefined) return false;
for (let i = set.length - 1; i >= 0; i--) {
for (let y = set[i].length - 1; y >= 0; y--) {
for (let i = set.length - 1; i >= 0; i -= 1) {
for (let y = set[i].length - 1; y >= 0; y -= 1) {
const exception = set[i][y];
if (
rule === exception.rule &&
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ exports.message = function (profileCode, rule, key, extra) {
rules[profile].sections[rule.section].rules[rule.rule];
let template =
rules['*'].sections[rule.section].rules[rule.rule];
for (let p = 0; p < values.length; p++)
for (let p = 0; p < values.length; p += 1)
template = template.replace(
new RegExp(`@{param${p + 1}}`, 'g'),
values[p]
Expand Down
5 changes: 3 additions & 2 deletions lib/rules/headers/h2-toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ exports.check = function (sr, done) {
else sr.error(self, 'not-found');
if (toc && toc.length > 0) {
let matches = 0;
for (let i = 0; i < toc.length; i++)
if (EXPECTED_HEADING.test(sr.norm(toc[i].textContent))) matches++;
for (let i = 0; i < toc.length; i += 1)
if (EXPECTED_HEADING.test(sr.norm(toc[i].textContent)))
matches += 1;
if (matches > 1) sr.error(self, 'too-many');
else if (matches === 0) sr.error(self, 'not-found');
}
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/links/compound.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ exports.check = function (sr, done) {
link: l,
errMsg: err,
});
count++;
count += 1;
});
req.timeout(TIMEOUT);
req.end((err1, res) => {
Expand Down Expand Up @@ -71,7 +71,7 @@ exports.check = function (sr, done) {
};
sr.error(self, 'link', details);
}
count++;
count += 1;
if (count === links.length) return done();
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/structure/section-ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exports.check = function (sr, done) {
if (h.querySelectorAll('a[name]').length) return true;

// has a[name] as previous element sibling
for (let i = 1, n = sibs.length; i < n; i++) {
for (let i = 1, n = sibs.length; i < n; i += 1) {
if (sibs[i] === h && sibs[i - 1].matches('a[name]')) return true;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/style/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports.check = function (sr, done) {

candidates.forEach(ele => {
if (PATTERN_SCRIPT.test(ele.getAttribute('src'))) {
found++;
found += 1;
}
});

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/validation/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ exports.check = function (sr, done) {
if (!json) return sr.throw('No JSON input.');

if (json.messages && json.messages.length) {
for (let i = 0, n = json.messages.length; i < n; i++) {
for (let i = 0, n = json.messages.length; i < n; i += 1) {
const msg = json.messages[i];
// {
// "type": "error",
Expand Down
14 changes: 7 additions & 7 deletions lib/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Specberus.prototype.extractMetadata = function (options) {
self.meta[i] = result[i];
}
}
done++;
done += 1;
self.sink.emit('done', this.name);
if (done === total)
self.sink.emit(
Expand Down Expand Up @@ -167,7 +167,7 @@ Specberus.prototype.validate = function (options) {
rule.check(
self,
function () {
done++;
done += 1;
self.sink.emit('done', this.name);
if (done === total)
self.sink.emit(
Expand Down Expand Up @@ -464,7 +464,7 @@ Specberus.prototype.getFeedbackDueDate = function () {
);
const candidates = txt.match(rex);
if (candidates !== null) {
for (let i = 0; i < candidates.length; i++) {
for (let i = 0; i < candidates.length; i += 1) {
const d = this.stringToDate(candidates[i]);
if (d >= lowBound) dates.list.push(d);
if (d >= lowBound && d < highBound) dates.valid.push(d);
Expand Down Expand Up @@ -502,7 +502,7 @@ Specberus.prototype.getDelivererGroups = async function () {
ids = this.getDataDelivererIDs() || [];
// For rec-track
if (ids.length === 0 && sotdLinks && sotdLinks.length > 0) {
for (let i = 0; i < sotdLinks.length; i++) {
for (let i = 0; i < sotdLinks.length; i += 1) {
const item = sotdLinks[i];
const href = item.getAttribute('href');
const text = this.norm(item.textContent);
Expand Down Expand Up @@ -535,7 +535,7 @@ Specberus.prototype.getDelivererGroups = async function () {
}

// send request to W3C API if there's id extracted from the doc.
for (let i = 0; i < ids.length; i++) {
for (let i = 0; i < ids.length; i += 1) {
const groupApiUrl = `https://api.w3.org/groups/${ids[i]}`;
const apikey = this.apiKey;
promiseArray.push(
Expand All @@ -551,7 +551,7 @@ Specberus.prototype.getDelivererGroups = async function () {
}

await Promise.all(promiseArray).then(res => {
for (let i = 0; i < res.length; i++) {
for (let i = 0; i < res.length; i += 1) {
const data = res[i];
if (data && data.body) {
let { type } = data.body;
Expand Down Expand Up @@ -597,7 +597,7 @@ Specberus.prototype.getDelivererIDs = async function () {
const promiseArray = [];

if (ids.length === 0 && sotdLinks && sotdLinks.length > 0) {
for (let i = 0; i < sotdLinks.length; i++) {
for (let i = 0; i < sotdLinks.length; i += 1) {
const item = sotdLinks[i];
const href = item.getAttribute('href');
const text = this.norm(item.textContent);
Expand Down
2 changes: 1 addition & 1 deletion lib/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const formatRules = function (sections, common) {
// Array (common rule with parameters)
const values = sections[s].rules[r];
let template = common.sections[s].rules[r];
for (let p = 0; p < values.length; p++)
for (let p = 0; p < values.length; p += 1)
template = template.replace(
new RegExp(`@{param${p + 1}}`, 'g'),
values[p]
Expand Down
2 changes: 1 addition & 1 deletion public/js/scroll-tweak.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $(document).ready(() => {
};

$(window).scroll(() => {
scrolled++;
scrolled += 1;
});

$('a[href^="#"]').click(e => {
Expand Down
2 changes: 1 addition & 1 deletion public/js/specberus.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ jQuery.extend({
addMessage(MSG_INFO, data);
});
socket.on('done', () => {
done++;
done += 1;
$progress.attr({
'aria-valuenow': done,
'aria-valuemax': total,
Expand Down
2 changes: 1 addition & 1 deletion test/l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const scanFileSystem = function () {
result[dir][name][match[1]] = true;
match = exceptionFinder.exec(data);
}
n++;
n += 1;
if (total === n) fulfill(result);
}
};
Expand Down
12 changes: 6 additions & 6 deletions test/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ const sink = require('../lib/sink');
const equivalentArray = function (a1, a2) {
if (a1 && a2 && a1.length === a2.length) {
let found = 0;
for (let i = 0; i < a1.length; i++) {
for (let j = 0; j < a2.length && found === i; j++) {
for (let i = 0; i < a1.length; i += 1) {
for (let j = 0; j < a2.length && found === i; j += 1) {
if (a1[i] === a2[j]) {
found++;
found += 1;
}
}
}
Expand Down Expand Up @@ -1281,7 +1281,7 @@ describe('Making sure Specberus is not broken...', () => {
});
handler.on('done', () => {
if (DEBUG) console.log('---done---');
handler.done++;
handler.done += 1;
});
handler.on('exception', data => {
console.error(
Expand All @@ -1301,7 +1301,7 @@ describe('Making sure Specberus is not broken...', () => {
for (
i = 0, n = test.errors.length;
i < n;
i++
i += 1
) {
expect(handler.errors).to.contain(
test.errors[i]
Expand All @@ -1316,7 +1316,7 @@ describe('Making sure Specberus is not broken...', () => {
for (
i = 0, n = test.warnings.length;
i < n;
i++
i += 1
) {
expect(
handler.warnings
Expand Down
2 changes: 1 addition & 1 deletion tools/make-groups-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const pth = require('path');
const src = require('./groups-sparql.json');

const res = {};
for (let i = 0, n = src.results.bindings.length; i < n; i++) {
for (let i = 0, n = src.results.bindings.length; i < n; i += 1) {
const group = src.results.bindings[i];
const key = group.mailbox.value.replace('mailto:', '');
res[key] = {
Expand Down

0 comments on commit 7bb9331

Please sign in to comment.