Skip to content

IshayMaya/eslint-plugin-php

 
 

Repository files navigation

ESLint Plugin PHP

An ESLint plugin to lint PHP files.

Note

This is basically a POC for PHP linter using ESLint's new Languages API. It aims to provide a better linting experience than PHP CodeSniffer.

Installation

npm i -D eslint-plugin-php

Usage

Add php as a plugin in your ESLint configuration file, specify the language for the files you want to lint, and configure the rules you want to use:

// eslint.config.mjs
import php from 'eslint-plugin-php';
import { defineConfig } from 'eslint/config';

export default defineConfig([
  {
    files: ['**/*.php'],
    plugins: {
      php,
    },
    language: 'php/php',
    rules: {
      'php/eqeqeq': 'error',
      'php/no-array-keyword': 'error',
    },
  },
]);

Available Rules

🔧 - Automatically fixable by the --fix CLI option.

💡 - Manually fixable by editor suggestions.

Rule ID Description 🔧 💡
php/disallow-references Disallow the use of references 💡
php/eqeqeq Require the use of === and !==
php/no-array-keyword Disallow the use of the array keyword 🔧
php/require-visibility Require visibility for class methods and properties 💡

About

An ESLint plugin to lint PHP files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 97.6%
  • JavaScript 2.4%