Skip to content

Commit 983a5e8

Browse files
authored
Merge pull request #5540 from ccnmtl/eslint
Upgrade eslint
2 parents 660b68d + 8eab76a commit 983a5e8

File tree

9 files changed

+240
-206
lines changed

9 files changed

+240
-206
lines changed

eslint.config.mjs

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import react from "eslint-plugin-react";
2+
import security from "eslint-plugin-security";
3+
import globals from "globals";
4+
import babelParser from "@babel/eslint-parser";
5+
import path from "node:path";
6+
import { fileURLToPath } from "node:url";
7+
import js from "@eslint/js";
8+
import { FlatCompat } from "@eslint/eslintrc";
9+
10+
const __filename = fileURLToPath(import.meta.url);
11+
const __dirname = path.dirname(__filename);
12+
const compat = new FlatCompat({
13+
baseDirectory: __dirname,
14+
recommendedConfig: js.configs.recommended,
15+
allConfig: js.configs.all
16+
});
17+
18+
export default [...compat.extends(
19+
"eslint:recommended",
20+
"plugin:cypress/recommended",
21+
"plugin:react/recommended",
22+
),
23+
security.configs.recommended,
24+
{
25+
plugins: {
26+
react,
27+
security,
28+
},
29+
30+
languageOptions: {
31+
globals: {
32+
...globals.browser,
33+
...globals.node,
34+
...globals.jquery,
35+
Backbone: true,
36+
_: true,
37+
},
38+
39+
parser: babelParser,
40+
ecmaVersion: 6,
41+
sourceType: "module",
42+
43+
parserOptions: {
44+
ecmaFeatures: {
45+
jsx: true,
46+
},
47+
},
48+
},
49+
50+
settings: {
51+
react: {
52+
version: "detect",
53+
},
54+
},
55+
56+
rules: {
57+
indent: ["error", 4],
58+
"linebreak-style": ["error", "unix"],
59+
60+
"no-unused-vars": ["error", {
61+
vars: "all",
62+
args: "none",
63+
}],
64+
65+
quotes: ["error", "single"],
66+
semi: ["error", "always"],
67+
68+
"max-len": [2, {
69+
code: 80,
70+
tabWidth: 4,
71+
ignoreUrls: true,
72+
}],
73+
74+
"space-before-function-paren": ["error", "never"],
75+
"space-in-parens": ["error", "never"],
76+
"no-trailing-spaces": ["error"],
77+
78+
"key-spacing": ["error", {
79+
beforeColon: false,
80+
}],
81+
82+
"func-call-spacing": ["error", "never"],
83+
"security/detect-buffer-noassert": 1,
84+
"security/detect-child-process": 1,
85+
"security/detect-disable-mustache-escape": 1,
86+
"security/detect-eval-with-expression": 1,
87+
"security/detect-new-buffer": 1,
88+
"security/detect-no-csrf-before-method-override": 1,
89+
"security/detect-non-literal-fs-filename": 1,
90+
"security/detect-non-literal-regexp": 1,
91+
"security/detect-non-literal-require": 0,
92+
"security/detect-object-injection": 0,
93+
"security/detect-possible-timing-attacks": 1,
94+
"security/detect-pseudoRandomBytes": 1,
95+
"security/detect-unsafe-regex": 1,
96+
},
97+
}];

media/js/app/assetmgr/asset.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,6 @@
12691269
} else if (template_label === 'asset-annotation-current') {
12701270
self.$parent.find('#annotation-current').html(rendered);
12711271
} else {
1272-
// eslint-disable-next-line no-console
12731272
console.error('Didn\'t attach template for:', template_label);
12741273
}
12751274

media/js/app/assetmgr/collection.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,14 +501,12 @@ CollectionList.prototype.createAssetThumbs = function(assets) {
501501
asset.y = 0;
502502
asset.zoom = 1;
503503

504-
/* eslint-disable no-empty */
505504
try {
506505
view.html.push(objDiv, {asset: asset});
507506
view.setState(asset);
508507
} catch (e) {
509508
console.error(e);
510509
}
511-
/* eslint-enable no-empty */
512510
}
513511
}
514512
};
@@ -545,7 +543,6 @@ CollectionList.prototype.createThumbs = function(assets) {
545543
if (t.length > 0) {
546544
t[0].appendChild(objDiv);
547545
} else {
548-
// eslint-disable-next-line no-console
549546
console.error('CollectionList error!');
550547
}
551548

media/js/app/assetmgr/collectionwidget.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ var CollectionWidget = function() {
4343
self.vocabulary = vocabularyReq[0].objects;
4444
self.postInitialize();
4545
}).fail(function() {
46-
// eslint-disable-next-line no-console
4746
console.error('Loading error in CollectionWidget constructor');
4847
});
4948
};
@@ -421,7 +420,6 @@ CollectionWidget.prototype.createThumbs = function(assets) {
421420
if (t.length > 0) {
422421
t[0].appendChild(objDiv);
423422
} else {
424-
// eslint-disable-next-line no-console
425423
console.error('CollectionWidget error!');
426424
}
427425

media/js/app/discussion/discussionpanel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ DiscussionPanelHandler.prototype.set_comment_content = function(content) {
147147
if (self.tinymce) {
148148
self.tinymce.setContent(content.comment);
149149
}
150-
} catch (e) {
150+
} catch {
151151
/*
152152
* IE totally SUX: throws some object error here. probably tinymce's
153153
* fault

media/js/app/taxonomy/taxonomy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@
590590
pL = data[skos_uri][
591591
'http:\/\/onomy.org\/onomy-ns#parentLabel']
592592
.value.trim();
593-
} catch (e) {
593+
} catch {
594594
pL = undefined;
595595
}
596596
}
@@ -611,7 +611,7 @@
611611
var re = 'http:\/\/www.w3.org\/2004' +
612612
'\/02\/skos\/core#broader';
613613
parent_uri = data[skos_uri][re].value.trim();
614-
} catch (e) {
614+
} catch {
615615
parent_uri = '';
616616
}
617617

media/js/app/util.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ function switcher(event, a) {
7878
return false;
7979
}
8080

81-
// eslint-disable-next-line no-unused-vars
8281
function updateUserSetting(user, setting, value) {
8382
jQuery.post('/setting/' + user + '/', {name: setting, value: value});
8483
}
@@ -123,7 +122,6 @@ function toggleHelpOverlay(btn, user, helpContentId) {
123122
return false;
124123
}
125124

126-
// eslint-disable-next-line no-unused-vars
127125
function getCookie(name) {
128126
var dc = document.cookie;
129127
var prefix = name + '=';
@@ -143,7 +141,6 @@ function getCookie(name) {
143141
return unescape(dc.substring(begin + prefix.length, end));
144142
}
145143

146-
// eslint-disable-next-line no-unused-vars
147144
function setCookie(name, value, expires, path, domain, secure) {
148145
document.cookie = name + '=' + escape(value) +
149146
((expires) ? '; expires=' + expires.toGMTString() : '') +

0 commit comments

Comments
 (0)