Как сгенерировать checkstyle.xml для Jenkins с помощью stylelint? - PullRequest
0 голосов
/ 04 мая 2018

Интересно, как сгенерировать checkstyle.xml для Jenkins с помощью stylelint. Поиском по сети и, к сожалению, нашел только stylelint-checkstyle-formatter , но только следующую «инструкцию»:

Просто прочитайте документацию к стилевому стилю об использовании средств форматирования и следуйте этим инструкциям.

К сожалению, я ничего не нашел в документации ...

Ответы [ 2 ]

0 голосов
/ 01 июля 2019

Я получил его для работы через CLI, установив плагин stylelint-checkstyle-formatter и затем передав его в stylelint с помощью опции --custom-formatter:

npm install stylelint-checkstyle-formatter --save-dev
stylelint --custom-formatter ./node_modules/stylelint-checkstyle-formatter ....
0 голосов
/ 04 мая 2018

Я наконец нашел способ (с gulp) и хочу поделиться им в StackOverflow.

Сначала установите следующие зависимости:

yarn add -D stylelint gulp-stylelint stylelint-checkstyle-formatter stylelint-scss stylelint-config-recommended-scss

Затем используйте следующее задание глотка:

gulp.task("scss-lint", function() {
    const gulpStylelint = require('gulp-stylelint');
    const stylelintCheckstyleFormatter = require('stylelint-checkstyle-formatter');

    return gulp
        .src('src/**/*.scss')
        .pipe(gulpStylelint({
            reportOutputDir: 'build/reports/scss-checkstyle',
            reporters: [
                {formatter: 'verbose', console: true},
                {formatter: stylelintCheckstyleFormatter, save: 'checkstyle.xml'},
            ],
        }));
});

И, наконец, мой .stylelint:

{
    "extends": "stylelint-config-recommended-scss",
    "defaultSeverity": "warning",
    "formatter": "stylelint-checkstyle-formatter",
    "plugins": [
        "stylelint-scss"
    ],
        "rules": {
        "indentation": 4,
            "color-hex-length": null,
            "shorthand-property-no-redundant-values": null,
            "no-missing-end-of-source-newline": null,
            "declaration-empty-line-before": null,
            "at-rule-empty-line-before": null,
            "selector-type-no-unknown": [
            true,
            {
                "ignore": ["custom-elements"],
                "ignoreTypes": ["tooltip"]
            }
        ]
    }
}
...