[CP-2311] NX configuration fixes (#1618)

This commit is contained in:
Michał Kurczewski
2023-12-27 11:00:15 +01:00
committed by GitHub
parent 959e6db3f1
commit 807c72d4db
10 changed files with 2293 additions and 556 deletions

View File

@@ -1 +1,4 @@
.eslintrc.js
jest
jest.config.ts
jest.preset.js

View File

@@ -1,14 +1,20 @@
{
"env": {
"browser": true
/**
* Copyright (c) Mudita sp. z o.o. All rights reserved.
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
module.exports = {
env: {
browser: true,
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"sourceType": "module"
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
sourceType: "module",
tsconfigRootDir: __dirname,
},
"root": true,
"plugins": [
root: true,
plugins: [
"@typescript-eslint",
"react",
"react-hooks",
@@ -17,9 +23,9 @@
"jest",
"jest-dom",
"jsx-a11y",
"testing-library"
"testing-library",
],
"extends": [
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
@@ -29,9 +35,9 @@
"plugin:jest-dom/recommended",
"plugin:testing-library/react",
"plugin:react/recommended",
"plugin:react-hooks/recommended"
"plugin:react-hooks/recommended",
],
"rules": {
rules: {
"@typescript-eslint/await-thenable": "warn",
"@typescript-eslint/restrict-template-expressions": "warn",
"@typescript-eslint/restrict-plus-operands": "warn",
@@ -61,18 +67,21 @@
"react/jsx-boolean-value": "off",
"react/no-unescaped-entities": "warn",
"react-hooks/rules-of-hooks": "warn",
"curly": "off",
curly: "off",
"no-async-promise-executor": "warn",
"no-prototype-builtins": "warn",
"license-header/header": ["error", "resources/license-header.js"],
"license-header/header": [
"error",
__dirname + "/resources/license-header.js",
],
"no-unused-vars": "off",
"unused-imports/no-unused-vars": [
"off",
{
"argsIgnorePattern": "^_"
}
argsIgnorePattern: "^_",
},
],
"unused-imports/no-unused-imports": "error",
@@ -109,15 +118,16 @@
"testing-library/no-container": "off",
"testing-library/await-async-queries": "off",
"testing-library/no-await-sync-events": "off",
"testing-library/no-render-in-lifecycle": "off"
"testing-library/no-render-in-lifecycle": "off",
"react/react-in-jsx-scope": "off",
},
"settings": {
"react": {
"version": "detect"
settings: {
react: {
version: "detect",
},
"jest": {
"version": "detect"
}
},
"ignorePatterns": ["auth-server.test.ts", "./jest"]
jest: {
version: "detect",
},
},
ignorePatterns: ["auth-server.test.ts", "./jest"],
}

10
jest.config.ts Normal file
View File

@@ -0,0 +1,10 @@
/**
* Copyright (c) Mudita sp. z o.o. All rights reserved.
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
import { getJestProjects } from "@nx/jest"
export default {
projects: getJestProjects(),
}

8
jest.preset.js Normal file
View File

@@ -0,0 +1,8 @@
/**
* Copyright (c) Mudita sp. z o.o. All rights reserved.
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
const nxPreset = require("@nx/jest/preset").default
module.exports = { ...nxPreset }

View File

@@ -15,7 +15,13 @@ module.exports = {
},
rootDir: "../",
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
testPathIgnorePatterns: ["node_modules", ".cache", "public", "cypress"],
testPathIgnorePatterns: [
"node_modules",
".cache",
"public",
"cypress",
"libs/(?!core)",
],
globals: {
__PATH_PREFIX__: "",
},
@@ -57,5 +63,5 @@ module.exports = {
snapshotFormat: {
escapeString: true,
printBasicPrototype: true,
}
},
}

25
nx.json
View File

@@ -14,5 +14,30 @@
},
"affected": {
"defaultBase": "master"
},
"generators": {
"@nx/react": {
"application": {
"babel": true
},
"library": {
"unitTestRunner": "jest"
}
}
},
"targetDefaults": {
"@nx/jest:jest": {
"cache": true,
"inputs": ["default", "^default", "{workspaceRoot}/jest.preset.js"],
"options": {
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
}
}

2550
package-lock.json generated
View File

File diff suppressed because it is too large Load Diff

View File

@@ -15,11 +15,15 @@
"app:develop": "nx develop mudita-center",
"app:dist": "nx dist mudita-center",
"app:translations:sync": "nx translations:sync mudita-center",
"test": "cross-env TZ=UTC jest --config=jest/jest.config.js",
"test": "npm run test:nx && npm run test:core",
"test:core": "cross-env TZ=UTC jest --config=jest/jest.config.js",
"test:nx": "nx run-many --target=test",
"lint": "npm run lint:js && npm run lint:css",
"lint:fix": "npm run lint:js -- --fix",
"lint:css": "cross-env stylelint '{libs,apps/mudita-center/src}/**/*.{ts,tsx}'",
"lint:js": "cross-env eslint '{libs,apps/mudita-center/src}/**/*.{ts,tsx}' --max-warnings=0",
"lint:fix": "npm run lint:js -- --fix",
"lint:js": "npm run lint:js:nx && npm run lint:js:core",
"lint:js:core": "cross-env eslint '{libs/core,apps/mudita-center/src}/**/*.{ts,tsx}' --max-warnings=0",
"lint:js:nx": "nx run-many --target=lint --max-warnings=0",
"lint:typecheck": "tsc --noEmit",
"app:storybook:serve": "nx storybook:serve mudita-center",
"app:storybook:build": "nx storybook:build mudita-center",
@@ -56,6 +60,10 @@
"@electron/remote": "^2.0.11",
"@faker-js/faker": "^7.5.0",
"@mudita/stylelint-config": "^1.0.4",
"@nx/eslint": "^17.2.6",
"@nx/jest": "17.2.6",
"@nx/js": "17.2.6",
"@nx/react": "^17.2.6",
"@reduxjs/toolkit": "1.9.7",
"@rematch/core": "^1.4.0",
"@rematch/select": "^2.0.5",
@@ -69,6 +77,8 @@
"@storybook/react": "^7.5.2",
"@storybook/react-webpack5": "^7.5.2",
"@storybook/testing-library": "^0.2.2",
"@swc-node/register": "~1.6.7",
"@swc/core": "~1.3.85",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.5.1",
@@ -82,12 +92,13 @@
"@types/lodash": "^4.14.182",
"@types/mime-types": "2.1.2",
"@types/mock-fs": "^4.13.1",
"@types/node": "^18.7.18",
"@types/node": "18.16.9",
"@types/node-fetch": "^3.0.3",
"@types/quoted-printable": "^1.0.0",
"@types/react": "^18.2.33",
"@types/react-beautiful-dnd": "^13.1.2",
"@types/react-dom": "^18.2.14",
"@types/react-is": "18.2.2",
"@types/react-modal": "^3.13.1",
"@types/react-redux": "7.1.28",
"@types/react-router": "^5.1.18",
@@ -120,6 +131,7 @@
"async-mutex": "^0.4.0",
"axios": "^0.27.2",
"axios-mock-adapter": "^1.21.2",
"babel-jest": "^29.4.1",
"babel-loader": "^8.2.5",
"babel-plugin-react-intl": "^7.8.3",
"babel-plugin-styled-components": "^2.0.7",
@@ -144,12 +156,13 @@
"electron-updater": "4.3.9",
"eslint": "^8.0.1",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jest": "^27.4.3",
"eslint-plugin-jest-dom": "^5.1.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-license-header": "^0.6.0",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-react": "7.32.2",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-testing-library": "^6.0.2",
"eslint-plugin-unused-imports": "^3.0.0",
"file-loader": "^6.2.0",
@@ -210,7 +223,7 @@
"sql.js": "^1.7.0",
"storybook": "^7.5.2",
"style-loader": "^3.3.1",
"styled-components": "^5.3.5",
"styled-components": "5.3.6",
"styled-normalize": "^8.0.7",
"stylelint": "^13.13.1",
"stylelint-config-styled-components": "^0.1.1",
@@ -244,6 +257,8 @@
"npm": "9.5.1"
},
"dependencies": {
"serialport": "10.1.0"
"react-is": "18.2.0",
"serialport": "10.1.0",
"tslib": "^2.3.0"
}
}

39
tsconfig.base.json Normal file
View File

@@ -0,0 +1,39 @@
{
"compileOnSave": false,
"compilerOptions": {
"sourceMap": true,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"module": "commonjs",
"lib": [
"dom",
"es6",
"dom.iterable",
"scripthost",
"es5",
"es7",
"es2017",
"ESNext",
"esnext.intl",
"es2017.intl",
"es2018.intl"
],
"skipLibCheck": true,
"baseUrl": "./",
"paths": {
"App/*": ["./apps/mudita-center/src/*"],
"Core/*": ["./libs/core/*"],
"E2E/*": ["./apps/mudita-center-e2e/src/*"],
"Libs/*": ["./libs/*"],
"Root/*": ["./*"],
}
},
"exclude": [
"node_modules",
"./apps/mudita-center/node_modules",
"./apps/mudita-center/dist",
"./apps/mudita-center/__mocks__"
]
}

View File

@@ -1,119 +1,20 @@
{
"compilerOptions": {
/***** Basic Options ******/
/* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"target": "es5",
/* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"module": "commonjs",
/* Specify library files to be included in the compilation: */
"lib": [
"dom",
"es6",
"dom.iterable",
"scripthost",
"es5",
"es7",
"es2017",
"ESNext",
"esnext.intl",
"es2017.intl",
"es2018.intl"
],
/* Allow javascript files to be compiled. */
"allowJs": true,
/* Report errors in .js files. */
// "checkJs": true,
/* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"jsx": "react",
/* Generates corresponding '.d.ts' file. */
// "declaration": true,
/* Generates corresponding '.map' file. */
"sourceMap": true,
/* Concatenate and emit output to single file. */
// "outFile": "./",
/* Redirect output structure to the directory. */
/*"outDir": "./dist",*/
/* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "rootDir": "./",
/* Do not emit comments to output. */
// "removeComments": true,
/* Do not emit outputs. */
// "noEmit": true,
/* Import emit helpers from 'tslib'. */
// "importHelpers": true,
/* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
"jsx": "react-jsx",
"downlevelIteration": true,
/* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
// "isolatedModules": true,
/***** Strict Type-Checking Options ******/
/* Enable all strict type-checking options. */
"strict": true,
/* Raise error on expressions and declarations with an implied 'any' type. */
"noImplicitAny": true,
/* Enable strict null checks. */
"strictNullChecks": true,
/* Enable strict checking of function types. */
// "strictFunctionTypes": true,
/* Raise error on 'this' expressions with an implied 'any' type. */
"noImplicitThis": true,
/* Parse in strict mode and emit "use strict" for each source file. */
"alwaysStrict": true,
/***** Additional Checks *****/
/* Report errors on unused locals. */
"noUnusedLocals": false,
/* Report errors on unused parameters. */
"noUnusedParameters": false,
/* Report error when not all code paths in function return a value. */
"noImplicitReturns": true,
/* Report errors for fallthrough cases in switch statement. */
// "noFallthroughCasesInSwitch": true,
/***** Module Resolution Options *****/
/* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"moduleResolution": "node",
/* Base directory to resolve non-absolute module names. */
"baseUrl": "./",
/* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
/* List of root folders whose combined content represents the structure of the project at runtime. */
// "rootDirs": [],
/* List of folders to include type definitions from. */
// "typeRoots": [],
/* Type declaration files to be included in compilation. */
"types": ["jest", "node", "@testing-library/jest-dom", "webpack-env"],
/* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
// "allowSyntheticDefaultImports": true,
/* Do not resolve the real path of symlinks. */
// "preserveSymlinks": true,
/***** Source Map Options *****/
/* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "sourceRoot": "./",
/* Specify the location where debugger should locate map files instead of generated locations. */
// "mapRoot": "./",
/* Emit a single file with source maps instead of having a separate file. */
// "inlineSourceMap": true,
/* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
// "inlineSources": true,
/***** Experimental Options *****/
/* Enables experimental support for ES7 decorators. */
"experimentalDecorators": true,
/* Enables experimental support for emitting type metadata for decorators. */
"emitDecoratorMetadata": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"paths": {
"Root/*": ["./*"],
"App/*": ["./apps/mudita-center/src/*"],
"E2E/*": ["./apps/mudita-center-e2e/src/*"],
"Libs/*": ["./libs/*"],
"Core/*": ["./libs/core/*"]
}
"esModuleInterop": true
},
"include": ["./apps/mudita-center/src", "./libs/core"],
"exclude": ["node_modules", "./apps/mudita-center/node_modules", "./apps/mudita-center/dist", "./apps/mudita-center/__mocks__"],
"include": ["./apps/mudita-center/src", "./libs"],
"extends": "./tsconfig.base.json"
}