Skip to content

Commit

Permalink
Enable prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
timja committed Aug 25, 2022
1 parent 6b0dc18 commit 16f0d3b
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"endOfLine": "auto",
"htmlWhitespaceSensitivity": "ignore"
}
2 changes: 1 addition & 1 deletion war/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
es2022: true
},
// Uses eslint default ruleset
extends: "eslint:recommended",
extends: ["eslint:recommended", "prettier"],
parserOptions: {
sourceType: "module"
},
Expand Down
34 changes: 34 additions & 0 deletions war/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# generated / build files
.pnp.cjs
.pnp.loader.mjs
target/
work/
node/

.yarnrc.yml

# libraries / external deps / generated files
src/main/js/plugin-setup-wizard/bootstrap-detached.js
src/main/webapp/scripts/behavior.js
src/main/webapp/bootstrap
src/main/webapp/scripts/yui
src/main/webapp/scripts/prototype.js
src/main/fonts/font-awesome
src/main/webapp/css/font-awesome
src/main/fonts/google-fonts/roboto/css/roboto.css
src/main/webapp/css/google-fonts/roboto/css/roboto.css
src/main/fonts/icomoon/css/icomoon.css
src/main/webapp/css/icomoon/css/icomoon.css
src/main/webapp/jsbundles/

# test files that we don't need formatted
../test/src/test/resources
../test/jmh-report.json

# doesn't work, see https://github.com/prettier/prettier/issues/5340
*.hbs

.yarn

# TODO not sure why this fails
src/main/less/abstracts/theme.less
8 changes: 5 additions & 3 deletions war/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"prod": "webpack --config webpack.config.js --mode=production",
"build": "yarn prod",
"start": "yarn dev --watch",
"lint:js": "eslint . --ext js",
"lint:js-ci": "eslint . --ext js -f checkstyle -o target/eslint-warnings.xml",
"lint:js": "eslint . --ext js && prettier --check ../",
"lint:js-ci": "eslint . --ext js -f checkstyle -o target/eslint-warnings.xml && prettier --check ../",
"lint:css": "stylelint src/main/less",
"lint:css-ci": "stylelint src/main/less --custom-formatter stylelint-formatter.js -o target/stylelint-warnings.xml",
"lint:css:fix": "stylelint src/main/less --fix",
"lint:ci": "yarn lint:js-ci && yarn lint:css-ci",
"lint:fix": "prettier --write ../ && stylelint src/main/less --fix",
"lint": "yarn lint:js && yarn lint:css"
},
"devDependencies": {
Expand All @@ -31,13 +31,15 @@
"css-loader": "6.7.1",
"css-minimizer-webpack-plugin": "4.0.0",
"eslint": "8.22.0",
"eslint-config-prettier": "8.5.0",
"handlebars": "4.7.7",
"handlebars-loader": "1.7.2",
"less": "4.1.3",
"less-loader": "11.0.0",
"mini-css-extract-plugin": "2.6.1",
"postcss": "8.4.16",
"postcss-loader": "7.0.1",
"prettier": "2.7.1",
"style-loader": "3.3.1",
"stylelint": "14.11.0",
"stylelint-config-standard": "28.0.0",
Expand Down
9 changes: 5 additions & 4 deletions war/stylelint-formatter.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/* eslint-env node */
const reporter = require('stylelint-checkstyle-reporter')
// TODO remove this file once https://github.com/stylelint/stylelint/issues/6100 is released
const reporter = require("stylelint-checkstyle-reporter");

/**
* @type {import('stylelint').Formatter}
* @type {import("stylelint").Formatter}
*/
function formatter(results, returnValue) {
returnValue.output = reporter(results)
returnValue.output = reporter(results);

return returnValue.output
return returnValue.output;
}

module.exports = formatter;
22 changes: 22 additions & 0 deletions war/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3061,6 +3061,17 @@ __metadata:
languageName: node
linkType: hard

"eslint-config-prettier@npm:8.5.0":
version: 8.5.0
resolution: "eslint-config-prettier@npm:8.5.0"
peerDependencies:
eslint: ">=7.0.0"
bin:
eslint-config-prettier: bin/cli.js
checksum: 0d0f5c32e7a0ad91249467ce71ca92394ccd343178277d318baf32063b79ea90216f4c81d1065d60f96366fdc60f151d4d68ae7811a58bd37228b84c2083f893
languageName: node
linkType: hard

"eslint-scope@npm:5.1.1":
version: 5.1.1
resolution: "eslint-scope@npm:5.1.1"
Expand Down Expand Up @@ -4027,6 +4038,7 @@ __metadata:
css-loader: 6.7.1
css-minimizer-webpack-plugin: 4.0.0
eslint: 8.22.0
eslint-config-prettier: 8.5.0
handlebars: 4.7.7
handlebars-loader: 1.7.2
hotkeys-js: 3.9.5
Expand All @@ -4039,6 +4051,7 @@ __metadata:
postcss: 8.4.16
postcss-less: 6.0.0
postcss-loader: 7.0.1
prettier: 2.7.1
sortablejs: 1.15.0
style-loader: 3.3.1
stylelint: 14.11.0
Expand Down Expand Up @@ -5466,6 +5479,15 @@ __metadata:
languageName: node
linkType: hard

"prettier@npm:2.7.1":
version: 2.7.1
resolution: "prettier@npm:2.7.1"
bin:
prettier: bin-prettier.js
checksum: 55a4409182260866ab31284d929b3cb961e5fdb91fe0d2e099dac92eaecec890f36e524b4c19e6ceae839c99c6d7195817579cdffc8e2c80da0cb794463a748b
languageName: node
linkType: hard

"promise-inflight@npm:^1.0.1":
version: 1.0.1
resolution: "promise-inflight@npm:1.0.1"
Expand Down

0 comments on commit 16f0d3b

Please sign in to comment.