php-codesniffer
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

php-codesniffer codecov

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

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

Package Sidebar

Install

npm i php-codesniffer

Weekly Downloads

20

Version

1.0.2

License

MIT

Unpacked Size

7.36 kB

Total Files

7

Last publish

Collaborators

  • tinovyatkin