# php-codesniffer

> Runs phpcs on specified file(s) and get result as JSON

Latest version **1.0.2** (published 2020-05-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install php-codesniffer
pnpm add php-codesniffer
yarn add php-codesniffer
bun add php-codesniffer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-05-04 |
| First published | 2020-05-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 10.10 |
| Dependencies | 1 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Konstantin Vyatkin |
| Maintainers | tinovyatkin |
| Keywords | PHP_CodeSniffer, lint, php, phpcs |

## Links

- npm: https://www.npmjs.com/package/php-codesniffer
- Repository: https://github.com/tinovyatkin/php-codesniffer
- Homepage: https://github.com/tinovyatkin/php-codesniffer#readme
- Issues: https://github.com/tinovyatkin/php-codesniffer/issues
- npm.io page: https://npm.io/package/php-codesniffer

## Dependencies (1)

- [php_codesniffer_master](https://npm.io/package/php_codesniffer_master.md) 1.0.0

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-05-04
- 1.0.1 — 2020-05-04
- 1.0.0 — 2020-05-03
- 0.0.1 — 2020-05-03

## README

# php-codesniffer [![codecov](https://codecov.io/gh/tinovyatkin/php-codesniffer/branch/master/graph/badge.svg)](https://codecov.io/gh/tinovyatkin/php-codesniffer)

Executes `phpcs` over a given file(s) and return results as JSON.
Written in TypeScript, good test coverage, no dependencies.

```ts
import { version, lint } from './linter';

it('returns version', async () => {
  expect(await version('php ./test/phpcs.phar')).toBe('3.5.5');
  expect(semver.valid(await version())).toBeTruthy();
});

it('lints several files', async () => {
  const res = await lint(
    './test/fixtures/test1.php ./test/fixtures/test2.php',
    undefined,
    {
      standard: path.resolve(
        __dirname,
        '../test/preferBeautifierConfig/subFolder/phpcs.xml',
      ),
    },
  );
  expect(res.totals).toMatchInlineSnapshot(`
      Object {
        "errors": 13,
        "fixable": 13,
        "warnings": 1,
      }
    `);
  expect(Object.values(res.files)).toMatchSnapshot();
});
```

### License

MIT

---
_Source: https://npm.io/package/php-codesniffer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
