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

Add new JS linter rules #17699

Merged
merged 10 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ plugins:
- eslint-plugin-import
- eslint-plugin-vue
- eslint-plugin-html
- eslint-plugin-github

extends:
- plugin:vue/recommended
Expand Down Expand Up @@ -96,6 +97,23 @@ rules:
function-paren-newline: [0]
generator-star-spacing: [0]
getter-return: [2]
github/array-foreach: [2]
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
github/async-currenttarget: [2]
github/async-preventdefault: [2]
github/authenticity-token: [0]
github/get-attribute: [2]
github/js-class-name: [0]
github/no-blur: [0]
github/no-d-none: [0]
github/no-dataset: [2]
github/no-implicit-buggy-globals: [0]
github/no-inner-html: [0]
github/no-innerText: [2]
github/no-then: [2]
github/no-useless-passive: [2]
github/prefer-observers: [0]
github/require-passive-events: [2]
github/unescaped-html-literal: [0]
grouped-accessor-pairs: [2]
guard-for-in: [0]
id-blacklist: [0]
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ lint: lint-frontend lint-backend

.PHONY: lint-frontend
lint-frontend: node_modules
npx eslint --color --max-warnings=0 web_src/js build templates *.config.js
npx eslint --color --max-warnings=0 web_src/js build templates *.config.js docs/assets/js
npx stylelint --color --max-warnings=0 web_src/less
npx editorconfig-checker templates

Expand Down
2 changes: 1 addition & 1 deletion build/generate-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@ async function main() {
]);
}

main().then(exit).catch(exit);
main().then(exit).catch(exit); // eslint-disable-line github/no-then

2 changes: 1 addition & 1 deletion build/generate-svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ async function main() {
]);
}

main().then(exit).catch(exit);
main().then(exit).catch(exit); // eslint-disable-line github/no-then

26 changes: 13 additions & 13 deletions docs/assets/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const fuseOptions = {
shouldSort: true,
includeMatches: true,
matchAllTokens: true,
threshold: 0.0, // for parsing diacritics
threshold: 0, // for parsing diacritics
tokenize: true,
location: 0,
distance: 100,
Expand Down Expand Up @@ -52,25 +52,25 @@ function doSearch() {
executeSearch(searchQuery);
} else {
const para = document.createElement('P');
para.innerText = 'Please enter a word or phrase above';
para.textContent = 'Please enter a word or phrase above';
document.getElementById('search-results').appendChild(para);
}
}

function getJSON(url, fn) {
const request = new XMLHttpRequest();
request.open('GET', url, true);
request.onload = function () {
request.addEventListener('load', () => {
if (request.status >= 200 && request.status < 400) {
const data = JSON.parse(request.responseText);
fn(data);
} else {
console.error(`Target reached on ${url} with error ${request.status}`);
}
};
request.onerror = function () {
});
request.addEventListener('error', () => {
console.error(`Connection error ${request.status}`);
};
});
request.send();
}

Expand All @@ -84,20 +84,20 @@ function executeSearch(searchQuery) {
populateResults(result);
} else {
const para = document.createElement('P');
para.innerText = 'No matches found';
para.textContent = 'No matches found';
document.getElementById('search-results').appendChild(para);
}
});
}

function populateResults(result) {
result.forEach((value, key) => {
for (const [key, value] of result.entries()) {
const content = value.item.contents;
let snippet = '';
const snippetHighlights = [];
if (fuseOptions.tokenize) {
snippetHighlights.push(searchQuery);
value.matches.forEach((mvalue) => {
for (const mvalue of value.matches) {
if (mvalue.key === 'tags' || mvalue.key === 'categories') {
snippetHighlights.push(mvalue.value);
} else if (mvalue.key === 'contents') {
Expand All @@ -111,7 +111,7 @@ function populateResults(result) {
snippetHighlights.push(mvalue.value.substring(mvalue.indices[0][0], mvalue.indices[0][1] - mvalue.indices[0][0] + 1));
}
}
});
}
}

if (snippet.length < 1) {
Expand All @@ -130,10 +130,10 @@ function populateResults(result) {
});
document.getElementById('search-results').appendChild(htmlToElement(output));

snippetHighlights.forEach((snipvalue) => {
for (const snipvalue of snippetHighlights) {
new Mark(document.getElementById(`summary-${key}`)).mark(snipvalue);
});
});
}
}
}

function render(templateString, data) {
Expand Down
Loading