Skip to content

Commit

Permalink
Add eslint-plugin-sonarjs (go-gitea#20431)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
3 people authored and Sysoev, Vladimir committed Aug 10, 2022
1 parent 723d2d7 commit cec61a7
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 4 deletions.
33 changes: 33 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ plugins:
- eslint-plugin-unicorn
- eslint-plugin-import
- eslint-plugin-jquery
- eslint-plugin-sonarjs

env:
es2022: true
Expand Down Expand Up @@ -369,6 +370,38 @@ rules:
semi-spacing: [2, {before: false, after: true}]
semi-style: [2, last]
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-keys: [0]
sort-vars: [0]
Expand Down
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"eslint": "8.20.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jquery": "1.5.1",
"eslint-plugin-sonarjs": "0.13.0",
"eslint-plugin-unicorn": "43.0.2",
"eslint-plugin-vue": "9.2.0",
"jest": "28.1.3",
Expand Down
6 changes: 3 additions & 3 deletions web_src/js/features/stopwatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function updateStopwatchData(data) {
$('.stopwatch-cancel').attr('action', `${issueUrl}/times/stopwatch/cancel`);
$('.stopwatch-issue').text(`${repo_owner_name}/${repo_name}#${issue_index}`);
$('.stopwatch-time').text(prettyMilliseconds(seconds * 1000));
updateStopwatchTime(seconds);
updateTimeInterval = updateStopwatchTime(seconds);
btnEl.removeClass('hidden');
}

Expand All @@ -149,10 +149,10 @@ function updateStopwatchData(data) {

function updateStopwatchTime(seconds) {
const secs = parseInt(seconds);
if (!Number.isFinite(secs)) return;
if (!Number.isFinite(secs)) return null;

const start = Date.now();
updateTimeInterval = setInterval(() => {
return setInterval(() => {
const delta = Date.now() - start;
const dur = prettyMilliseconds(secs * 1000 + delta, {compact: true});
$('.stopwatch-time').text(dur);
Expand Down
2 changes: 1 addition & 1 deletion web_src/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function parseIssueHref(href) {
export function strSubMatch(full, sub) {
const res = [''];
let i = 0, j = 0;
for (; i < sub.length && j < full.length;) {
while (i < sub.length && j < full.length) {
while (j < full.length) {
if (sub[i] === full[j]) {
if (res.length % 2 !== 0) res.push('');
Expand Down

0 comments on commit cec61a7

Please sign in to comment.