Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ node_modules
*.min.js
*.min.css
src/locales/
# Generated and formatted by ESLint's native suppression commands.
eslint-suppressions.json
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,17 @@ Run all code-quality to validate changes:
$ yarn run check
```

This runs the TypeScript typecheck, Prettier check, lint, and tests.
Individual checks can also be run with `yarn typecheck`, `yarn prettify:check`, `yarn lint`, and `yarn test`.
This runs the TypeScript typecheck, Prettier check, lint, application tests, and ESLint tooling tests.
The [EyeSeeTea ESLint policy](eslint/README.md) documents enforced conventions, warning/error levels,
legacy-code rollout, justified exceptions, and practices that still require review.

Individual checks: `yarn typecheck`, `yarn prettify:check`, `yarn lint`,
`yarn test` (application), and `yarn test:eslint` (ESLint tooling).

Lint uses a committed [ESLint baseline](eslint/BASELINE.md): `yarn lint:new` rejects
errors above accepted legacy counts; `yarn lint:all` shows the backlog. Use
`yarn lint:cached` locally and `yarn lint:baseline:prune` after legacy fixes.
Review baseline increases explicitly; never regenerate in CI.

## Some development tips

Expand Down
199 changes: 199 additions & 0 deletions eslint-suppressions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
{
"src/data/__tests__/api-futures.spec.ts": {
"eyeseetea/http-client-access": {
"count": 2
}
},
"src/domain/entities/generic/Collection.ts": {
"@typescript-eslint/no-unsafe-return": {
"count": 3
},
"@typescript-eslint/no-unsafe-type-assertion": {
"count": 9
},
"eyeseetea/no-collection-mutation": {
"count": 9
},
"no-restricted-syntax": {
"count": 3
}
},
"src/domain/entities/generic/Either.ts": {
"@typescript-eslint/no-unsafe-return": {
"count": 2
},
"no-restricted-syntax": {
"count": 2
}
},
"src/domain/entities/generic/Future.ts": {
"@typescript-eslint/no-unsafe-argument": {
"count": 1
},
"@typescript-eslint/no-unsafe-assignment": {
"count": 1
},
"@typescript-eslint/no-unsafe-return": {
"count": 3
},
"@typescript-eslint/no-unsafe-type-assertion": {
"count": 1
},
"eyeseetea/http-client-access": {
"count": 1
},
"eyeseetea/no-collection-mutation": {
"count": 3
},
"no-restricted-syntax": {
"count": 3
}
},
"src/domain/entities/generic/HashMap.ts": {
"@typescript-eslint/no-unsafe-type-assertion": {
"count": 1
},
"no-restricted-syntax": {
"count": 1
}
},
"src/domain/entities/generic/Rec.ts": {
"@typescript-eslint/no-unsafe-type-assertion": {
"count": 6
}
},
"src/domain/entities/generic/Struct.ts": {
"@typescript-eslint/no-unsafe-member-access": {
"count": 1
},
"@typescript-eslint/no-unsafe-return": {
"count": 1
},
"@typescript-eslint/no-unsafe-type-assertion": {
"count": 4
},
"no-restricted-syntax": {
"count": 1
}
},
"src/domain/entities/generic/__tests__/Future.spec.ts": {
"@typescript-eslint/no-unsafe-argument": {
"count": 1
},
"@typescript-eslint/no-unsafe-assignment": {
"count": 1
},
"@typescript-eslint/no-unsafe-type-assertion": {
"count": 1
},
"no-restricted-syntax": {
"count": 1
}
},
"src/domain/usecases/GetUserReportUseCase.ts": {
"eyeseetea/no-collection-mutation": {
"count": 1
}
},
"src/domain/usecases/__tests__/GetCurrentUserUseCase.spec.ts": {
"eyeseetea/layer-dependencies": {
"count": 1
}
},
"src/domain/usecases/__tests__/GetUserReportUseCase.spec.ts": {
"@typescript-eslint/no-unsafe-argument": {
"count": 1
}
},
"src/scripts/UsersReportScript.ts": {
"@typescript-eslint/no-floating-promises": {
"count": 1
},
"eyeseetea/client-construction": {
"count": 1
},
"eyeseetea/http-client-access": {
"count": 1
},
"eyeseetea/layer-dependencies": {
"count": 2
},
"no-restricted-syntax": {
"count": 1
}
},
"src/scripts/dev/UpdatePoScript.ts": {
"eyeseetea/no-collection-mutation": {
"count": 1
}
},
"src/utils/i18n-typed.ts": {
"@typescript-eslint/no-unsafe-assignment": {
"count": 1
},
"@typescript-eslint/no-unsafe-call": {
"count": 2
},
"@typescript-eslint/no-unsafe-member-access": {
"count": 2
},
"@typescript-eslint/no-unsafe-return": {
"count": 1
}
},
"src/utils/ts-utils.ts": {
"@typescript-eslint/no-unsafe-type-assertion": {
"count": 1
}
},
"src/utils/uid.ts": {
"@typescript-eslint/no-unsafe-assignment": {
"count": 1
},
"@typescript-eslint/no-unsafe-call": {
"count": 3
},
"@typescript-eslint/no-unsafe-member-access": {
"count": 2
}
},
"src/webapp/components/users-table/__tests__/UsersTable.spec.tsx": {
"eyeseetea/layer-dependencies": {
"count": 1
},
"testing-library/prefer-explicit-assert": {
"count": 1
}
},
"src/webapp/pages/app/App.tsx": {
"@typescript-eslint/no-floating-promises": {
"count": 1
},
"no-restricted-syntax": {
"count": 1
}
},
"src/webapp/pages/app/Dhis2App.tsx": {
"@typescript-eslint/no-unsafe-assignment": {
"count": 6
},
"@typescript-eslint/no-unsafe-call": {
"count": 1
},
"@typescript-eslint/no-unsafe-member-access": {
"count": 2
},
"@typescript-eslint/no-unsafe-return": {
"count": 1
},
"@typescript-eslint/no-unsafe-type-assertion": {
"count": 2
},
"eyeseetea/client-construction": {
"count": 2
},
"eyeseetea/http-client-access": {
"count": 2
}
}
}
137 changes: 6 additions & 131 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,133 +1,8 @@
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import testingLibrary from "eslint-plugin-testing-library";
import noRelativeImportPaths from "eslint-plugin-no-relative-import-paths";
import unusedImports from "eslint-plugin-unused-imports";
import baseConfig from "./eslint/base-config.mjs";
import reactConfig from "./eslint/react-config.mjs";
import testingConfig from "./eslint/testing-config.mjs";
import baselineConfig from "./eslint/baseline-config.mjs";

import requireFutureBlockCapture from "./eslint/rules/require-future-block-capture.ts";

// ESLint 9 flat config, converted from .eslintrc.json. Same rule set: the file
// is longer because flat config spells out what `extends` and `env` used to imply.
export default tseslint.config(
{
ignores: [
"dist/**",
"build/**",
"node_modules/**",
"coverage/**",
"eslint.config.*",
"src/locales/**",
"src/**/snapshots/*.ts",
"**/*.d.ts",
],
},

js.configs.recommended,
...tseslint.configs.recommended,
react.configs.flat.recommended,
react.configs.flat["jsx-runtime"],
reactHooks.configs.flat.recommended,

{
languageOptions: {
parserOptions: {
ecmaVersion: "latest",
project: "./tsconfig.json",
sourceType: "module",
},
},
settings: {
react: { version: "detect" },
},
plugins: {
local: {
rules: {
"require-future-block-capture": requireFutureBlockCapture,
},
},
"react-hooks": reactHooks,
"no-relative-import-paths": noRelativeImportPaths,
"unused-imports": unusedImports,
},
rules: {
// TypeScript already resolves identifiers; core no-undef duplicates it
// and does not know about DOM or Node globals here.
"no-undef": "off",

"no-console": ["warn", { allow: ["debug", "warn", "error", "info"] }],
"prefer-const": "warn",
"no-debugger": "warn",
"no-unused-expressions": "off",
"no-useless-concat": "off",
"no-useless-constructor": "off",
"no-unexpected-multiline": "off",
"no-use-before-define": "off",
"no-extra-semi": "off",
"no-mixed-spaces-and-tabs": "off",
"no-useless-rename": "off",
"default-case": "off",
"array-callback-return": "off",

"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unnecessary-type-constraint": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-unused-expressions": "warn",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-misused-promises": "warn",
// typescript-eslint v8 moved this from `recommended` to `strict`.
// Kept on so behaviour matches the previous config β€” the codebase
// already carries eslint-disable comments where it uses `!`.
"@typescript-eslint/no-non-null-assertion": "error",

"react/prop-types": "off",
"react/display-name": "off",
"react/react-in-jsx-scope": "off",

"react-hooks/rules-of-hooks": "warn",
"react-hooks/exhaustive-deps": "warn",
// TODO: Enable `react-hooks/set-state-in-effect`.
"react-hooks/set-state-in-effect": "off",

"no-relative-import-paths/no-relative-import-paths": [
"error",
{ allowSameFolder: true, rootDir: "src", prefix: "$" },
],
"local/require-future-block-capture": "error",
},
},

{
files: ["**/*.spec.{ts,tsx}"],
...testingLibrary.configs["flat/react"],
rules: {
...testingLibrary.configs["flat/react"].rules,
"testing-library/await-async-queries": "error",
"testing-library/no-await-sync-queries": "error",
"testing-library/prefer-screen-queries": "off",
"testing-library/no-debugging-utils": "off",
"testing-library/no-dom-import": "off",
},
},

{
files: ["**/*.js"],
languageOptions: { parserOptions: { project: null } },
rules: { "@typescript-eslint/no-misused-promises": "off" },
}
);
// Company policy comes last; errors are ratcheted using native CLI suppressions.
export default tseslint.config(...baseConfig, ...reactConfig, ...testingConfig, ...baselineConfig);
Loading
Loading