Skip to content

Commit

Permalink
feat: Add prettier auto-formatter
Browse files Browse the repository at this point in the history
Add the prettier auto-formatter and integrate with eslint
  • Loading branch information
nielm committed Mar 14, 2024
1 parent e87d017 commit 9db2814
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.next
next-env.d.ts
node_modules
yarn.lock
package-lock.json
public
10 changes: 3 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ module.exports = {
'commonjs': true,
'es2021': true,
},
'extends': 'google',
'extends': ['google', 'plugin:prettier/recommended'],
'overrides': [
{
'env': {
'node': true,
},
'files': [
'.eslintrc.{js,cjs}',
],
'files': ['.eslintrc.{js,cjs}'],
'parserOptions': {
'sourceType': 'script',
},
Expand All @@ -37,7 +35,5 @@ module.exports = {
'parserOptions': {
'ecmaVersion': 'latest',
},
'rules': {
},
'rules': {},
};

7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.next
next-env.d.ts
node_modules
yarn.lock
package-lock.json
public
*.md
62 changes: 62 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const shared = {
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
quoteProps: 'preserve',
bracketSpacing: false,
trailingComma: 'all',
arrowParens: 'always',
embeddedLanguageFormatting: 'off',
bracketSameLine: true,
singleAttributePerLine: false,
jsxSingleQuote: false,
htmlWhitespaceSensitivity: 'strict',
};

module.exports = {
overrides: [
{
/** TSX/TS/JS-specific configuration. */
files: '*.tsx',
options: shared,
},
{
files: '*.ts',
options: shared,
},
{
files: '*.js',
options: shared,
},
{
/** Sass-specific configuration. */
files: '*.scss',
options: {
singleQuote: true,
},
},
{
files: '*.html',
options: {
printWidth: 100,
},
},
{
files: '*.acx.html',
options: {
parser: 'angular',
singleQuote: true,
},
},
{
files: '*.ng.html',
options: {
parser: 'angular',
singleQuote: true,
printWidth: 100,
},
},
],
};
2 changes: 1 addition & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"target": "ES6",
"checkJs": true,
"allowJs": true,
"noEmit": true,
"noEmit": true
},
"include": ["src/**/*"],
"exclude": ["src/**/node_modules"]
Expand Down
116 changes: 114 additions & 2 deletions package-lock.json

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

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"scripts": {
"eslint": "eslint .",
"eslint-fix": "eslint --fix .",
"check-format": "prettier --check .",
"format": "prettier --write .",
"typecheck": "tsc --project jsconfig.json --maxNodeModuleJsDepth 0 --noEmit",
"mdlint": "markdownlint '**/*.md' --config .mdl.json --ignore '**/node_modules/**' --ignore 'code-of-conduct.md' --ignore 'CHANGELOG.md'",
"install-all": "find . -name package.json -a ! -path '*/node_modules/*' -execdir pwd \\; -execdir npm install --save \\;"
Expand All @@ -16,11 +18,14 @@
"@types/mocha": "^10.0.6",
"eslint": "^8.57.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"markdownlint-cli": "^0.39.0",
"prettier": "^3.2.5",
"typescript": "^5.4.2"
},
"engines": {
"node": ">=18.0.0 || >=20.0.0",
"npm": ">=10.0.0"
"npm": ">=10.0.0"
}
}
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
},
"engines": {
"node": ">=18.0.0 || >=20.0.0",
"npm": ">=10.0.0"
"npm": ">=10.0.0"
}
}

0 comments on commit 9db2814

Please sign in to comment.