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

Add prettier #1574

Merged
merged 9 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .github/workflows/github-actions-PR-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
working-directory: src/main/cliapp
run: |
npm ci
npx prettier --check .
npm test -- --watchAll=false
npm run build
test-build-docker-image:
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ debug:
checkstyle:
mvn checkstyle:check

prettier-check:
npx prettier 'src/main/cliapp/**/*.js' --check

prettier-write:
npx prettier 'src/main/cliapp/**/*.js' --write

test:
mvn test

Expand Down
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ CONTAINER ID IMAGE COMMAND

This repository uses checkstyle to validate formatting of code to a coding standard. [Checkstyle](https://checkstyle.sourceforge.io/) is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard.

This repository also uses [Prettier](https://prettier.io/) to validate and update the formatting of code in the frontend codebase.

### Running Checkstyle

To run checkstyle locally in order to check your code before committing run the following:
Expand Down Expand Up @@ -295,12 +297,45 @@ make: *** [checkstyle] Error 1

Checkstyle can be configured via the checkstyle.xml file in the root of the project, this file can also be used by IDE's to keep code in line with the ruleset.

### Running Prettier

To validate formatting on JavaScript files locally with Prettier:

```bash
> npx prettier --check **/*.js
```

Or the make target:

```bash
> make prettier-check
```

To update formatting on JavaScript files locally with Prettier:

```bash
> npx prettier --write **/*.js
```

Or the make target:

```bash
> make prettier-write
```

Prettier can be configured via the .prettierrc.yaml file in the src/main/cliapp director of this project, this file can also be used by IDE's to keep code in line with the ruleset.

### Checkstyle Links

* Checkstyle for vscode: [https://marketplace.visualstudio.com/items?itemName=shengchen.vscode-checkstyle](https://marketplace.visualstudio.com/items?itemName=shengchen.vscode-checkstyle)
* Checkstyle for Intellij: [https://stackoverflow.com/questions/26955766/intellij-idea-checkstyle](https://stackoverflow.com/questions/26955766/intellij-idea-checkstyle)
* Checkstyle for Eclipse: [https://www.youtube.com/watch?v=H90QoBp2NSQ](https://www.youtube.com/watch?v=H90QoBp2NSQ) or [https://checkstyle.org/eclipse-cs/#!/](https://checkstyle.org/eclipse-cs/#!/)

### Prettier Links

* Prettier for vscode: [https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
* Prettier for Intellij: [https://www.jetbrains.com/help/idea/prettier.html](https://www.jetbrains.com/help/idea/prettier.html)

## Building

Before building locally, make sure and create a copy of the application.properties file
Expand Down
6 changes: 6 additions & 0 deletions src/main/cliapp/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
*.html
*.css
*.scss
*.json
*.yaml
6 changes: 6 additions & 0 deletions src/main/cliapp/.prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# see more options at https://prettier.io/docs/en/options
trailingComma: "es5"
tabWidth: 2
semi: true
singleQuote: true
printWidth: 120
16 changes: 8 additions & 8 deletions src/main/cliapp/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
const gulp = require("gulp");
const inlinesource = require("gulp-inline-source");
const replace = require("gulp-replace");
const gulp = require('gulp');
const inlinesource = require('gulp-inline-source');
const replace = require('gulp-replace');

gulp.task("default", () => {
gulp.task('default', () => {
return gulp
.src("./build/*.html")
.src('./build/*.html')
.pipe(replace('.js"></script>', '.js" inline></script>'))
.pipe(replace('rel="stylesheet">', 'rel="stylesheet" inline>'))
.pipe(
inlinesource({
compress: false,
ignore: ["png"],
ignore: ['png'],
})
)
.pipe(gulp.dest("./build"));
});
.pipe(gulp.dest('./build'));
});
31 changes: 30 additions & 1 deletion src/main/cliapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/main/cliapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
},
"eslintConfig": {
"extends": [
"react-app"
"react-app",
"prettier"
]
},
"browserslist": [
Expand All @@ -66,6 +67,8 @@
],
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"msw": "^0.48.1"
"eslint-config-prettier": "^9.1.0",
"msw": "^0.48.1",
"prettier": "3.2.5"
}
}
5 changes: 1 addition & 4 deletions src/main/cliapp/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import routes from './routes';
import './App.scss';

const App = () => {

const oktaAuth = new OktaAuth(oktaAuthConfig);

const history = useHistory();
Expand All @@ -27,9 +26,7 @@ const App = () => {

return (
<Security oktaAuth={oktaAuth} onAuthRequired={customAuthHandler} restoreOriginalUri={restoreOriginalUri}>
<Login>
{routes}
</Login>
<Login>{routes}</Login>
</Security>
);
};
Expand Down
Loading
Loading