Skip to content

Commit

Permalink
upgrade eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
ndittren committed Jul 18, 2024
1 parent 5f84d86 commit 10e4340
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 8 deletions.
99 changes: 99 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import security from 'eslint-plugin-security';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [
...compat.extends('eslint:recommended'),
security.configs.recommended,
{
plugins: {
security,
},

languageOptions: {
globals: {
...globals.browser,
...globals.jquery,
$$: true,
forEach: true,
map: true,
setStyle: true,
MochiKit: true,
queryString: true,
serializeJSON: true,
hideElement: true,
getElementsByTagAndClassName: true,
showElement: true,
logDebug: true,
addElementClass: true,
removeElementClass: true,
filter: true,
loadJSONDoc: true,
list: true,
range: true,
itemgetter: true,
findValue: true,
setDisplayForElement: true,
DIV: true,
swapDOM: true,
zip: true,
getNodeAttribute: true,
log: true,
getElement: true,
},
},

rules: {
indent: ['error', 4],
'linebreak-style': ['error', 'unix'],

'no-unused-vars': ['error', {
vars: 'all',
args: 'none',
}],

quotes: ['error', 'single'],
semi: ['error', 'always'],

'max-len': [2, {
code: 80,
tabWidth: 4,
ignoreUrls: true,
}],

'space-before-function-paren': ['error', 'never'],
'space-in-parens': ['error', 'never'],
'no-trailing-spaces': ['error'],

'key-spacing': ['error', {
beforeColon: false,
}],

'func-call-spacing': ['error', 'never'],
'security/detect-buffer-noassert': 1,
'security/detect-child-process': 1,
'security/detect-disable-mustache-escape': 1,
'security/detect-eval-with-expression': 1,
'security/detect-new-buffer': 1,
'security/detect-no-csrf-before-method-override': 1,
'security/detect-non-literal-fs-filename': 1,
'security/detect-non-literal-regexp': 1,
'security/detect-non-literal-require': 0,
'security/detect-object-injection': 0,
'security/detect-possible-timing-attacks': 1,
'security/detect-pseudoRandomBytes': 1,
'security/detect-unsafe-regex': 1,
},
},
];
1 change: 1 addition & 0 deletions media/taking_action/js/nav.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-vars */
/* global partial: true, connect: true, hasElementClass: true */
/* exported steps, game_state, nav_ready, observation_1, observation_2 */
/* exported observation_css_classes, criteria_css_classes */
Expand Down
3 changes: 3 additions & 0 deletions media/taking_action/js/taking_action.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ function loadState() {
maybeEnableNext();
}

// eslint-disable-next-line no-unused-vars
function like_checkbox(selected_class, all_button_class, the_element) {
map(function(a) {
removeElementClass(a, selected_class);
}, $$('.' + all_button_class));
addElementClass($(the_element), selected_class);
}

// eslint-disable-next-line no-unused-vars
function show_answer() {
maybeEnableNext();
}
Expand All @@ -95,6 +97,7 @@ function new_ldss_form_fields_to_save() {
return results;
}

// eslint-disable-next-line no-unused-vars
function deprecated_ldss_form_fields_to_save() {
var results = {};
var filled_out_fields = filter(function(a) {
Expand Down
37 changes: 30 additions & 7 deletions package-lock.json

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

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"url": "https://github.com/ccnmtl/carr/issues"
},
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.7.0",
"eslint": "~9.7.0",
"eslint-plugin-security": "^3.0.0"
"eslint-plugin-security": "^3.0.0",
"globals": "^15.8.0"
}
}

0 comments on commit 10e4340

Please sign in to comment.