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",
|
2018-10-30 06:03:05 -04:00
|
|
|
"standard",
|
2021-03-03 07:52:13 -05:00
|
|
|
"prettier"
|
2018-10-30 06:03:05 -04:00
|
|
|
],
|
2018-02-27 06:19:40 -05:00
|
|
|
"env": {
|
2020-12-15 05:23:54 -05:00
|
|
|
"es2020": true
|
|
|
|
},
|
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": {
|
2021-01-05 05:56:15 -05:00
|
|
|
// 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.
|
2021-10-20 06:17:59 -04:00
|
|
|
"import/no-extraneous-dependencies": "error"
|
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.
|
2021-10-06 07:24:20 -04:00
|
|
|
{
|
|
|
|
// Node
|
|
|
|
"files": [
|
|
|
|
"**/app/src/**/*.js",
|
|
|
|
"app.js",
|
|
|
|
"i18next-scanner.config.js",
|
|
|
|
"karma.conf.js",
|
|
|
|
"scripts/**/*.js",
|
|
|
|
"webpack.config*.js"
|
|
|
|
],
|
|
|
|
"env": {
|
|
|
|
"node": true
|
|
|
|
}
|
|
|
|
},
|
2019-08-07 10:04:04 -04:00
|
|
|
{
|
2019-10-14 09:17:30 -04:00
|
|
|
// Test specific rules
|
2021-10-06 07:24:20 -04:00
|
|
|
"files": ["**/test/**/*.js"],
|
|
|
|
"plugins": [
|
|
|
|
"mocha",
|
|
|
|
"chai-expect",
|
|
|
|
"chai-friendly"
|
|
|
|
],
|
|
|
|
"env": {
|
|
|
|
"mocha": true
|
2019-10-14 09:17:30 -04:00
|
|
|
},
|
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",
|
|
|
|
|
2021-10-06 07:24:20 -04:00
|
|
|
|
|
|
|
// Swap the no-unused-expressions rule with a more chai-friendly one
|
|
|
|
"no-unused-expressions": "off",
|
|
|
|
"chai-friendly/no-unused-expressions": "error",
|
|
|
|
|
2019-08-07 10:04:04 -04:00
|
|
|
// 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
|
2021-10-06 07:24:20 -04:00
|
|
|
"files": ["**/app/src/**/*.js", "app.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"],
|
2021-10-06 07:24:20 -04:00
|
|
|
"env": {
|
|
|
|
"browser": true
|
|
|
|
},
|
|
|
|
"parserOptions": {
|
|
|
|
"sourceType": "module",
|
|
|
|
"ecmaFeatures": {
|
|
|
|
"jsx": true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"plugins": [
|
|
|
|
"jsx-a11y"
|
|
|
|
],
|
|
|
|
"extends": [
|
|
|
|
"plugin:react/recommended",
|
|
|
|
"plugin:react-hooks/recommended",
|
|
|
|
"plugin:jsx-a11y/recommended",
|
|
|
|
"standard-jsx",
|
|
|
|
"standard-react",
|
|
|
|
"prettier"
|
|
|
|
],
|
2019-10-14 09:17:30 -04:00
|
|
|
"globals": {
|
2021-07-12 06:40:29 -04:00
|
|
|
"__webpack_public_path__": true,
|
2019-10-14 09:17:30 -04:00
|
|
|
"$": 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": {
|
2021-09-14 06:43:57 -04:00
|
|
|
"react/jsx-no-target-blank": ["error", {
|
|
|
|
"allowReferrer": true
|
|
|
|
}],
|
2020-07-20 09:21:36 -04:00
|
|
|
// 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
|
|
|
// 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
|
|
|
}
|