2018-02-22 19:25:26 +00:00
|
|
|
{
|
2020-12-15 10:23:54 +00:00
|
|
|
"root": true,
|
2018-10-30 10:03:05 +00:00
|
|
|
"extends": [
|
2020-12-15 10:23:54 +00:00
|
|
|
"eslint:recommended",
|
|
|
|
"plugin:react/recommended",
|
|
|
|
"plugin:react-hooks/recommended",
|
|
|
|
"plugin:jsx-a11y/recommended",
|
2018-10-30 10:03:05 +00:00
|
|
|
"standard",
|
2019-08-13 12:35:32 +00:00
|
|
|
"standard-jsx",
|
2018-10-30 10:03:05 +00:00
|
|
|
"standard-react",
|
2021-03-03 12:52:13 +00:00
|
|
|
"prettier"
|
2018-10-30 10:03:05 +00:00
|
|
|
],
|
2018-02-28 11:45:30 +00:00
|
|
|
"plugins": [
|
2018-10-30 10:03:05 +00:00
|
|
|
"jsx-a11y",
|
|
|
|
"mocha",
|
2018-02-28 11:45:30 +00:00
|
|
|
"chai-expect",
|
|
|
|
"chai-friendly"
|
|
|
|
],
|
2018-02-27 11:19:40 +00:00
|
|
|
"env": {
|
2019-03-07 15:29:59 +00:00
|
|
|
"browser": true,
|
2020-12-15 10:23:54 +00:00
|
|
|
"mocha": true,
|
|
|
|
"node": true,
|
|
|
|
"es2020": true
|
|
|
|
},
|
|
|
|
"parserOptions": {
|
|
|
|
"sourceType": "module",
|
|
|
|
"ecmaFeatures": {
|
|
|
|
"jsx": true
|
|
|
|
}
|
2018-02-27 11:19:40 +00:00
|
|
|
},
|
2018-10-30 10:03:05 +00:00
|
|
|
"settings": {
|
2019-01-17 09:52:07 +00:00
|
|
|
// Tell eslint-plugin-react to detect which version of React we are using
|
2018-10-30 10:03:05 +00:00
|
|
|
"react": {
|
2019-01-17 09:52:07 +00:00
|
|
|
"version": "detect"
|
2018-10-30 10:03:05 +00:00
|
|
|
}
|
|
|
|
},
|
2018-02-28 11:45:30 +00:00
|
|
|
"rules": {
|
|
|
|
// Swap the no-unused-expressions rule with a more chai-friendly one
|
2020-12-15 10:23:54 +00:00
|
|
|
"no-unused-expressions": "off",
|
2021-01-05 10:56:15 +00:00
|
|
|
"chai-friendly/no-unused-expressions": "error",
|
|
|
|
|
|
|
|
// Disable some rules after upgrading ESLint
|
|
|
|
// TODO: re-enable and fix
|
|
|
|
"no-prototype-builtins": "off",
|
2020-12-15 10:23:54 +00:00
|
|
|
"no-var": "off",
|
|
|
|
"prefer-const": "off",
|
|
|
|
"prefer-regex-literals": "off",
|
2021-01-05 10:56:15 +00:00
|
|
|
"array-callback-return": "off",
|
|
|
|
"no-unreachable-loop": "off",
|
|
|
|
"no-loss-of-precision": "off",
|
|
|
|
|
|
|
|
"node/no-callback-literal": "off",
|
|
|
|
"node/no-deprecated-api": "off",
|
|
|
|
"node/handle-callback-err": "off",
|
|
|
|
"node/no-path-concat": "off",
|
|
|
|
|
2020-12-15 10:23:54 +00:00
|
|
|
"react/display-name": "off",
|
|
|
|
"react/no-unescaped-entities": "off",
|
|
|
|
"react/no-unused-prop-types": "off",
|
|
|
|
"react/jsx-no-target-blank": "off",
|
2021-01-05 10:56:15 +00:00
|
|
|
"react/jsx-handler-names": "off"
|
2019-08-07 14:04:04 +00:00
|
|
|
},
|
|
|
|
"overrides": [
|
2020-07-02 15:51:38 +00:00
|
|
|
// NOTE: changing paths may require updating them in the Makefile too.
|
2019-08-07 14:04:04 +00:00
|
|
|
{
|
2019-10-14 13:17:30 +00:00
|
|
|
// Test specific rules
|
2020-09-25 08:39:24 +00:00
|
|
|
"files": ["**/test/*/src/**/*.js", "**/test/**/*.test.js"],
|
2019-10-14 13:17:30 +00:00
|
|
|
"globals": {
|
|
|
|
"expect": true
|
|
|
|
},
|
2019-08-07 14:04:04 +00:00
|
|
|
"rules": {
|
|
|
|
// mocha-specific rules
|
|
|
|
"mocha/handle-done-callback": "error",
|
|
|
|
"mocha/no-exclusive-tests": "error",
|
|
|
|
"mocha/no-global-tests": "error",
|
|
|
|
"mocha/no-identical-title": "error",
|
|
|
|
"mocha/no-nested-tests": "error",
|
|
|
|
"mocha/no-pending-tests": "error",
|
|
|
|
"mocha/no-skipped-tests": "error",
|
|
|
|
"mocha/no-mocha-arrows": "error",
|
|
|
|
|
|
|
|
// chai-specific rules
|
|
|
|
"chai-expect/missing-assertion": "error",
|
|
|
|
"chai-expect/terminating-properties": "error",
|
|
|
|
|
|
|
|
// prefer-arrow-callback applies to all callbacks, not just ones in mocha tests.
|
|
|
|
// we don't enforce this at the top-level - just in tests to manage `this` scope
|
|
|
|
// based on mocha's context mechanism
|
|
|
|
"mocha/prefer-arrow-callback": "error"
|
|
|
|
}
|
2019-08-09 09:39:26 +00:00
|
|
|
},
|
|
|
|
{
|
2019-10-14 13:17:30 +00:00
|
|
|
// Frontend test specific rules
|
2020-07-09 13:56:33 +00:00
|
|
|
"files": ["**/test/karma/**/*.js"],
|
2019-10-14 13:17:30 +00:00
|
|
|
"globals": {
|
|
|
|
"expect": true,
|
|
|
|
"$": true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Backend specific rules
|
2019-11-13 14:23:20 +00:00
|
|
|
"files": ["**/app/src/**/*.js"],
|
2019-08-09 09:39:26 +00:00
|
|
|
"rules": {
|
2019-10-14 13:17:30 +00:00
|
|
|
// don't allow console.log in backend code
|
2019-08-09 09:39:26 +00:00
|
|
|
"no-console": "error"
|
|
|
|
}
|
2019-10-14 13:17:30 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
// Frontend specific rules
|
2019-11-05 14:00:13 +00:00
|
|
|
"files": ["**/frontend/js/**/*.js"],
|
2019-10-14 13:17:30 +00:00
|
|
|
"globals": {
|
|
|
|
"$": true,
|
|
|
|
"angular": true,
|
|
|
|
"ace": true,
|
|
|
|
"ga": true,
|
|
|
|
"sl_console": true,
|
|
|
|
"sl_debugging": true,
|
|
|
|
// Injected in layout.pug
|
2020-05-12 14:23:53 +00:00
|
|
|
"user_id": true,
|
|
|
|
"ExposedSettings": true
|
2020-07-20 13:21:36 +00:00
|
|
|
},
|
|
|
|
"rules": {
|
|
|
|
// Prevent usage of legacy string refs
|
|
|
|
"react/no-string-refs": "error",
|
|
|
|
|
2021-01-05 10:56:15 +00:00
|
|
|
// Prevent curly braces around strings (as they're unnecessary)
|
|
|
|
"react/jsx-curly-brace-presence": ["error", {
|
|
|
|
"props": "never",
|
|
|
|
"children": "never"
|
|
|
|
}],
|
|
|
|
|
2020-07-20 13:21:36 +00:00
|
|
|
// Fix conflict between prettier & standard by overriding to prefer
|
|
|
|
// double quotes
|
|
|
|
"jsx-quotes": ["error", "prefer-double"],
|
|
|
|
|
|
|
|
// Override weird behaviour of jsx-a11y label-has-for (says labels must be
|
|
|
|
// nested *and* have for/id attributes)
|
|
|
|
"jsx-a11y/label-has-for": [
|
|
|
|
"error",
|
|
|
|
{
|
|
|
|
"required": {
|
|
|
|
"some": [
|
|
|
|
"nesting",
|
|
|
|
"id"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2019-10-14 13:17:30 +00:00
|
|
|
}
|
2019-08-07 14:04:04 +00:00
|
|
|
}
|
|
|
|
]
|
2018-03-02 16:06:48 +00:00
|
|
|
}
|