Skip to content

Commit

Permalink
explicitly specify prettier rules and decouple from eslint
Browse files Browse the repository at this point in the history
this change decouples eslint and prettier (for reasoning, see:
https://prettier.io/docs/en/integrating-with-linters.html).

it also proposes a prettier config with all of the commonplace rules
explicitly set (instead of using the defaults).
  • Loading branch information
echo-bravo-yahoo committed Oct 23, 2024
1 parent f981b13 commit f4d30c9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ A collection of lint, format, and build configs used at Fauna for TypeScript pro
## Included configs (`./config/`)
- `eslint.config.js`, a minimal placeholder eslint config.
- `.gitignore`, a minimal placeholder .gitignore file.
- `prettierrc.js`, a minimal placeholder prettier config.
- `prettierrc.js`, a minimal placeholder prettier config. this is a _stand-alone_ prettier config, and is used as a stand-alone; it's not integrated into eslint ([by choice](https://prettier.io/docs/en/integrating-with-linters.html)). run it before running eslint. we use [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) to remove eslint rules that collide with prettier, so prettier is authoritative on stylistic formatting.
6 changes: 5 additions & 1 deletion config/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const eslintConfigPrettier = require("eslint-config-prettier");

// borrowed from fauna-shell
const config = [
{
Expand Down Expand Up @@ -32,6 +34,8 @@ const config = [
"no-unused-expressions": "off",
},
},
// this disables eslint's formatting rules that collide with prettier's
eslintConfigPrettier,
];

module.exports = config;
module.exports = { config };
17 changes: 13 additions & 4 deletions config/prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
/**
* @see https://prettier.io/docs/en/configuration.html
* @see https://prettier.io/docs/en/options
* @type {import("prettier").Config}
*/
const config = {
trailingComma: "es5",
tabWidth: 4,
semi: false,
singleQuote: true,
tabWidth: 2,
semi: true,
singleQuote: false,
quoteProps: "as-needed",
trailingComma: "all",
bracketSpacing: true,
bracketSameLine: false,
arrowParens: "always",
proseWrap: "preserve",
endOfLine: "lf",
embeddedLanguageFormatting: "auto",
singleAttributePerLine: false,
};

module.exports = config;
17 changes: 15 additions & 2 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"homepage": "https://github.com/fauna/typescript#readme",
"dependencies": {
"eslint-config-prettier": "^9.1.0",
"mentions-regex": "^2.0.3",
"parse-commit-message": "^5.0.4"
},
Expand Down

0 comments on commit f4d30c9

Please sign in to comment.