Skip to content

Commit

Permalink
meta: add Prettier (#4707)
Browse files Browse the repository at this point in the history
JS files are ignored for now because we want to migrate them to TS
anyway.
MD files are also ignored to minimize the diff.

ESLint is run twice twice on TS files in case it conflicts with Prettier.
  • Loading branch information
aduh95 authored Sep 28, 2023
1 parent 8138b45 commit 2f691ac
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 6 deletions.
19 changes: 16 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const svgPresentationAttributes = [

module.exports = {
root: true,
extends: ['transloadit'],
extends: ['transloadit', 'prettier'],
env: {
es6: true,
jest: true,
Expand Down Expand Up @@ -63,7 +63,6 @@ module.exports = {
// rules we want to enforce
'array-callback-return': 'error',
'func-names': 'error',
'implicit-arrow-linebreak': 'error',
'import/no-dynamic-require': 'error',
'import/no-extraneous-dependencies': 'error',
'max-len': 'error',
Expand Down Expand Up @@ -142,6 +141,7 @@ module.exports = {
{
files: [
'*.jsx',
'*.tsx',
'packages/@uppy/react-native/**/*.js',
],
parser: 'espree',
Expand Down Expand Up @@ -358,6 +358,7 @@ module.exports = {
'test/**/*.ts',
'*.test.js',
'*.test-d.ts',
'*.test-d.tsx',
'postcss.config.js',
'.eslintrc.js',
'private/**/*.js',
Expand Down Expand Up @@ -474,11 +475,23 @@ module.exports = {
},
},
{
files: ['**/react/*.md/*.js', '**/react.md/*.js', '**/react-*.md/*.js'],
files: ['**/react/*.md/*.js', '**/react.md/*.js', '**/react-*.md/*.js', '**/react/**/*.test-d.tsx'],
settings: {
react: { pragma: 'React' },
},
},
{
files: ['**/react/**/*.test-d.tsx'],
rules: {
'import/extensions': 'off',
'import/no-useless-path-segments': 'off',
'no-alert': 'off',
'no-inner-declarations': 'off',
'no-lone-blocks': 'off',
'no-unused-expressions': 'off',
'no-unused-vars': 'off',
},
},
{
files: ['e2e/**/*.ts'],
extends: ['plugin:cypress/recommended'],
Expand Down
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
*.js
*.jsx
*.cjs
*.mjs
*.md
*.lock
14 changes: 14 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
proseWrap: 'always',
singleQuote: true,
trailingComma: 'all',
semi: false,
overrides: [
{
files: 'packages/@uppy/angular/**',
options: {
semi: true,
},
},
],
}
2 changes: 1 addition & 1 deletion e2e/clients/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ <h1>Test apps</h1>
<li><a href="dashboard-ui/index.html">dashboard-ui</a></li>
<li><a href="dashboard-vue/index.html">dashboard-vue</a></li>
</ul>
<nav>
</nav>
</body>
</html>
2 changes: 1 addition & 1 deletion examples/transloadit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h2>Form</h2>
<strong id="uppy-form-selected-files"></strong>
<button type="button" id="uppy-select-files">Select Files</button>
</label>
<div class="progress"></div>
<span class="progress"></span>
</p>
<p>
<button type="submit">
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
"description": "Extensible JavaScript file upload widget with support for drag&drop, resumable uploads, previews, restrictions, file processing/encoding, remote providers like Instagram, Dropbox, Google Drive, S3 and more :dog:",
"lint-staged": {
"*.{js,mjs,cjs,jsx}": "eslint --fix",
"*.{ts,mts,cts,tsx}": "eslint --fix",
"*.{ts,mts,cts,tsx}": [
"eslint --fix",
"prettier -w",
"eslint"
],
"*.{css,html,json,scss,vue,yaml,yml}": "prettier -w",
"*.md": [
"remark --silently-ignore -i .remarkignore -foq",
"eslint --fix"
Expand Down Expand Up @@ -62,6 +67,7 @@
"esbuild": "^0.17.1",
"esbuild-plugin-babel": "^0.2.3",
"eslint": "^8.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-transloadit": "^2.0.0",
"eslint-plugin-compat": "^4.0.0",
"eslint-plugin-cypress": "^2.12.1",
Expand Down Expand Up @@ -91,6 +97,7 @@
"postcss-dir-pseudo-class": "^6.0.0",
"postcss-logical": "^5.0.0",
"pre-commit": "^1.2.2",
"prettier": "^3.0.3",
"remark-cli": "^11.0.0",
"resolve": "^1.17.0",
"sass": "^1.29.0",
Expand Down
22 changes: 22 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9045,6 +9045,7 @@ __metadata:
esbuild: ^0.17.1
esbuild-plugin-babel: ^0.2.3
eslint: ^8.0.0
eslint-config-prettier: ^9.0.0
eslint-config-transloadit: ^2.0.0
eslint-plugin-compat: ^4.0.0
eslint-plugin-cypress: ^2.12.1
Expand Down Expand Up @@ -9074,6 +9075,7 @@ __metadata:
postcss-dir-pseudo-class: ^6.0.0
postcss-logical: ^5.0.0
pre-commit: ^1.2.2
prettier: ^3.0.3
remark-cli: ^11.0.0
resolve: ^1.17.0
sass: ^1.29.0
Expand Down Expand Up @@ -15778,6 +15780,17 @@ __metadata:
languageName: node
linkType: hard

"eslint-config-prettier@npm:^9.0.0":
version: 9.0.0
resolution: "eslint-config-prettier@npm:9.0.0"
peerDependencies:
eslint: ">=7.0.0"
bin:
eslint-config-prettier: bin/cli.js
checksum: 362e991b6cb343f79362bada2d97c202e5303e6865888918a7445c555fb75e4c078b01278e90be98aa98ae22f8597d8e93d48314bec6824f540f7efcab3ce451
languageName: node
linkType: hard

"eslint-config-transloadit@npm:^2.0.0":
version: 2.0.0
resolution: "eslint-config-transloadit@npm:2.0.0"
Expand Down Expand Up @@ -26290,6 +26303,15 @@ __metadata:
languageName: node
linkType: hard

"prettier@npm:^3.0.3":
version: 3.0.3
resolution: "prettier@npm:3.0.3"
bin:
prettier: bin/prettier.cjs
checksum: e10b9af02b281f6c617362ebd2571b1d7fc9fb8a3bd17e371754428cda992e5e8d8b7a046e8f7d3e2da1dcd21aa001e2e3c797402ebb6111b5cd19609dd228e0
languageName: node
linkType: hard

"pretty-bytes@npm:^5.3.0, pretty-bytes@npm:^5.6.0":
version: 5.6.0
resolution: "pretty-bytes@npm:5.6.0"
Expand Down

0 comments on commit 2f691ac

Please sign in to comment.