Skip to content

Commit 19db3f4

Browse files
silverwindlafriks
andauthored
rework eslint config (#11615)
* rework eslint config - use explicit config that only enables rules - upgrade eslint to 7.1.0 - add new plugins with selected rules enabled - fix discovered issues, remove global wipPrefixes * remove if * undo template change * add disabled rules as well for easier config updating * add missing disabled rule * update eslint and plugins * fix new violation * remove deprecated rules Co-authored-by: Lauris BH <[email protected]>
1 parent 363e51d commit 19db3f4

File tree

8 files changed

+725
-163
lines changed

8 files changed

+725
-163
lines changed

.eslintrc

Lines changed: 338 additions & 9 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 361 additions & 124 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@
5353
"worker-loader": "2.0.0"
5454
},
5555
"devDependencies": {
56-
"eslint": "6.8.0",
57-
"eslint-config-airbnb-base": "14.1.0",
58-
"eslint-plugin-import": "2.20.2",
56+
"eslint": "7.2.0",
57+
"eslint-plugin-import": "2.21.1",
58+
"eslint-plugin-sonarjs": "0.5.0",
59+
"eslint-plugin-unicorn": "20.1.0",
5960
"stylelint": "13.3.3",
6061
"stylelint-config-standard": "20.0.0",
6162
"updates": "10.2.11"

templates/repo/issue/new_form.tmpl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<div class="field">
1616
<input name="title" id="issue_title" placeholder="{{.i18n.Tr "repo.milestones.title"}}" value="{{.title}}" tabindex="3" autofocus required maxlength="255">
1717
{{if .PageIsComparePull}}
18-
<div class="title_wip_desc">{{.i18n.Tr "repo.pulls.title_wip_desc" (index .PullRequestWorkInProgressPrefixes 0| Escape) | Safe}}</div>
18+
<div class="title_wip_desc" data-wip-prefixes="{{Json .PullRequestWorkInProgressPrefixes}}">{{.i18n.Tr "repo.pulls.title_wip_desc" (index .PullRequestWorkInProgressPrefixes 0| Escape) | Safe}}</div>
1919
{{end}}
2020
</div>
2121
{{template "repo/issue/comment_tab" .}}
@@ -59,7 +59,7 @@
5959
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" data-id-selector="#label_{{.ID}}"><span class="octicon-check {{if not .IsChecked}}invisible{{end}}">{{svg "octicon-check" 16}}</span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name | RenderEmoji}}
6060
{{if .Description }}<br><small class="desc">{{.Description | RenderEmoji}}</small>{{end}}</a>
6161
{{end}}
62-
62+
6363
<div class="ui divider"></div>
6464
{{range .OrgLabels}}
6565
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" data-id-selector="#label_{{.ID}}"><span class="octicon-check {{if not .IsChecked}}invisible{{end}}">{{svg "octicon-check" 16}}</span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name | RenderEmoji}}
@@ -176,7 +176,4 @@
176176
</div>
177177
</div>
178178
</form>
179-
{{if .PageIsComparePull}}
180-
<script>window.wipPrefixes = {{.PullRequestWorkInProgressPrefixes}}</script>
181-
{{end}}
182179

web_src/js/features/clipboard.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ export default async function initClipboard() {
77
const clipboard = new ClipboardJS(els);
88
clipboard.on('success', (e) => {
99
e.clearSelection();
10-
11-
$(`#${e.trigger.getAttribute('id')}`).popup('destroy');
12-
e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-success'));
13-
$(`#${e.trigger.getAttribute('id')}`).popup('show');
14-
e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original'));
10+
$(e.trigger).popup('destroy');
11+
e.trigger.dataset.content = e.trigger.dataset.success;
12+
$(e.trigger).popup('show');
13+
e.trigger.dataset.content = e.trigger.dataset.original;
1514
});
1615

1716
clipboard.on('error', (e) => {
18-
$(`#${e.trigger.getAttribute('id')}`).popup('destroy');
19-
e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-error'));
20-
$(`#${e.trigger.getAttribute('id')}`).popup('show');
21-
e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original'));
17+
$(e.trigger).popup('destroy');
18+
e.trigger.dataset.content = e.trigger.dataset.error;
19+
$(e.trigger).popup('show');
20+
e.trigger.dataset.content = e.trigger.dataset.original;
2221
});
2322
}

web_src/js/features/codeeditor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const languagesByExt = {};
66
function getEditorconfig(input) {
77
try {
88
return JSON.parse(input.dataset.editorconfig);
9-
} catch (_err) {
9+
} catch {
1010
return null;
1111
}
1212
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {highlightBlock} from 'highlight.js';
22
import {createWindow} from 'domino';
33

4-
self.onmessage = function ({data}) {
4+
self.addEventListener('message', ({data}) => {
55
const window = createWindow();
66
self.document = window.document;
77

88
const {index, html} = data;
99
document.body.innerHTML = html;
1010
highlightBlock(document.body.firstChild);
1111
self.postMessage({index, html: document.body.innerHTML});
12-
};
12+
});

web_src/js/index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* globals wipPrefixes */
21
/* exported timeAddManual, toggleStopwatch, cancelStopwatch */
32
/* exported toggleDeadlineForm, setDeadline, updateDeadline, deleteDependencyModal, cancelCodeComment, onOAuthLoginClick */
43

@@ -2178,8 +2177,9 @@ function initWipTitle() {
21782177
$issueTitle.focus();
21792178
const value = $issueTitle.val().trim().toUpperCase();
21802179

2181-
for (const i in wipPrefixes) {
2182-
if (value.startsWith(wipPrefixes[i].toUpperCase())) {
2180+
const wipPrefixes = $('.title_wip_desc').data('wip-prefixes');
2181+
for (const prefix of wipPrefixes) {
2182+
if (value.startsWith(prefix.toUpperCase())) {
21832183
return;
21842184
}
21852185
}
@@ -2472,10 +2472,9 @@ $(document).ready(async () => {
24722472
'div.repository.settings.collaboration': initRepositoryCollaboration
24732473
};
24742474

2475-
let selector;
2476-
for (selector in routes) {
2475+
for (const [selector, fn] of Object.entries(routes)) {
24772476
if ($(selector).length > 0) {
2478-
routes[selector]();
2477+
fn();
24792478
break;
24802479
}
24812480
}
@@ -2972,13 +2971,13 @@ function initVueComponents() {
29722971
repoClass(repo) {
29732972
if (repo.fork) {
29742973
return 'octicon-repo-forked';
2975-
} if (repo.mirror) {
2974+
} else if (repo.mirror) {
29762975
return 'octicon-repo-clone';
2977-
} if (repo.template) {
2976+
} else if (repo.template) {
29782977
return `octicon-repo-template${repo.private ? '-private' : ''}`;
2979-
} if (repo.private) {
2978+
} else if (repo.private) {
29802979
return 'octicon-lock';
2981-
} if (repo.internal) {
2980+
} else if (repo.internal) {
29822981
return 'octicon-internal-repo';
29832982
}
29842983
return 'octicon-repo';

0 commit comments

Comments
 (0)