Skip to content

Add support for dependencies to custom formatter flag #5192

@ThornWalli

Description

@ThornWalli

Current implementation, although using require, only provides relative or absolute file path.

stylelint/lib/cli.js

Lines 348 to 354 in 16ae9e4

if (cli.flags.customFormatter) {
const customFormatter = path.isAbsolute(cli.flags.customFormatter)
? cli.flags.customFormatter
: path.join(process.cwd(), cli.flags.customFormatter);
formatter = require(customFormatter);
}

So it is not possible to import a formatter as dependency correctly.

Not Correct stylelint "src/**/*.css" --custom-formatter node_modules/dependency/index.js

Correct stylelint "src/**/*.css" --custom-formatter dependency

Topic was already mentioned here in the past. #2449

PR: #5193

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions