Skip to content

Commit

Permalink
Merge pull request #9 from bence-toth/4-stylelint
Browse files Browse the repository at this point in the history
Stylelint and Prettier
  • Loading branch information
bence-toth authored Jul 16, 2022
2 parents 9b57b51 + d18416e commit 7f93dc1
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 3 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@ No spinning logo, no unnecessary boilerplate code.
In addition to [the official TypeScript template](https://github.com/facebook/create-react-app/tree/main/packages/cra-template-typescript), the following dependencies are included by default:

- [classnames](https://www.npmjs.com/package/classnames)
- [prettier](https://www.npmjs.com/package/prettier)
- [react-router-dom](https://www.npmjs.com/package/react-router-dom)
- [stylelint](https://www.npmjs.com/package/stylelint)
- [stylelint](https://www.npmjs.com/package/stylelint)
- [stylelint-config-prettier](https://www.npmjs.com/package/stylelint-config-prettier)
- [stylelint-config-standard](https://www.npmjs.com/package/stylelint-config-standard)
- [stylelint-prettier](https://www.npmjs.com/package/stylelint-prettier)

Furthermore, there are the following additions:

- HTTPS is enabled in development and test mode
- Some additional npm scripts are available:
- `npm run lint-js` to run ESLint
- `npm run lint-css` to run Stylelint
- `npm run lint` to run both ESLint and Stylelint
- `npm run prettier` to run a Prettier check

To use this template, add `--template typescript-blank` when creating a new app.

Expand Down
11 changes: 11 additions & 0 deletions template.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"classnames": "^2.3.1",
"prettier": "^2.7.1",
"react-router-dom": "^6.3.0",
"stylelint": "^14.9.1",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-standard": "^26.0.0",
"stylelint-prettier": "^2.0.0",
"typescript": "^4.4.2",
"web-vitals": "^2.1.0"
},
"eslintConfig": {
"extends": ["react-app", "react-app/jest"]
},
"scripts": {
"lint": "npm run lint-js; npm run lint-css",
"lint-js": "eslint ./src",
"lint-css": "stylelint \"**/*.css\"",
"prettier": "prettier --check ."
}
}
}
1 change: 1 addition & 0 deletions template/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
7 changes: 7 additions & 0 deletions template/.stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": ["stylelint-config-standard", "stylelint-config-prettier"],
"plugins": ["stylelint-prettier"],
"rules": {
"prettier/prettier": true
}
}
4 changes: 2 additions & 2 deletions template/src/reportWebVitals.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ReportHandler } from 'web-vitals';
import { ReportHandler } from "web-vitals";

const reportWebVitals = (onPerfEntry?: ReportHandler) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
import("web-vitals").then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
Expand Down
2 changes: 1 addition & 1 deletion template/src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';
import "@testing-library/jest-dom";
20 changes: 20 additions & 0 deletions template/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"]
}

0 comments on commit 7f93dc1

Please sign in to comment.