Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(805): nx and rspack on existing project structure #847

Merged
merged 19 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from 18 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
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -604,14 +604,14 @@ jobs:
<<: *slack_notify

test_unit_comps:
executor: node-large
executor: node-xlarge
steps:
- checkout
- attach_workspace:
at: ~/project
- run:
name: Unit Testing
command: make unit_test_comps
command: yarn test:unit:comps:ci
environment:
JEST_JUNIT_OUTPUT_DIR: ./reports/junit/
- store_test_results:
Expand All @@ -629,7 +629,7 @@ jobs:
at: ~/project
- run:
name: Unit Testing
command: make unit_test_docs
command: yarn test:unit:docs:ci
environment:
JEST_JUNIT_OUTPUT_DIR: ./reports/junit/
- run:
Expand Down
94 changes: 94 additions & 0 deletions .eslintrc.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx"],
"settings": {
"next": {
"rootDir": "site/"
}
},
"env": {
"jest": true
},
"globals": {
"page": true,
"browser": true,
"context": true,
"cy": true,
"Cypress": true,
"window": true
},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": "off",
"eslint-comments/no-unused-disable": "off"
}
},
{
"files": ["*.tsx"],
"extends": ["plugin:@next/next/recommended"],
"rules": {
"react/prop-types": "off",
"react/forbid-prop-types": "error",
"react-hooks/exhaustive-deps": "warn",
"react/jsx-props-no-spreading": "off",
"react/require-default-props": "off",

"react/jsx-no-useless-fragment": "off",
"react-hooks/rules-of-hooks": "warn",
"react/display-name": "off",
"react/jsx-key": "off"
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript", "plugin:prettier/recommended", "prettier"],
"rules": {
"no-undef": "off",
"no-var": "off",
"no-console": "warn",
"func-names": "warn",

"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-unused-expressions": "warn",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-var-require": "off",
"@typescript-eslint/no-var-requires": "off",

"prettier/prettier": [
"error",
{
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": false,
"arrowParens": "avoid"
}
]
}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"rules": {
"no-undef": "off"
}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.test.js", "*.test.jsx"],
"env": {
"jest": true
},
"rules": {
"no-var": "off"
}
}
]
}
137 changes: 0 additions & 137 deletions .eslintrc.js

This file was deleted.

23 changes: 23 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": [
"plugin:@nrwl/nx/react-typescript",
"plugin:@nrwl/nx/react",
"plugin:storybook/recommended",
"./.eslintrc.base.json"
],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
Comment on lines +11 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these required?

]
}
4 changes: 1 addition & 3 deletions .storybook/addons/tealium/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ const Tool = () => {
});

return (
<>
<NewsKitProvider theme={newskitLightTheme}>
<NewsKitProvider theme={newskitLightTheme}>
<ConsentSettingsLink
privacyManagerId={CONFIG.privacyManagerId}
gdpr
Expand All @@ -87,7 +86,6 @@ const Tool = () => {
</span>
</Tooltip>
</NewsKitProvider>
</>
);
};

Expand Down
1 change: 0 additions & 1 deletion .storybook/manager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import {addons} from '@storybook/addons';
import storybookTheme from './storybook-theme';

Expand Down
1 change: 1 addition & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export const parameters = {
docs: {
// We create a custom Docs page, using of our components for the header
page: () => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const docsContext = React.useContext(DocsContext);
return (
<ThemeProvider theme={newskitLightTheme}>
Expand Down
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ build_docs:
build_docs_with_no_base_url:
SITE_ENV=${SITE_ENV} yarn build:docs && yarn postbuild:docs

unit_test_docs:
yarn test:unit:ci --projects=site

unit_test_comps:
yarn test:unit:ci --projects=src

lint:
yarn lint

Expand Down
4 changes: 1 addition & 3 deletions docs/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ Scripts should be named using the following naming convention:

* `test:unit:run` -> used by other commands to call jest with correct base arguments. Use to generate snapshots for ci-only tests.

* `test:unit:ci` -> runs all the unit tests with CircleCI optimised config.

* `test:unit:comps` -> runs the unit tests on the src folder.

* `test:unit:site` -> runs the unit tests on the site folder.
* `test:unit:docs` -> runs the unit tests on the site folder.

* `test:visual:comps:ci:percy` -> starts the local storybook and runs the percy storybook tests afterwards.

Expand Down
27 changes: 18 additions & 9 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
// These combined settings are now only used by the old-style "yarn test:unit:watch",
// as the nx-based test commands use a separate coverage folder per project
module.exports = {
projects: ['<rootDir>/src/jest.config.js', '<rootDir>/site/jest.config.js'],
coveragePathIgnorePatterns: ['/node_modules/', '<rootDir>/test'],
coverageReporters: ['lcov', 'text-summary'],
collectCoverage: true,
coverageDirectory: './coverage',
coverageThreshold: {
'src/**': {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
coverageDirectory: './coverage/all',
snapshotSerializers: ['@emotion/jest/serializer'],
preset: './jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', {presets: ['@nrwl/react/babel']}],
},
setupFilesAfterEnv: [
'<rootDir>/src/test/test-framework-setup.ts',
'@testing-library/jest-dom/extend-expect',
],
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/src/theme-checker/'],
testEnvironmentOptions: {
url: 'http://localhost/',
},
workerIdleMemoryLimit: 0.4,
};
3 changes: 3 additions & 0 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const nxPreset = require('@nrwl/jest/preset').default;

module.exports = {...nxPreset};
20 changes: 20 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": [
"lint:code:comps",
"lint:code:docs",
"lint:code",
"lint:markdown",
"lint:next",
"test:unit:run",
"test:unit:comps",
"test:unit:docs"
]
}
}
},
"defaultBase": "main"
}
Loading