prettier/stylelint-prettier

4.0.1 causes crash if a .prettierrc.js file is not present

mattbrictson opened this issue · 1 comments

stylelint crashes with the introduction of with stylelint-prettier 4.0.1. The crash goes away if a .prettierrc.js file is created.

What version of stylelint, prettier and stylelint-prettier are you using?

prettier@3.0.0
stylelint-prettier@4.0.1
stylelint@15.10.2

Please paste any applicable config files that you're using (e.g. .prettierrc or .stylelintrc files)

.prettierrc (none)

.stylelintrc.js
module.exports = {
  plugins: ["stylelint-declaration-strict-value"],
  extends: [
    "stylelint-config-standard",
    "stylelint-config-recommended-scss",
    "stylelint-prettier/recommended",
  ],
  rules: {
    "alpha-value-notation": null,
    "color-function-notation": null,
    "declaration-empty-line-before": null,
    "declaration-no-important": true,
    "import-notation": null,
    "max-nesting-depth": 1,
    "no-empty-source": null,
    "no-invalid-position-at-import-rule": null,
    "property-no-unknown": [
      true,
      {
        // Allow property used for css-fonts-4 variable fonts
        ignoreProperties: ["font-named-instance"],
      },
    ],
    "scale-unlimited/declaration-strict-value": [
      "/color/",
      {
        disableFix: true,
        ignoreValues: [
          "currentcolor",
          "inherit",
          "initial",
          "transparent",
          "unset",
        ],
      },
    ],
    "scss/at-function-pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
    "scss/at-mixin-pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
    "scss/dollar-variable-pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
    "scss/no-global-function-names": null,
    "scss/no-duplicate-dollar-variables": true,
    "scss/selector-no-redundant-nesting-selector": true,
    "selector-class-pattern": [
      // classes must be in BEM form, like this:
      // my-component
      // my-component--variant
      // my-component__element
      // my-component__element--variant
      // my-component__long-element-name
      // my-component__long-element-name--variant
      "^[a-z]+(-[a-z]+)*(__[a-z]+(-[a-z]+)*)?(--[a-z]+(-[a-z]+)*)*$",
      {
        resolveNestedSelectors: true,
        message:
          "Classes must be in BEM form like `my-component__element--variant`",
      },
    ],
    "selector-max-compound-selectors": 2,
    "selector-max-id": 0,
    "selector-no-qualifying-type": true,
  },
};

What source code are you linting?

.scss files

What did you expect to happen?

I expected stylelint to run without errors.

What actually happened?

TypeError: Cannot read properties of null (reading 'plugins')
    at node_modules/stylelint-prettier/stylelint-prettier.js:59:29
    at async Promise.all (index 0)
    at async Promise.all (index 20)
    at async lintSource (node_modules/stylelint/lib/lintSource.js:110:2)
    at async node_modules/stylelint/lib/standalone.js:211:27
    at async Promise.all (index 0)
    at async standalone (node_modules/stylelint/lib/standalone.js:254:22)

Thanks for the report. I've shipped the fix in 4.0.2.