eslint-parser-plain

raw JSON →
0.1.1 verified Sat Apr 25 auth: no javascript

ESLint parser that allows linting of various plain text file types (e.g., Markdown, JSON, YAML) by treating them as plain text strings. Version 0.1.1 is the current stable release with a slow release cadence. It is designed for use with ESLint's parser option to enable linting rules (like prettier/prettier) in non-JavaScript files. Differentiates from @eslint/markdown by being simpler and file-type agnostic.

error Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/eslint-parser-plain/dist/index.js from /path/to/.eslintrc.cjs not supported.
cause ESLint config file (e.g., .eslintrc.cjs) uses require() for an ESM-only package.
fix
Change .eslintrc.cjs to .eslintrc.mjs and use import statements, or use dynamic import: const parser = await import('eslint-parser-plain');
error Parsing error: The parser 'eslint-parser-plain' is not found.
cause The package is not installed or is not in node_modules.
fix
Run 'npm install eslint-parser-plain --save-dev' and ensure your ESLint configuration points to the correct package name.
error TypeError: (0 , _default.parse) is not a function
cause Importing default export incorrectly in a CommonJS context.
fix
Use the named export parseForESLint or import the default as shown in the quickstart.
gotcha eslint-parser-plain does not perform syntax validation; it treats all input as plain text. This may hide syntax errors in files like JSON.
fix Ensure your files are syntactically valid before linting, or combine with another parser for validation.
breaking ESM-only package: using require('eslint-parser-plain') will throw 'ERR_REQUIRE_ESM'.
fix Use import statements or dynamic import() in CJS contexts. Alternatively, configure ESLint to support ESM parsers.
gotcha The package's parse method returns an object with an 'ast' property set to a minimal token (e.g., { type: 'Program', body: [] }), not a full AST. This may break tools expecting a standard ESTree AST.
fix Do not rely on the AST structure; this parser is intended only for plain text string extraction.
deprecated No known deprecations; all current APIs are stable.
fix N/A
npm install eslint-parser-plain
yarn add eslint-parser-plain
pnpm add eslint-parser-plain

Configures ESLint to use eslint-parser-plain for .md and .json files, enabling prettier rules on them.

// .eslintrc.cjs
module.exports = {
  overrides: [
    {
      files: ['*.md', '*.json'],
      parser: 'eslint-parser-plain',
      rules: {
        'prettier/prettier': ['error', { parser: 'markdown' }],
      },
    },
  ],
};