Skip to content

Commit e03d627

Browse files
silverwindsapk
andauthored
Misc JS linting and naming tweaks (#10652)
- lowercase all js filenames except Vue components - enable new lint rules, mostly focused on shorter code - autofix new lint violations - apply misc transformations indexOf -> includes and onevent-> addEventListener Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
1 parent 984b85c commit e03d627

File tree

11 files changed

+89
-96
lines changed

11 files changed

+89
-96
lines changed

.eslintrc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extends:
55
- eslint:recommended
66

77
ignorePatterns:
8-
- /web_src/js/vendor
8+
- /web_src/js/vendor
99

1010
parserOptions:
1111
ecmaVersion: 2020
@@ -26,19 +26,22 @@ globals:
2626

2727
rules:
2828
arrow-body-style: [0]
29+
arrow-parens: [2, always]
2930
camelcase: [0]
3031
comma-dangle: [2, only-multiline]
3132
consistent-return: [0]
3233
default-case: [0]
3334
func-names: [0]
34-
import/extensions: [0]
35+
import/extensions: [2, always, {ignorePackages: true}]
3536
import/prefer-default-export: [0]
3637
max-len: [0]
38+
multiline-comment-style: [2, separate-lines]
3739
newline-per-chained-call: [0]
3840
no-alert: [0]
3941
no-cond-assign: [2, except-parens]
4042
no-console: [1, {allow: [info, warn, error]}]
4143
no-continue: [0]
44+
no-eq-null: [2]
4245
no-mixed-operators: [0]
4346
no-multi-assign: [0]
4447
no-new: [0]
@@ -49,8 +52,12 @@ rules:
4952
no-unused-vars: [2, {args: all, argsIgnorePattern: ^_, varsIgnorePattern: ^_, ignoreRestSiblings: true}]
5053
no-use-before-define: [0]
5154
no-var: [2]
55+
object-curly-spacing: [2, never]
5256
one-var-declaration-per-line: [0]
5357
one-var: [0]
58+
operator-linebreak: [2, after]
5459
prefer-const: [2, {destructuring: all}]
5560
prefer-destructuring: [0]
61+
quotes: [2, single, {avoidEscape: true, allowTemplateLiterals: true}]
5662
radix: [2, as-needed]
63+
semi: [2, always, {omitLastInOneLineBlock: true}]

web_src/js/features/clipboard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default async function initClipboard() {
22
const els = document.querySelectorAll('.clipboard');
33
if (!els || !els.length) return;
44

5-
const { default: ClipboardJS } = await import(/* webpackChunkName: "clipboard" */'clipboard');
5+
const {default: ClipboardJS} = await import(/* webpackChunkName: "clipboard" */'clipboard');
66

77
const clipboard = new ClipboardJS(els);
88
clipboard.on('success', (e) => {

web_src/js/features/contextPopup.js renamed to web_src/js/features/contextpopup.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { svg } from '../utils.js';
1+
import {svg} from '../utils.js';
22

3-
const { AppSubUrl } = window.config;
3+
const {AppSubUrl} = window.config;
44

55
export default function initContextPopups() {
66
const refIssues = $('.ref-issue');
@@ -14,7 +14,7 @@ export default function initContextPopups() {
1414

1515
function issuePopup(owner, repo, index, $element) {
1616
$.get(`${AppSubUrl}/api/v1/repos/${owner}/${repo}/issues/${index}`, (issue) => {
17-
const createdAt = new Date(issue.created_at).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
17+
const createdAt = new Date(issue.created_at).toLocaleDateString(undefined, {year: 'numeric', month: 'short', day: 'numeric'});
1818

1919
let body = issue.body.replace(/\n+/g, ' ');
2020
if (body.length > 85) {

web_src/js/features/dropzone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default async function createDropzone(el, opts) {
2-
const [{ default: Dropzone }] = await Promise.all([
2+
const [{default: Dropzone}] = await Promise.all([
33
import(/* webpackChunkName: "dropzone" */'dropzone'),
44
import(/* webpackChunkName: "dropzone" */'dropzone/dist/dropzone.css'),
55
]);

web_src/js/features/gitGraph.js renamed to web_src/js/features/gitgraph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default async function initGitGraph() {
22
const graphCanvas = document.getElementById('graph-canvas');
33
if (!graphCanvas) return;
44

5-
const { default: gitGraph } = await import(/* webpackChunkName: "gitgraph" */'../vendor/gitGraph.js');
5+
const {default: gitGraph} = await import(/* webpackChunkName: "gitgraph" */'../vendor/gitgraph.js');
66

77
const graphList = [];
88
$('#graph-raw-list li span.node-relation').each(function () {

web_src/js/features/userHeatmap.js renamed to web_src/js/features/userheatmap.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import Vue from 'vue';
22

3-
const { AppSubUrl, heatmapUser } = window.config;
3+
const {AppSubUrl, heatmapUser} = window.config;
44

55
export default async function initHeatmap() {
66
const el = document.getElementById('user-heatmap');
77
if (!el) return;
88

9-
const { CalendarHeatmap } = await import(/* webpackChunkName: "userheatmap" */'vue-calendar-heatmap');
9+
const {CalendarHeatmap} = await import(/* webpackChunkName: "userheatmap" */'vue-calendar-heatmap');
1010
Vue.component('calendarHeatmap', CalendarHeatmap);
1111

1212
const vueDelimeters = ['${', '}'];
@@ -59,7 +59,7 @@ export default async function initHeatmap() {
5959
const chartData = [];
6060
for (let i = 0; i < chartRawData.length; i++) {
6161
self.totalContributions += chartRawData[i].contributions;
62-
chartData[i] = { date: new Date(chartRawData[i].timestamp * 1000), count: chartRawData[i].contributions };
62+
chartData[i] = {date: new Date(chartRawData[i].timestamp * 1000), count: chartRawData[i].contributions};
6363
}
6464
self.values = chartData;
6565
self.isLoading = false;

0 commit comments

Comments
 (0)