2018-02-22 14:25:26 -05:00
|
|
|
{
|
2020-12-15 05:23:54 -05:00
|
|
|
"root": true,
|
2018-10-30 06:03:05 -04:00
|
|
|
"extends": [
|
2020-12-15 05:23:54 -05:00
|
|
|
"eslint:recommended",
|
|
|
|
"plugin:react/recommended",
|
|
|
|
"plugin:react-hooks/recommended",
|
|
|
|
"plugin:jsx-a11y/recommended",
|
2018-10-30 06:03:05 -04:00
|
|
|
"standard",
|
2019-08-13 08:35:32 -04:00
|
|
|
"standard-jsx",
|
2018-10-30 06:03:05 -04:00
|
|
|
"standard-react",
|
2021-03-03 07:52:13 -05:00
|
|
|
"prettier"
|
2018-10-30 06:03:05 -04:00
|
|
|
],
|
2018-02-28 06:45:30 -05:00
|
|
|
"plugins": [
|
2018-10-30 06:03:05 -04:00
|
|
|
"jsx-a11y",
|
|
|
|
"mocha",
|
2018-02-28 06:45:30 -05:00
|
|
|
"chai-expect",
|
|
|
|
"chai-friendly"
|
|
|
|
],
|
2018-02-27 06:19:40 -05:00
|
|
|
"env": {
|
2019-03-07 10:29:59 -05:00
|
|
|
"browser": true,
|
2020-12-15 05:23:54 -05:00
|
|
|
"mocha": true,
|
|
|
|
"node": true,
|
|
|
|
"es2020": true
|
|
|
|
},
|
|
|
|
"parserOptions": {
|
|
|
|
"sourceType": "module",
|
|
|
|
"ecmaFeatures": {
|
|
|
|
"jsx": true
|
|
|
|
}
|
2018-02-27 06:19:40 -05:00
|
|
|
},
|
2018-10-30 06:03:05 -04:00
|
|
|
"settings": {
|
2019-01-17 04:52:07 -05:00
|
|
|
// Tell eslint-plugin-react to detect which version of React we are using
|
2018-10-30 06:03:05 -04:00
|
|
|
"react": {
|
2019-01-17 04:52:07 -05:00
|
|
|
"version": "detect"
|
2018-10-30 06:03:05 -04:00
|
|
|
}
|
|
|
|
},
|
2018-02-28 06:45:30 -05:00
|
|
|
"rules": {
|
|
|
|
// Swap the no-unused-expressions rule with a more chai-friendly one
|
2020-12-15 05:23:54 -05:00
|
|
|
"no-unused-expressions": "off",
|
2021-01-05 05:56:15 -05:00
|
|
|
"chai-friendly/no-unused-expressions": "error",
|
|
|
|
|
|
|
|
// Disable some rules after upgrading ESLint
|
|
|
|
// TODO: re-enable and fix
|
2020-12-15 05:23:54 -05:00
|
|
|
"no-var": "off",
|
2021-01-05 05:56:15 -05:00
|
|
|
|
2021-05-05 09:06:07 -04:00
|
|
|
// do not allow importing of implicit dependencies.
|
|
|
|
"import/no-extraneous-dependencies": "error",
|
|
|
|
|
2021-01-05 05:56:15 -05:00
|
|
|
"node/no-callback-literal": "off",
|
|
|
|
"node/no-deprecated-api": "off",
|
|
|
|
"node/handle-callback-err": "off",
|
2021-06-23 05:37:08 -04:00
|
|
|
"node/no-path-concat": "off"
|
2019-08-07 10:04:04 -04:00
|
|
|
},
|
|
|
|
"overrides": [
|
2020-07-02 11:51:38 -04:00
|
|
|
// NOTE: changing paths may require updating them in the Makefile too.
|
2019-08-07 10:04:04 -04:00
|
|
|
{
|
2019-10-14 09:17:30 -04:00
|
|
|
// Test specific rules
|
2020-09-25 04:39:24 -04:00
|
|
|
"files": ["**/test/*/src/**/*.js", "**/test/**/*.test.js"],
|
2019-10-14 09:17:30 -04:00
|
|
|
"globals": {
|
|
|
|
"expect": true
|
|
|
|
},
|
2019-08-07 10:04:04 -04: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 05:39:26 -04:00
|
|
|
},
|
|
|
|
{
|
2019-10-14 09:17:30 -04:00
|
|
|
// Frontend test specific rules
|
2020-07-09 09:56:33 -04:00
|
|
|
"files": ["**/test/karma/**/*.js"],
|
2019-10-14 09:17:30 -04:00
|
|
|
"globals": {
|
|
|
|
"expect": true,
|
|
|
|
"$": true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Backend specific rules
|
2019-11-13 09:23:20 -05:00
|
|
|
"files": ["**/app/src/**/*.js"],
|
2019-08-09 05:39:26 -04:00
|
|
|
"rules": {
|
2019-10-14 09:17:30 -04:00
|
|
|
// don't allow console.log in backend code
|
2021-05-05 09:06:07 -04:00
|
|
|
"no-console": "error",
|
|
|
|
|
|
|
|
// do not allow importing of implicit dependencies.
|
|
|
|
"import/no-extraneous-dependencies": ["error", {
|
|
|
|
// do not allow importing of devDependencies.
|
|
|
|
"devDependencies": false
|
|
|
|
}]
|
2019-08-09 05:39:26 -04:00
|
|
|
}
|
2019-10-14 09:17:30 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
// Frontend specific rules
|
2021-06-23 05:37:08 -04:00
|
|
|
"files": ["**/frontend/js/**/*.js", "**/frontend/stories/**/*.js", "**/*.stories.js", "**/test/frontend/**/*.js"],
|
2019-10-14 09:17:30 -04:00
|
|
|
"globals": {
|
|
|
|
"$": true,
|
|
|
|
"angular": true,
|
|
|
|
"ace": true,
|
|
|
|
"ga": true,
|
|
|
|
"sl_console": true,
|
|
|
|
"sl_debugging": true,
|
|
|
|
// Injected in layout.pug
|
2020-05-12 10:23:53 -04:00
|
|
|
"user_id": true,
|
|
|
|
"ExposedSettings": true
|
2020-07-20 09:21:36 -04:00
|
|
|
},
|
|
|
|
"rules": {
|
|
|
|
// Prevent usage of legacy string refs
|
|
|
|
"react/no-string-refs": "error",
|
|
|
|
|
2021-01-05 05:56:15 -05:00
|
|
|
// Prevent curly braces around strings (as they're unnecessary)
|
|
|
|
"react/jsx-curly-brace-presence": ["error", {
|
|
|
|
"props": "never",
|
|
|
|
"children": "never"
|
|
|
|
}],
|
|
|
|
|
2021-06-23 05:37:08 -04:00
|
|
|
// Allow target="_blank" in JSX
|
|
|
|
"react/jsx-no-target-blank": "off",
|
|
|
|
|
|
|
|
// Don't import React for JSX; the JSX runtime is added by a Babel plugin
|
|
|
|
"react/react-in-jsx-scope": "off",
|
|
|
|
"react/jsx-uses-react": "off",
|
|
|
|
|
2020-07-20 09:21:36 -04: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 09:17:30 -04:00
|
|
|
}
|
2021-05-05 09:06:07 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"files": ["scripts/ukamf/*.js"],
|
|
|
|
"rules": {
|
|
|
|
// Do not allow importing of any dependencies unless specified in either
|
|
|
|
// - web/package.json
|
|
|
|
// - web/scripts/ukamf/package.json
|
|
|
|
"import/no-extraneous-dependencies": ["error", {"packageDir": [".", "scripts/ukamf"]}]
|
|
|
|
}
|
2019-08-07 10:04:04 -04:00
|
|
|
}
|
|
|
|
]
|
2018-03-02 11:06:48 -05:00
|
|
|
}
|