Skip to content

Commit d3eb196

Browse files
authored
Merge pull request #3938 from ccnmtl/eslint-9
⬆️ eslint 9.27.0
2 parents a264c83 + da65016 commit d3eb196

25 files changed

+565
-292
lines changed

.eslintrc.cjs

Lines changed: 0 additions & 65 deletions
This file was deleted.

eslint.config.mjs

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

media/js/config/env.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-env node */
1+
/* global process */
22

33
'use strict';
44

media/js/config/paths.cjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-env node */
1+
/* global process */
22

33
'use strict';
44

@@ -48,11 +48,11 @@ module.exports = {
4848
dotenv: resolveApp('.env'),
4949
appBuild: resolveApp(JS_PATH + 'build'),
5050
appPublic: resolveApp(JS_PATH + 'public'),
51-
appEditorJs: resolveApp(JS_PATH + 'src/editor-main.js'),
52-
appViewerJs: resolveApp(JS_PATH + 'src/viewer-main.js'),
53-
appStepGraphViewerJs: resolveApp(JS_PATH + 'src/stepGraphViewer-main.js'),
54-
appRubricJs: resolveApp(JS_PATH + 'src/rubric-main.js'),
55-
appGraphPreviewJs: resolveApp(JS_PATH + 'src/graphPreview-main.js'),
51+
appEditorJs: resolveApp(JS_PATH + 'src/editor-main.jsx'),
52+
appViewerJs: resolveApp(JS_PATH + 'src/viewer-main.jsx'),
53+
appStepGraphViewerJs: resolveApp(JS_PATH + 'src/stepGraphViewer-main.jsx'),
54+
appRubricJs: resolveApp(JS_PATH + 'src/rubric-main.jsx'),
55+
appGraphPreviewJs: resolveApp(JS_PATH + 'src/graphPreview-main.jsx'),
5656
appPackageJson: resolveApp('package.json'),
5757
appSrc: resolveApp(JS_PATH + 'src'),
5858
yarnLockFile: resolveApp('yarn.lock'),

media/js/config/webpack.config.dev.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-env node */
1+
/* global process */
22

33
'use strict';
44

media/js/config/webpack.config.prod.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-env node */
1+
/* global process */
22

33
'use strict';
44

File renamed without changes.
File renamed without changes.
File renamed without changes.

media/js/src/JXGBoard.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-env node */
2+
/* global process */
23

34
import React from 'react';
45
import PropTypes from 'prop-types';
File renamed without changes.
File renamed without changes.

media/js/src/editors/TemplateGraphEditor.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default class TemplateGraphEditor extends React.Component {
2222
try {
2323
math.evaluate(expression, { x: 1 });
2424
return true;
25-
} catch (e) {
25+
} catch {
2626
return false;
2727
}
2828
}

media/js/src/graphs/CostFunctionsGraph.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class CostFunctionsGraph extends Graph {
138138
return cost(q, me.options.gA1, me.options.gA2, me.options.gA3);
139139
};
140140

141-
const f2 = function(q) {
141+
const f2 = function() {
142142
return fcost(me.options.gA1);
143143
};
144144

@@ -192,7 +192,7 @@ export class CostFunctionsGraph extends Graph {
192192
return mcost(q, me.options.gA1, me.options.gA2, me.options.gA3);
193193
};
194194

195-
const f2 = function(q) {
195+
const f2 = function() {
196196
return acost(me.options.gA1);
197197
};
198198

media/js/src/graphs/OptimalChoiceConsumption.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ const u1f1 = function(x, px, py, R, alpha, beta) {
112112
return (UStar / (x ** alpha)) ** (1 / beta);
113113
};
114114

115-
const xstarvalue2 = function(px, py, R, alpha, beta) {
115+
const xstarvalue2 = function(px, py, R, alpha) {
116116
return (R * alpha) / px;
117117
};
118118

119-
const ystarvalue2 = function(px, py, R, alpha, beta) {
119+
const ystarvalue2 = function(px, py, R, alpha) {
120120
return -((-R + R * alpha) / py);
121121
};
122122

@@ -276,15 +276,15 @@ const u7f1 = function(x, px, py, R, a, b) {
276276
}
277277
};
278278

279-
const xstarvalue8 = function(px, py, R, a, b) {
279+
const xstarvalue8 = function(px, py, R, a) {
280280
if (0 < (R / px)) {
281281
return (a * py) / px;
282282
}
283283

284284
return 0;
285285
};
286286

287-
const ystarvalue8 = function(px, py, R, a, b) {
287+
const ystarvalue8 = function(px, py, R, a) {
288288
if (R > py) {
289289
return (R / py) - a;
290290
}

media/js/src/graphs/OptimalChoiceCostMinimizing.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ const isocost0 = function(w, r, c, l, alpha, beta) {
128128
};*/
129129

130130
// Function choice: 1
131-
const isocost1 = function(w, r, q, l, alpha, beta) {
131+
const isocost1 = function(w, r, q, l, alpha) {
132132
return (-l*w + q*r*(-alpha*w/(r*(alpha - 1)))**(1 - alpha) +
133133
q*w*(r*(1 - alpha)/(alpha*w))**alpha) / r;
134134
};
@@ -259,7 +259,7 @@ const lStarValue6 = function(q, w, r, a, b) {
259259
return q / b;
260260
};
261261

262-
const kStarValue6 = function(q, w, r, a, b) {
262+
const kStarValue6 = function(q, w, r, a) {
263263
return q / a;
264264
};
265265

media/js/src/graphs/RevenueElasticityGraph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const epsilonP = function(c) {
1313

1414
const r = function(b, c, q) {
1515
return q * fp(b, c, q);};
16-
const rBCEpQ = function(b, c, q) {
16+
const rBCEpQ = function(b, c) {
1717
return c * c * b / 4;};
1818
const rP = function(b, c, p) {
1919
return p * fq(b, c, p);};

media/js/src/graphs/TemplateGraph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const getFunc = function(expression, fallback='fallback', x) {
2626
try {
2727
func = math.evaluate(expression, scope);
2828
window.EconPlayground[fallback] = expression;
29-
} catch (e) {
29+
} catch {
3030
func = math.evaluate(window.EconPlayground[fallback], scope);
3131
}
3232

File renamed without changes.

media/js/src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* globals process, Promise */
1+
/* globals process */
22

33
const BOARD_WIDTH = 540;
44
const BOARD_HEIGHT = 300;
File renamed without changes.

0 commit comments

Comments
 (0)