Add eslint-plugin-sonarjs (#20431)
We had this plugin before but it was removed as it became outdated, now it was updated again, so it's compatible again. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
3df33799c1
commit
bc17cba835
5 changed files with 58 additions and 4 deletions
|
@ -12,6 +12,7 @@ plugins:
|
||||||
- eslint-plugin-unicorn
|
- eslint-plugin-unicorn
|
||||||
- eslint-plugin-import
|
- eslint-plugin-import
|
||||||
- eslint-plugin-jquery
|
- eslint-plugin-jquery
|
||||||
|
- eslint-plugin-sonarjs
|
||||||
|
|
||||||
env:
|
env:
|
||||||
es2022: true
|
es2022: true
|
||||||
|
@ -369,6 +370,38 @@ rules:
|
||||||
semi-spacing: [2, {before: false, after: true}]
|
semi-spacing: [2, {before: false, after: true}]
|
||||||
semi-style: [2, last]
|
semi-style: [2, last]
|
||||||
semi: [2, always, {omitLastInOneLineBlock: true}]
|
semi: [2, always, {omitLastInOneLineBlock: true}]
|
||||||
|
sonarjs/cognitive-complexity: [0]
|
||||||
|
sonarjs/elseif-without-else: [0]
|
||||||
|
sonarjs/max-switch-cases: [0]
|
||||||
|
sonarjs/no-all-duplicated-branches: [2]
|
||||||
|
sonarjs/no-collapsible-if: [0]
|
||||||
|
sonarjs/no-collection-size-mischeck: [2]
|
||||||
|
sonarjs/no-duplicate-string: [0]
|
||||||
|
sonarjs/no-duplicated-branches: [0]
|
||||||
|
sonarjs/no-element-overwrite: [2]
|
||||||
|
sonarjs/no-empty-collection: [2]
|
||||||
|
sonarjs/no-extra-arguments: [0]
|
||||||
|
sonarjs/no-gratuitous-expressions: [2]
|
||||||
|
sonarjs/no-identical-conditions: [2]
|
||||||
|
sonarjs/no-identical-expressions: [0]
|
||||||
|
sonarjs/no-identical-functions: [0]
|
||||||
|
sonarjs/no-ignored-return: [2]
|
||||||
|
sonarjs/no-inverted-boolean-check: [2]
|
||||||
|
sonarjs/no-nested-switch: [0]
|
||||||
|
sonarjs/no-nested-template-literals: [0]
|
||||||
|
sonarjs/no-one-iteration-loop: [2]
|
||||||
|
sonarjs/no-redundant-boolean: [2]
|
||||||
|
sonarjs/no-redundant-jump: [0]
|
||||||
|
sonarjs/no-same-line-conditional: [2]
|
||||||
|
sonarjs/no-small-switch: [0]
|
||||||
|
sonarjs/no-unused-collection: [2]
|
||||||
|
sonarjs/no-use-of-empty-return-value: [2]
|
||||||
|
sonarjs/no-useless-catch: [0]
|
||||||
|
sonarjs/non-existent-operator: [2]
|
||||||
|
sonarjs/prefer-immediate-return: [0]
|
||||||
|
sonarjs/prefer-object-literal: [0]
|
||||||
|
sonarjs/prefer-single-boolean-return: [0]
|
||||||
|
sonarjs/prefer-while: [2]
|
||||||
sort-imports: [0]
|
sort-imports: [0]
|
||||||
sort-keys: [0]
|
sort-keys: [0]
|
||||||
sort-vars: [0]
|
sort-vars: [0]
|
||||||
|
|
20
package-lock.json
generated
20
package-lock.json
generated
|
@ -50,6 +50,7 @@
|
||||||
"eslint": "8.20.0",
|
"eslint": "8.20.0",
|
||||||
"eslint-plugin-import": "2.26.0",
|
"eslint-plugin-import": "2.26.0",
|
||||||
"eslint-plugin-jquery": "1.5.1",
|
"eslint-plugin-jquery": "1.5.1",
|
||||||
|
"eslint-plugin-sonarjs": "0.13.0",
|
||||||
"eslint-plugin-unicorn": "43.0.2",
|
"eslint-plugin-unicorn": "43.0.2",
|
||||||
"eslint-plugin-vue": "9.2.0",
|
"eslint-plugin-vue": "9.2.0",
|
||||||
"jest": "28.1.3",
|
"jest": "28.1.3",
|
||||||
|
@ -5492,6 +5493,18 @@
|
||||||
"eslint": ">=5.4.0"
|
"eslint": ">=5.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/eslint-plugin-sonarjs": {
|
||||||
|
"version": "0.13.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.13.0.tgz",
|
||||||
|
"integrity": "sha512-t3m7ta0EspzDxSOZh3cEOJIJVZgN/TlJYaBGnQlK6W/PZNbWep8q4RQskkJkA7/zwNpX0BaoEOSUUrqaADVoqA==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"eslint": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/eslint-plugin-unicorn": {
|
"node_modules/eslint-plugin-unicorn": {
|
||||||
"version": "43.0.2",
|
"version": "43.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-43.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-43.0.2.tgz",
|
||||||
|
@ -16787,6 +16800,13 @@
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {}
|
"requires": {}
|
||||||
},
|
},
|
||||||
|
"eslint-plugin-sonarjs": {
|
||||||
|
"version": "0.13.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.13.0.tgz",
|
||||||
|
"integrity": "sha512-t3m7ta0EspzDxSOZh3cEOJIJVZgN/TlJYaBGnQlK6W/PZNbWep8q4RQskkJkA7/zwNpX0BaoEOSUUrqaADVoqA==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {}
|
||||||
|
},
|
||||||
"eslint-plugin-unicorn": {
|
"eslint-plugin-unicorn": {
|
||||||
"version": "43.0.2",
|
"version": "43.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-43.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-43.0.2.tgz",
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
"eslint": "8.20.0",
|
"eslint": "8.20.0",
|
||||||
"eslint-plugin-import": "2.26.0",
|
"eslint-plugin-import": "2.26.0",
|
||||||
"eslint-plugin-jquery": "1.5.1",
|
"eslint-plugin-jquery": "1.5.1",
|
||||||
|
"eslint-plugin-sonarjs": "0.13.0",
|
||||||
"eslint-plugin-unicorn": "43.0.2",
|
"eslint-plugin-unicorn": "43.0.2",
|
||||||
"eslint-plugin-vue": "9.2.0",
|
"eslint-plugin-vue": "9.2.0",
|
||||||
"jest": "28.1.3",
|
"jest": "28.1.3",
|
||||||
|
|
|
@ -140,7 +140,7 @@ function updateStopwatchData(data) {
|
||||||
$('.stopwatch-cancel').attr('action', `${issueUrl}/times/stopwatch/cancel`);
|
$('.stopwatch-cancel').attr('action', `${issueUrl}/times/stopwatch/cancel`);
|
||||||
$('.stopwatch-issue').text(`${repo_owner_name}/${repo_name}#${issue_index}`);
|
$('.stopwatch-issue').text(`${repo_owner_name}/${repo_name}#${issue_index}`);
|
||||||
$('.stopwatch-time').text(prettyMilliseconds(seconds * 1000));
|
$('.stopwatch-time').text(prettyMilliseconds(seconds * 1000));
|
||||||
updateStopwatchTime(seconds);
|
updateTimeInterval = updateStopwatchTime(seconds);
|
||||||
btnEl.removeClass('hidden');
|
btnEl.removeClass('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,10 +149,10 @@ function updateStopwatchData(data) {
|
||||||
|
|
||||||
function updateStopwatchTime(seconds) {
|
function updateStopwatchTime(seconds) {
|
||||||
const secs = parseInt(seconds);
|
const secs = parseInt(seconds);
|
||||||
if (!Number.isFinite(secs)) return;
|
if (!Number.isFinite(secs)) return null;
|
||||||
|
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
updateTimeInterval = setInterval(() => {
|
return setInterval(() => {
|
||||||
const delta = Date.now() - start;
|
const delta = Date.now() - start;
|
||||||
const dur = prettyMilliseconds(secs * 1000 + delta, {compact: true});
|
const dur = prettyMilliseconds(secs * 1000 + delta, {compact: true});
|
||||||
$('.stopwatch-time').text(dur);
|
$('.stopwatch-time').text(dur);
|
||||||
|
|
|
@ -64,7 +64,7 @@ export function parseIssueHref(href) {
|
||||||
export function strSubMatch(full, sub) {
|
export function strSubMatch(full, sub) {
|
||||||
const res = [''];
|
const res = [''];
|
||||||
let i = 0, j = 0;
|
let i = 0, j = 0;
|
||||||
for (; i < sub.length && j < full.length;) {
|
while (i < sub.length && j < full.length) {
|
||||||
while (j < full.length) {
|
while (j < full.length) {
|
||||||
if (sub[i] === full[j]) {
|
if (sub[i] === full[j]) {
|
||||||
if (res.length % 2 !== 0) res.push('');
|
if (res.length % 2 !== 0) res.push('');
|
||||||
|
|
Loading…
Reference in a new issue