Skip to content

Commit 241da1f

Browse files
committed
Initialize project with essential configurations and structure
- Added .editorconfig for consistent coding styles. - Created .eslintrc.js for TypeScript and React linting rules. - Included .gitignore to exclude unnecessary files from version control. - Set up .prettierignore and .prettierrc for code formatting preferences. - Established jest.config.js for testing configurations. - Added LICENSE file with MIT license. - Created package.json and package-lock.json for project dependencies. - Added README.md with project overview and setup instructions. - Implemented initial Webpack configuration files (common, dev, prod). - Created TypeScript configuration (tsconfig.json) for type checking. - Added initial application structure with React components and routing. - Included utility hooks and mock files for testing. - Set up GitHub Actions CI workflow for linting, testing, and building.
0 parents  commit 241da1f

29 files changed

+23413
-0
lines changed

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.snap]
12+
max_line_length = off
13+
trim_trailing_whitespace = false
14+
15+
[*.md]
16+
max_line_length = off
17+
trim_trailing_whitespace = false

.eslintrc.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
module.exports = {
2+
// tells eslint to use the TypeScript parser
3+
"parser": "@typescript-eslint/parser",
4+
// tell the TypeScript parser that we want to use JSX syntax
5+
"parserOptions": {
6+
"tsx": true,
7+
"jsx": true,
8+
"js": true,
9+
"useJSXTextNode": true,
10+
"project": "./tsconfig.json",
11+
"tsconfigRootDir": "."
12+
},
13+
// we want to use the recommended rules provided from the typescript plugin
14+
"extends": [
15+
"eslint:recommended",
16+
"plugin:react/recommended",
17+
"plugin:@typescript-eslint/recommended"
18+
],
19+
"globals": {
20+
"window": "readonly",
21+
"describe": "readonly",
22+
"test": "readonly",
23+
"expect": "readonly",
24+
"it": "readonly",
25+
"process": "readonly",
26+
"document": "readonly",
27+
"insights": "readonly",
28+
"shallow": "readonly",
29+
"render": "readonly",
30+
"mount": "readonly"
31+
},
32+
"overrides": [
33+
{
34+
"files": ["src/**/*.ts", "src/**/*.tsx"],
35+
"parser": "@typescript-eslint/parser",
36+
"plugins": ["@typescript-eslint"],
37+
"extends": ["plugin:@typescript-eslint/recommended"],
38+
"rules": {
39+
"react/prop-types": "off",
40+
"@typescript-eslint/no-unused-vars": "error"
41+
},
42+
},
43+
],
44+
"settings": {
45+
"react": {
46+
"version": "^16.11.0"
47+
}
48+
},
49+
// includes the typescript specific rules found here: https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#supported-rules
50+
"plugins": [
51+
"@typescript-eslint",
52+
"react-hooks",
53+
"eslint-plugin-react-hooks"
54+
],
55+
"rules": {
56+
"sort-imports": [
57+
"error",
58+
{
59+
"ignoreDeclarationSort": true
60+
}
61+
],
62+
"@typescript-eslint/explicit-function-return-type": "off",
63+
"react-hooks/rules-of-hooks": "error",
64+
"react-hooks/exhaustive-deps": "warn",
65+
"@typescript-eslint/interface-name-prefix": "off",
66+
"prettier/prettier": "off",
67+
"import/no-unresolved": "off",
68+
"import/extensions": "off",
69+
"react/prop-types": "off"
70+
},
71+
"env": {
72+
"browser": true,
73+
"node": true
74+
}
75+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve the react seed
4+
title: ''
5+
labels: needs triage
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior
15+
16+
**Expected behavior**
17+
A clear and concise description of what you expected to happen.
18+
19+
**Screenshots**
20+
If applicable, add screenshots to help explain your problem.
21+
22+
**Additional context**
23+
Add any other context about the problem here.

.github/workflows/ci.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
- release*
8+
9+
jobs:
10+
lint:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: lts/*
20+
- name: Install dependencies
21+
run: npm install
22+
- name: Run eslint
23+
run: npm run lint
24+
test:
25+
name: Test
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v3
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v3
32+
with:
33+
node-version: lts/*
34+
- name: Install dependencies
35+
run: npm install
36+
- name: Run tests
37+
run: npm run test
38+
build:
39+
name: Build
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v3
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v3
46+
with:
47+
node-version: lts/*
48+
- name: Install dependencies
49+
run: npm install
50+
- name: Attempt a build
51+
run: npm run build

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
**/node_modules
2+
dist
3+
yarn-error.log
4+
yarn.lock
5+
stats.json
6+
coverage
7+
storybook-static
8+
.DS_Store
9+
.idea
10+
.env
11+
.history

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package.json

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"printWidth": 120
4+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Red Hat
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Patternfly Seed
2+
3+
Patternfly Seed is an open source build scaffolding utility for web apps. The primary purpose of this project is to give developers a jump start when creating new projects that will use patternfly. A secondary purpose of this project is to serve as a reference for how to configure various aspects of an application that uses patternfly, webpack, react, typescript, etc.
4+
5+
Out of the box you'll get an app layout with chrome (header/sidebar), routing, build pipeline, test suite, and some code quality tools. Basically, all the essentials.
6+
7+
<img width="1058" alt="Out of box dashboard view of patternfly seed" src="https://github.com/user-attachments/assets/0227b366-67f1-4df8-8d92-e8e95d6e08b3" />
8+
9+
## Quick-start
10+
11+
```bash
12+
git clone https://github.com/patternfly/patternfly-react-seed
13+
cd patternfly-react-seed
14+
npm install && npm run start:dev
15+
```
16+
## Development scripts
17+
```sh
18+
# Install development/build dependencies
19+
npm install
20+
21+
# Start the development server
22+
npm run start:dev
23+
24+
# Run a production build (outputs to "dist" dir)
25+
npm run build
26+
27+
# Run the test suite
28+
npm run test
29+
30+
# Run the test suite with coverage
31+
npm run test:coverage
32+
33+
# Run the linter
34+
npm run lint
35+
36+
# Run the code formatter
37+
npm run format
38+
39+
# Launch a tool to inspect the bundle size
40+
npm run bundle-profile:analyze
41+
42+
# Start the express server (run a production build first)
43+
npm run start
44+
```
45+
46+
## Configurations
47+
* [TypeScript Config](./tsconfig.json)
48+
* [Webpack Config](./webpack.common.js)
49+
* [Jest Config](./jest.config.js)
50+
* [Editor Config](./.editorconfig)
51+
52+
## Raster image support
53+
54+
To use an image asset that's shipped with PatternFly core, you'll prefix the paths with "@assets". `@assets` is an alias for the PatternFly assets directory in node_modules.
55+
56+
For example:
57+
```js
58+
import imgSrc from '@assets/images/g_sizing.png';
59+
<img src={imgSrc} alt="Some image" />
60+
```
61+
62+
You can use a similar technique to import assets from your local app, just prefix the paths with "@app". `@app` is an alias for the main src/app directory.
63+
64+
```js
65+
import loader from '@app/assets/images/loader.gif';
66+
<img src={loader} alt="Content loading" />
67+
```
68+
69+
## Vector image support
70+
Inlining SVG in the app's markup is also possible.
71+
72+
```js
73+
import logo from '@app/assets/images/logo.svg';
74+
<span dangerouslySetInnerHTML={{__html: logo}} />
75+
```
76+
77+
You can also use SVG when applying background images with CSS. To do this, your SVG's must live under a `bgimages` directory (this directory name is configurable in [webpack.common.js](./webpack.common.js#L5)). This is necessary because you may need to use SVG's in several other context (inline images, fonts, icons, etc.) and so we need to be able to differentiate between these usages so the appropriate loader is invoked.
78+
```css
79+
body {
80+
background: url(./assets/bgimages/img_avatar.svg);
81+
}
82+
```
83+
84+
## Adding custom CSS
85+
When importing CSS from a third-party package for the first time, you may encounter the error `Module parse failed: Unexpected token... You may need an appropriate loader to handle this file typ...`. You need to register the path to the stylesheet directory in [stylePaths.js](./stylePaths.js). We specify these explicitly for performance reasons to avoid webpack needing to crawl through the entire node_modules directory when parsing CSS modules.
86+
87+
## Code quality tools
88+
* For accessibility compliance, we use [react-axe](https://github.com/dequelabs/react-axe)
89+
* To keep our bundle size in check, we use [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer)
90+
* To keep our code formatting in check, we use [prettier](https://github.com/prettier/prettier)
91+
* To keep our code logic and test coverage in check, we use [jest](https://github.com/facebook/jest)
92+
* To ensure code styles remain consistent, we use [eslint](https://eslint.org/)
93+
94+
## Multi environment configuration
95+
This project uses [dotenv-webpack](https://www.npmjs.com/package/dotenv-webpack) for exposing environment variables to your code. Either export them at the system level like `export MY_ENV_VAR=http://dev.myendpoint.com && npm run start:dev` or simply drop a `.env` file in the root that contains your key-value pairs like below:
96+
97+
```sh
98+
ENV_1=http://1.myendpoint.com
99+
ENV_2=http://2.myendpoint.com
100+
```
101+
102+
103+
With that in place, you can use the values in your code like `console.log(process.env.ENV_1);`

__mocks__/fileMock.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = 'test-file-stub';

0 commit comments

Comments
 (0)