- Formatting is done solely by prettier. It is completely automated, and not configurable in any way other than changing the
.prettierrcof this repo, and republishing the package. - Linting is not related to formatting in any way. The goal of linting is to catch early code quality issues, and enforce usage of best practices.
Use the following command to install the package as a dev dependency:
npm install @ottofeller/ofmt --save-dev --save-exactThen the following command is used to install prettier and eslint configs as dev dependencies:
npx ofmt installThe latter command on ofmt executable does:
- install
@ottofeller/prettier-config-ofmtpackage; - install
@ottofeller/eslint-config-ofmtpackage; - add the configs to package.json (
prettierandeslintConfigfields). - add
formatandlintscripts to package.json.
💡 For existing
prettierandeslintConfigfields in the package.json file:
prettierfield is overwritten;eslintConfigfiled is extended with eslint.quality.cjs.
💡 For existing
formatorlintscript in the package.json file warns and leaves the script untouched.
The project utilizes the following config packages (located within the same repo):
@ottofeller/prettier-config-ofmtpackage with formatting rules;@ottofeller/eslint-config-ofmtpackage containing:eslint.quality.cjswith JS/TS-specific code quality and best practices ruleseslint.tailwind.cjssame as above, CSS-specific
Direct use of configs is meant only for IDE support. For CLI runs use the provided executables.
There are two bin files that perform the code checking:
ofmt- prettier formatter. Two options are available:\-l, --lint- a flag to perform checking only. Without the flagprettierwill rewrite files with fixed formatting.-p, --src-path- defines search path for source code withinformatandlintscripts (the scripts added to a project upon installation). Defaults to./src. Used only withinstallcommand.-n, --no-local-config- ignores local eslint config files.
olint- code quality and best practices linter.
💡 The examples below use shorthand executable name as registered in PATH by
npm- available only if the package is installed in the project or in upper scopes on the search path ofnpm. If the@ottofeller/ofmtis not installed append with the package name:
npx -p @ottofeller/ofmt [ofmt|olint] ...npx ofmt -l './src/**/*.ts'npx ofmt './src/**/*.ts'npx ofmt install .npx ofmt install . -p "client server"NOTE: if run as npm-script the path will be inferred:
"scripts": {
"ofmt:install": "ofmt install",
...
}npm run ofmt:installnpx olint './src/**/*.ts'