- 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 install the package as a dev dependency:
npm install @ottofeller/ofmt --save-dev --save-exact
Then the following command is used to install prettier
and eslint
configs as dev dependencies:
npx ofmt install
The latter command on ofmt
executable does:
- install
@ottofeller/prettier-config-ofmt
package; - install
@ottofeller/eslint-config-ofmt
package; - add the configs to package.json (
prettier
andeslintConfig
fields). - add
format
andlint
scripts to package.json.
💡 For existing
prettier
andeslintConfig
fields in the package.json file:
prettier
field is overwritten;eslintConfig
filed is extended with eslint.quality.cjs.
💡 For existing
format
orlint
script 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-ofmt
package with formatting rules;@ottofeller/eslint-config-ofmt
package containing:eslint.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. Two options are available:\-l, --lint
- a flag to perform checking only. Without the flagprettier
will rewrite files with fixed formatting.-p, --src-path
- defines search path for source code withinformat
andlint
scripts (the scripts added to a project upon installation). Defaults to./src
. Used only withinstall
command.-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/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 .
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:install
npx olint './src/**/*.ts'