Skip to content

Commit 3da0b5b

Browse files
chore: Add Prettier configuration and setup
Add Prettier for consistent code formatting across the project. Changes: - Add .prettierrc.js with Standard-style formatting rules - Add .prettierignore to exclude build artifacts and dependencies - Add format and format:check scripts to package.json - Add prettier, eslint-config-prettier, and eslint-plugin-prettier packages - Update ESLint configuration to integrate with Prettier - Update .eslintignore to exclude style files - Update VS Code settings for Prettier integration - Update PostCSS and Babel configs for consistency This enables consistent code formatting and integrates Prettier with the existing ESLint setup.
1 parent 9a242db commit 3da0b5b

File tree

9 files changed

+12166
-8428
lines changed

9 files changed

+12166
-8428
lines changed

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@
66
/node_modules
77
.eslintrc.js
88
babel.config.js
9+
.prettierrc.js
10+
11+
# Style files (excluded from linting)
12+
*.css
13+
*.scss

.eslintrc.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ module.exports = {
44
// Remove this if you have an higher level ESLint config file (it usually happens into a monorepos)
55
root: true,
66

7+
parser: 'vue-eslint-parser',
78
parserOptions: {
89
parser: '@babel/eslint-parser',
910
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
10-
sourceType: 'module' // Allows for the use of imports
11+
sourceType: 'module', // Allows for the use of imports
12+
requireConfigFile: true, // Use babel.config.js for Babel configuration
1113
},
1214

1315
env: {
1416
browser: true,
15-
'vue/setup-compiler-macros': true
1617
},
1718

1819
// Rules order is important, please avoid shuffling them
@@ -23,19 +24,20 @@ module.exports = {
2324
// Uncomment any of the lines below to choose desired strictness,
2425
// but leave only one uncommented!
2526
// See https://eslint.vuejs.org/rules/#available-rules
26-
'plugin:vue/vue3-essential', // Priority A: Essential (Error Prevention)
27-
// 'plugin:vue/vue3-strongly-recommended', // Priority B: Strongly Recommended (Improving Readability)
28-
// 'plugin:vue/vue3-recommended', // Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead)
27+
'plugin:vue/essential', // Priority A: Essential (Error Prevention) - Vue 3
28+
// 'plugin:vue/strongly-recommended', // Priority B: Strongly Recommended (Improving Readability) - Vue 3
29+
// 'plugin:vue/recommended', // Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead) - Vue 3
2930

30-
'standard'
31-
31+
'standard',
32+
// Prettier must be last to override other configs
33+
'plugin:prettier/recommended',
3234
],
3335

3436
plugins: [
3537
// https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-files
3638
// required to lint *.vue files
3739
'vue',
38-
40+
'prettier',
3941
],
4042

4143
globals: {
@@ -48,7 +50,7 @@ module.exports = {
4850
__QUASAR_SSR_PWA__: 'readonly',
4951
process: 'readonly',
5052
Capacitor: 'readonly',
51-
chrome: 'readonly'
53+
chrome: 'readonly',
5254
},
5355

5456
// add your custom rules here
@@ -73,12 +75,11 @@ module.exports = {
7375
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
7476

7577
// custom
76-
'semi': [2, 'always'],
77-
'space-before-function-paren': [2, 'always'],
78-
'keyword-spacing': [2, { before: true, after: true }],
79-
'space-before-blocks': [2, 'always'],
80-
'comma-dangle': [2, 'always-multiline'],
8178
'no-console': 'off',
8279
'no-multi-str': 'off',
83-
}
80+
81+
// Prettier integration - Prettier handles formatting, so we disable conflicting rules
82+
// eslint-config-prettier disables formatting rules, but we keep some custom ones
83+
'prettier/prettier': 'error',
84+
},
8485
}

.postcssrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
module.exports = {
55
plugins: [
66
// to edit target browsers: use "browserslist" field in package.json
7-
require('autoprefixer')
8-
]
7+
require('autoprefixer'),
8+
],
99
}

.prettierignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build outputs
5+
dist/
6+
.quasar/
7+
*.min.js
8+
*.bundle.js
9+
10+
# Generated files
11+
coverage/
12+
*.log
13+
14+
# Config files that shouldn't be formatted
15+
package-lock.json
16+
yarn.lock
17+
pnpm-lock.yaml
18+
19+
# Other
20+
.DS_Store
21+
*.swp
22+
*.swo
23+
*~
24+

.prettierrc.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
// Basic formatting
3+
semi: false, // Standard style: no semicolons
4+
singleQuote: true, // Standard style: single quotes
5+
quoteProps: 'as-needed',
6+
trailingComma: 'es5', // Standard style: trailing commas for ES5
7+
bracketSpacing: true,
8+
arrowParens: 'avoid', // Match ESLint rule: 'arrow-parens': 'off'
9+
10+
// Indentation
11+
tabWidth: 2, // Standard: 2 spaces
12+
useTabs: false,
13+
14+
// Line length
15+
printWidth: 100,
16+
17+
// Line endings
18+
endOfLine: 'lf',
19+
20+
// Vue-specific
21+
vueIndentScriptAndStyle: false,
22+
23+
// Other
24+
bracketSameLine: false,
25+
singleAttributePerLine: false,
26+
}

.vscode/settings.json

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
{
2-
"editor.codeActionsOnSave": [
3-
"source.fixAll.eslint"
4-
],
5-
"eslint.validate": [
6-
"javascript",
7-
"javascriptreact",
8-
"typescript",
9-
"vue"
10-
],
11-
// "eslint.autoFixOnSave": true
12-
// "editor.formatOnSave": true,
2+
"editor.codeActionsOnSave": {
3+
"source.fixAll.eslint": "always"
4+
},
5+
"eslint.validate": ["javascript", "javascriptreact", "typescript", "vue"],
6+
"yaml.validate": false,
7+
"prettier.configPath": ".prettierrc.js",
8+
"editor.formatOnSave": true
139
// "vetur.format.defaultFormatter.html": "js-beautify-html",
1410
}

babel.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ module.exports = api => {
77
'@quasar/babel-preset-app',
88
api.caller(caller => caller && caller.target === 'node')
99
? { targets: { node: 'current' } }
10-
: {}
11-
]
12-
]
10+
: {},
11+
],
12+
],
1313
}
1414
}

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"private": true,
88
"scripts": {
99
"lint": "eslint --ext .js,.vue ./",
10+
"format": "prettier --write \"**/*.{js,vue,json,scss,css,md}\"",
11+
"format:check": "prettier --check \"**/*.{js,vue,json,scss,css,md}\"",
1012
"test": "echo \"No test specified\" && exit 0",
1113
"serve": "firebase serve",
1214
"dev": "quasar dev -m ssr",
@@ -31,12 +33,15 @@
3133
"@babel/eslint-parser": "^7.13.14",
3234
"@quasar/app-webpack": "^3.7.2",
3335
"eslint": "^8.10.0",
36+
"eslint-config-prettier": "^10.1.8",
3437
"eslint-config-standard": "^17.0.0",
3538
"eslint-plugin-import": "^2.19.1",
3639
"eslint-plugin-n": "^15.0.0",
40+
"eslint-plugin-prettier": "^5.5.4",
3741
"eslint-plugin-promise": "^6.0.0",
3842
"eslint-plugin-vue": "^8.5.0",
3943
"eslint-webpack-plugin": "^3.1.1",
44+
"prettier": "^3.6.2",
4045
"pug": "^3.0.2",
4146
"pug-plain-loader": "^1.1.0",
4247
"workbox-webpack-plugin": "^6.0.0"

0 commit comments

Comments
 (0)