Skip to content

Latest commit

 

History

History
52 lines (40 loc) · 1.89 KB

File metadata and controls

52 lines (40 loc) · 1.89 KB

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 💡