linaria icon indicating copy to clipboard operation
linaria copied to clipboard

stylelint autofix doesn't work with linaria preprocess

Open hannahjin opened this issue 5 years ago • 1 comments

Environment

Description

Stylelint autofix doesn't work. It works when I remove 'linaria/stylelint-config' from the extended presets. command: npx stylelint "**/*.{tsx,css}" --fix Error:

Autofix is incompatible with processors and will be disabled. Are you sure you need a processor?
TypeError: Cannot read property 'stringify' of null
    at Root.toString (/Users/hannahjin/workspace/fork/repo/node_modules/postcss/lib/node.js:193:21)
    at /Users/hannahjin/workspace/fork/repo/node_modules/stylelint/lib/standalone.js:254:44
    at async Promise.all (index 0)

If I override the syntax to css-in-js for stylelint cli option npx stylelint "**/*.{tsx,css}" --syntax=css-in-js --fix, then I get Error:

Autofix is incompatible with processors and will be disabled. Are you sure you need a processor?

Reproducible Demo

stylelint.config.js

module.exports = {
  extends: ['stylelint-config-recommended', 'linaria/stylelint-config'],
  plugins: ['stylelint-high-performance-animation'],
  rules: {
    'color-hex-case': 'lower',
    'color-named': 'never',
    'declaration-block-no-shorthand-property-overrides': null,
    'font-weight-notation': 'numeric',
    'length-zero-no-unit': true,
    'selector-pseudo-class-no-unknown': [
      true,
      {
        ignorePseudoClasses: ['global'],
      },
    ],
    'plugin/no-low-performance-animation-properties': true,
  },
};

Tested against a dummy component like

import * as React from 'react';

import { css } from 'linaria';

const special = css`
  width: 100px;
  padding: 0px 4px; /*expects auofix */
  --webkit-box-sizing: border-box;

  :global() {
    font-weight: bold; /*expects error */
  }

  color: green; /*expects error */
  transition: color 200ms; /*expects error */
`;

export const TestComponent: React.FC = () => {
  return <div className={special}>Test</div>;
};

hannahjin avatar Aug 26 '20 05:08 hannahjin

Are there any plans to support Stylelint 15 and Stylelint 16? Our project currently uses these versions of Stylelint, and we are encountering compatibility issues with the current version of the package.

Additionally, the syntax package we have been working with @stylelint/postcss-css-in-js is now deprecated. We've tried using @linaria/postcss-linaria and the @linaria/stylelint-config-standard-linaria configuration, but we are experiencing issues with autofix.

Could anyone from linaria team provide any guidance or updates on these matters ?

msobiecki avatar Jul 05 '24 11:07 msobiecki