npm package (CLI)
PHPTaqwim can be used as an npm package (CLI). This has the advantage of integrating it with your build process. For example, you can use it as a pre-commit hook to make sure that the committed code is linted and formatted.
Installation
pnpm add @kalimahapps/taqwim -D
or
npm install @kalimahapps/taqwim -D
Options
In addition to the list of options below, you can run taqwim --help
to see the options in the console.
--path, -p
A comma separated paths to the files or directories to be processed. Paths are relative to the current working directory. If no path is provided, the current working directory will be used. Directories will be processed recursively
Type: string
Default: .
--fix, -f
Automatically fix errors.
Type: boolean
--report-style, -rs
The style of the report to be displayed.
Type: string
Default: default
Choices: default, json, none
--report-file, -o
File path to write the report to. Path can be relative to working directory or absolute. If not provided, the report will be displayed in the console.
Type: string
--cwd
Path to the directory to be used as the current working directory. If not provided, the current working directory will be used.
Type: string
--config-file-name, -cf
Config file name. If supplied, it will be used instead of the default config file name. It should be relative to cwd
arg if supplied, otherwise relative to CWD.
Type: string
--summary, -s
Display a summary of the report if reportStyle is "default".
Type: boolean
Default: false
--version, -v
Display the version.
Type: boolean
Default: false
--verbose, -vv
Display the column number in the report if reportStyle is "default".
Type: boolean
Default: false
--vvv
Display the rule name in the report if reportStyle is "default".
Type: boolean
Default: false
--hide-logo, -hl
Hide the logo in the report if reportStyle is "default".
Type: boolean
Default: false
--rule, -r
A comma separated list of rules to be used. If not provided, all rules will be used.
Type: string
--line, -l
A comma separated list of line numbers to be processed. If not provided, all lines will be processed.
Type: string
--column, -c
A comma separated list of column numbers to be processed. If not provided, all columns will be processed.
Type: string
--group-rules, -gr
Show output grouped by rule. Only applicable if reportStyle is "default".
Type: boolean
Default: false
--help, -h
Show help.
Type: boolean
Examples
TIP
Wrap any provided string with double quotes ("
) to avoid any issues with the shell.
Lint a file
taqwim --path=./path/to/file.php
Lint a directory
taqwim --path=./path/to/directory
Lint a file and write the report to a file
taqwim --path=./path/to/file.php --report-file=./path/to/report.json
Lint a file and apply fixes
taqwim --path=./path/to/file.php --fix
Lint specific rules
taqwim --path=./path/to/file.php --rules=rule-name,another-rule-name
Lint a file on a specific line
taqwim --path=./path/to/file.php --line=10