Registry / devops / prettier-formatter-gitlab

prettier-formatter-gitlab

JSON →
library1.1.0jsnpmunverified

A Prettier formatter that generates GitLab Code Quality reports. Version 1.1.0 is a stable release with no active development cadence. It transforms Prettier output into a JSON format compatible with GitLab's Code Quality feature, enabling CI/CD pipelines to display code formatting issues as merge request annotations. Different from other formatters like prettier-formatter-default, it produces a GitLab-specific report that integrates with GitLab's UI. No major updates since initial release; primarily a utility for GitLab users.

npm install prettier-formatter-gitlab
INSTALL
IMPORT
SIG · PRETTIER-FORMATTER
P
prettier-formatter-gitlab
devopsjavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import gitlabFormatter from 'prettier-formatter-gitlab'
✗ const gitlabFormatter = require('prettier-formatter-gitlab')
Package is ESM-only; CommonJS require will fail.
GitLabFormatter
✓ import { GitLabFormatter } from 'prettier-formatter-gitlab'
✗ import { gitlabFormatter } from 'prettier-formatter-gitlab'
Named export uses PascalCase.
formats
✓ const { formats } = require('prettier-formatter-gitlab')
✗ const formats = require('prettier-formatter-gitlab').formats
CommonJS destructuring works if using a bundler that supports dynamic require; but ESM is recommended.

Shows using the plugin with Prettier's format() to produce a GitLab Code Quality report.

import prettier from 'prettier'; import gitlabFormatter from 'prettier-formatter-gitlab'; const code = 'const x = 1'; const result = prettier.format(code, { parser: 'babel', plugins: [gitlabFormatter], }); // result is a GitLab Code Quality report JSON string const report = JSON.parse(result); console.log(JSON.stringify(report, null, 2));
Debug
Known issues
gotchaThis package only works as a Prettier plugin; does not function standalone.
fix
Always pass it as a plugin to Prettier's format or CLI.
affects: all
deprecatedThe package has not been updated since 2021; may not support newer Prettier versions (>=3.0).
fix
Check compatibility with your Prettier version; consider using built-in GitLab support if available.
affects: >=1.0.0
breakingESM-only: CommonJS require() may throw 'ERR_REQUIRE_ESM' in Node.js versions <14.
fix
Use dynamic import() or set type: module in package.json.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'prettier-formatter-gitlab'
Package not installed or not in node_modules.
fix
Run npm install prettier-formatter-gitlab --save-dev
TypeError: gitlabFormatter is not a function
Using require() on ESM-only package incorrectly.
fix
Use import gitlabFormatter from 'prettier-formatter-gitlab' or dynamic import.
Error: Couldn't parse source files into AST
Misconfigured options when using the plugin.
fix
Ensure you pass the formatter as a plugin in Prettier options, not as a standalone module.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
prettier-formatter-gitlab — npm install prettier-formatter-gitlab · libregistry