2018-02-22 19:25:26 +00:00
|
|
|
{
|
2020-12-15 10:23:54 +00:00
|
|
|
"root": true,
|
2022-03-15 13:17:43 +00:00
|
|
|
"parser": "@typescript-eslint/parser",
|
2018-10-30 10:03:05 +00:00
|
|
|
"extends": [
|
2020-12-15 10:23:54 +00:00
|
|
|
"eslint:recommended",
|
2022-03-15 13:17:43 +00:00
|
|
|
"plugin:@typescript-eslint/recommended",
|
2018-10-30 10:03:05 +00:00
|
|
|
"standard",
|
2021-03-03 12:52:13 +00:00
|
|
|
"prettier"
|
2018-10-30 10:03:05 +00:00
|
|
|
],
|
2018-02-27 11:19:40 +00:00
|
|
|
"env": {
|
2020-12-15 10:23:54 +00:00
|
|
|
"es2020": true
|
|
|
|
},
|
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": {
|
2021-05-05 13:06:07 +00:00
|
|
|
// do not allow importing of implicit dependencies.
|
2022-03-15 13:17:43 +00:00
|
|
|
"import/no-extraneous-dependencies": "error",
|
|
|
|
|
|
|
|
// disable some TypeScript rules
|
|
|
|
"@typescript-eslint/no-var-requires": "off",
|
|
|
|
"@typescript-eslint/no-unused-vars": "off",
|
|
|
|
"@typescript-eslint/no-empty-function": "off",
|
|
|
|
"@typescript-eslint/no-explicit-any": "off",
|
|
|
|
"@typescript-eslint/no-this-alias": "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.
|
2021-10-06 11:24:20 +00: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 14:04:04 +00:00
|
|
|
{
|
2019-10-14 13:17:30 +00:00
|
|
|
// Test specific rules
|
2022-03-15 15:53:25 +00:00
|
|
|
"files": ["**/test/**/*.*"],
|
2021-10-06 11:24:20 +00:00
|
|
|
"plugins": [
|
|
|
|
"mocha",
|
|
|
|
"chai-expect",
|
|
|
|
"chai-friendly"
|
|
|
|
],
|
|
|
|
"env": {
|
|
|
|
"mocha": true
|
2019-10-14 13:17:30 +00:00
|
|
|
},
|
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",
|
|
|
|
|
2021-10-06 11:24:20 +00: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 14:04:04 +00: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 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
|
2021-10-06 11:24:20 +00:00
|
|
|
"files": ["**/app/src/**/*.js", "app.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
|
2021-05-05 13:06:07 +00: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 09:39:26 +00:00
|
|
|
}
|
2019-10-14 13:17:30 +00:00
|
|
|
},
|
2022-03-30 09:49:41 +00:00
|
|
|
{
|
|
|
|
// Cypress specific rules
|
2022-04-06 10:14:43 +00:00
|
|
|
"files": ["cypress/**/*.{js,ts,tsx}", "**/test/frontend/**/*.spec.{js,ts,tsx}"],
|
2022-03-30 09:49:41 +00:00
|
|
|
"extends": [
|
|
|
|
"plugin:cypress/recommended"
|
|
|
|
]
|
|
|
|
},
|
2019-10-14 13:17:30 +00:00
|
|
|
{
|
|
|
|
// Frontend specific rules
|
2022-03-30 09:49:41 +00:00
|
|
|
"files": ["**/frontend/js/**/*.{js,ts,tsx}", "**/frontend/stories/**/*.{js,ts,tsx}", "**/*.stories.{js,ts,tsx}", "**/test/frontend/**/*.{js,ts,tsx}", "**/test/frontend/components/**/*.spec.{js,ts,tsx}"],
|
2021-10-06 11:24:20 +00: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",
|
|
|
|
"prettier"
|
|
|
|
],
|
2019-10-14 13:17:30 +00:00
|
|
|
"globals": {
|
2021-07-12 10:40:29 +00:00
|
|
|
"__webpack_public_path__": true,
|
2019-10-14 13:17:30 +00:00
|
|
|
"$": 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": {
|
2022-02-07 11:46:51 +00:00
|
|
|
// TODO: remove once https://github.com/standard/eslint-config-standard-react/issues/68 (support eslint@8) is fixed.
|
|
|
|
// START: inline standard-react rules
|
|
|
|
// "react/jsx-no-bind": ["error", {
|
|
|
|
// "allowArrowFunctions": true,
|
|
|
|
// "allowBind": false,
|
|
|
|
// "ignoreRefs": true
|
|
|
|
// },],
|
|
|
|
"react/no-did-update-set-state": "error",
|
|
|
|
"react/no-unknown-property": "error",
|
|
|
|
"react/no-unused-prop-types": "error",
|
|
|
|
"react/prop-types": "error",
|
|
|
|
// "react/react-in-jsx-scope": "error",
|
|
|
|
// END: inline standard-react rules
|
|
|
|
|
2021-09-14 10:43:57 +00:00
|
|
|
"react/jsx-no-target-blank": ["error", {
|
|
|
|
"allowReferrer": true
|
|
|
|
}],
|
2020-07-20 13:21:36 +00:00
|
|
|
// 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"
|
|
|
|
}],
|
|
|
|
|
2021-06-23 09:37:08 +00: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",
|
|
|
|
|
2021-12-07 11:30:08 +00:00
|
|
|
// Allow functions as JSX props
|
|
|
|
"react/jsx-no-bind": "off", // TODO: fix occurrences and re-enable this
|
|
|
|
|
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
|
|
|
}
|
2021-05-05 13:06:07 +00:00
|
|
|
},
|
2022-03-15 13:17:43 +00:00
|
|
|
// React + TypeScript-specific rules
|
|
|
|
{
|
|
|
|
"files": ["**/*.tsx"],
|
|
|
|
"rules": {
|
|
|
|
"react/prop-types": "off",
|
|
|
|
"no-undef": "off"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// TypeScript-specific rules
|
|
|
|
{
|
|
|
|
"files": ["**/*.ts"],
|
|
|
|
"rules": {
|
|
|
|
"no-undef": "off"
|
|
|
|
}
|
|
|
|
},
|
2021-05-05 13:06:07 +00: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"]}]
|
|
|
|
}
|
2022-05-16 14:25:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"files": ["scripts/learn/checkSanitize/*.js"],
|
|
|
|
"rules": {
|
|
|
|
// The checkSanitize script is used in the dev-env only.
|
|
|
|
"import/no-extraneous-dependencies": ["error", {
|
|
|
|
"devDependencies": true,
|
|
|
|
"packageDir": [".", "../../"]
|
|
|
|
}]
|
|
|
|
}
|
2019-08-07 14:04:04 +00:00
|
|
|
}
|
|
|
|
]
|
2018-03-02 16:06:48 +00:00
|
|
|
}
|