Skip to content

Commit

Permalink
Lint and Test Cases (#1296)
Browse files Browse the repository at this point in the history
* Implement tests with jest

* export function findTabStops

* Add Received tests using jest matcher

* add antispam tests

* add datetime tests

* implement GetHeaderList tests

* First pass on errors tests

* move matchers to subdir

* adjust cleanStack for jest

* better file name

* add xml tests

* remove grunt/qunit

* make command line and vs code error tests work at the same time

* Fix filename

* adjust stacks further for website runner

* don't fail on coverage (yet)

* Add linting

* clean up lint

* add some whitespace fixup lint

* remove lint todo

* convert jest config to typescript

* enable esModuleInterop

* enable allowSyntheticDefaultImports

* clean up scripts

* Tidy up webpack.config.js

* remove dead comment

* remove redundant strict checks

* remove more implied by strict

* slight script tweaks

* Enable no-inferrable-types

* remove dead comment

* normalize env testing differences better

* remove any from errors

* remove some any

* Remove any from stacksEqual

* better typing for stacksEqual

* remove another any

* remove more any

* remove more any

* remove more any

* remove some more any

* remove another any

* remove more any

* remove more any

* fix build - remove another any

* remove another any

* remove more any

* one class per file - + a bit of re-org

* get rid of object[]

* remove any

* remove another unknown

* remove another any

* remove another any

* remove more any

* remove more any

* enforce no any

* remove an unknown

* add some more lints

* fix error tests

* add some tests

* reorg tests adjacent to code

* Add more linting rules

* align test filenames better

* more file renames

* lint imports, add lint on save

* fix error test cases

* add antispam test

* Add CreationRow and ReceivedRow tests

* No need for setField to return a value

* add tests to match

* fix file case

* Add ArchivedRow tests

* add OtherRow test

* Get row statement coverage to 100

* get row coverage to 100%

* More received tests

* add more doSort test cases, fix sort on missing fields

* First pass unit tests on table

* enable some missing tests

* add another table test

* proper reset arrows test

* Add visibility tests to table

* Increase coverage thresholds

* isolate ui code more

* Sync with main

* Force case changes
  • Loading branch information
stephenegriffin authored Oct 16, 2024
1 parent 5554aa8 commit 7da79a3
Show file tree
Hide file tree
Showing 79 changed files with 3,063 additions and 11,691 deletions.
45 changes: 40 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention */
module.exports = {
"env": {
"browser": true,
Expand All @@ -8,8 +9,7 @@ module.exports = {
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"overrides": [
],
"overrides": [],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
Expand All @@ -18,16 +18,51 @@ module.exports = {
"plugins": [
"@typescript-eslint",
"@stylistic/js",
"node"
"node",
"import"
],
settings: { "import/resolver": { typescript: { project: "./tsconfig.json" } } },
"rules": {
"indent": ["error", 4, { "SwitchCase": 1, },],
"linebreak-style": ["error", "windows"],
"quotes": ["error", "double"],
"semi": ["error", "always"],
"max-classes-per-file": ["error", 1],
"no-duplicate-imports": "error",
"no-inner-declarations": "error",
"no-unmodified-loop-condition": "error",
"block-scoped-var": "error",
"camelcase": ["error", { "properties": "always" }],
"sort-imports": ["error", { ignoreDeclarationSort: true }],
"@stylistic/js/no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0, "maxBOF": 0 }],
"@stylistic/js/no-trailing-spaces": "error",
"@typescript-eslint/no-explicit-any": "off", // TODO: consider removing this
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-inferrable-types": "error",
}
"@typescript-eslint/naming-convention": [
"error",
{ "selector": "default", "format": ["camelCase"] },
{ "selector": "variableLike", "format": ["camelCase"] },
{ "selector": "typeLike", "format": ["PascalCase"] },
{ "selector": "enumMember", "format": ["PascalCase"] },
{ "selector": "property", "format": ["camelCase"] },
{ "selector": "method", "format": ["camelCase"] }
],
"import/no-unresolved": "error",
"import/no-named-as-default-member": "off",
"import/order": [
"error",
{
groups: [
"builtin", // Built-in imports (come from NodeJS native) go first
"external", // <- External imports
"internal", // <- Absolute imports
["sibling", "parent"], // <- Relative imports, the sibling and parent types they can be mingled together
"index", // <- index imports
"unknown", // <- unknown
],
"newlines-between": "always",
alphabetize: { order: "asc", caseInsensitive: true, },
},
],
},
};
10 changes: 5 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript"
]
"editor.formatOnSave": false,
"eslint.validate": ["javascript", "javascriptreact", "typescript"],
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
}
}
4 changes: 4 additions & 0 deletions global-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Use UTC timezone for all tests
module.exports = async () => {
process.env.TZ = "UTC";
};
9 changes: 5 additions & 4 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {Config} from "jest";
// https://github.com/jest-community/awesome-jest
const config: Config = {
testEnvironment: "jsdom",
globalSetup: "./global-setup.js",
transform: {
"^.+.tsx?$": ["ts-jest",{ diagnostics: { ignoreCodes: ["TS151001"] } }],
},
Expand All @@ -14,10 +15,10 @@ const config: Config = {
coverageReporters: ["json", "lcov", "text", "clover"],
coverageThreshold: {
global: {
branches: 25,
functions: 20,
lines: 25,
statements: 25,
branches: 35,
functions: 45,
lines: 45,
statements: 40,
},
},
reporters: [
Expand Down
Loading

0 comments on commit 7da79a3

Please sign in to comment.