- Formatting is done solely by prettier. It is completely automated, and not configurable in any way other than changing the
.prettierrc
of 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 instal the package as a dev dependency:
npm install @ottofeller/ofmt --save-dev
The package implements an install
command that copies prettier
and eslint
configs to your project - it creates a symlink to prettier
config file and adds/extends eslint
config within package.json. See the Examples sections for usage details.
NOTE: the install
script does not attempt to overwrite existing prettier
config - if a .prettierrc file exists it is left as is. An existing eslint
config is extended with eslint.quality.cjs.
The project contains the following configs:
.prettierrc
formatting ruleseslint.quality.cjs
with JS/TS-specific code quality and best practices ruleseslint.tailwind.cjs
same 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. A single option is available:
-l, --lint
- a flag to perform checking only. Without the flagprettier
will rewrite files with fixed formatting.olint
- code quality and best practices linter.
NOTE: 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 of npm
. If the @ottofeller/ofmt
is 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 .
NOTE: if run as npm-script the path will be inferred:
"scripts": {
"ofmt:install": "ofmt install",
...
}
npm run ofmt:install
npx olint './src/**/*.ts'