Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stylelint 14 rules do not work because during traversal, node parent lang is undefined and not template-literal #1266

Open
ShayDavidson opened this issue Jun 29, 2023 · 1 comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized

Comments

@ShayDavidson
Copy link

ShayDavidson commented Jun 29, 2023

Environment

  • Node.js version: 18.16.0
  • Stylelint version: 14.16.1
  • @linaria/core version: 4.2.10
  • @linaria/stylelint-config-standard-linaria: 4.1.5
  • @linaria/postcss-linaria: 4.1.5

Stylelint config:

{
  "ignoreFiles": ["**/*"],
  "extends": ["@linaria/stylelint-config-standard-linaria"],
}

Description

I integrated stylelint into our Linaria project, yet figured that most of the rules do not work. e.g. property-no-unknown doesn't report unknown properties, yet string-quotes worked.

Considering I couldn't figure what's wrong, I literally debugged the property-no-unknown rule in Stylelint. This pointed me to this line in one of the checks: https://github.com/stylelint/stylelint/blob/main/lib/rules/property-no-unknown/index.js#L64

!isStandardSyntaxLang((parent.source).lang)

Yet the "parent" of my unknown property was the actual wrapping TS file my Linaria declaration is present in. e.g. if this is the traversed declaration in test.ts:

const ResponsiveWidth = css`
  test: 1px;
`;

Then the parent became:

import { css } from '@linaria/core';

Considering this is no CSS, stylelint fails to recognize this is CSS hence the check passes.

I guess I'm doing something wrong, but can't figure what. I thought it's related to PostCSS missing as an actual dependency, but even after installing it the rules fail to work.

@ShayDavidson ShayDavidson added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Jun 29, 2023
@github-actions github-actions bot removed the needs: triage 🏷 Issue needs to be checked and prioritized label Jun 29, 2023
@ShayDavidson ShayDavidson changed the title Stylelint 14 rules do not work because parent lang is undefined Stylelint 14 rules do not work because during traversal node parent lang is undefined Jun 29, 2023
@github-actions github-actions bot added needs: triage 🏷 Issue needs to be checked and prioritized and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Jun 29, 2023
@ShayDavidson ShayDavidson changed the title Stylelint 14 rules do not work because during traversal node parent lang is undefined Stylelint 14 rules do not work because during traversal, node parent lang is undefined Jun 29, 2023
@github-actions github-actions bot added needs: triage 🏷 Issue needs to be checked and prioritized and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Jun 29, 2023
@ShayDavidson
Copy link
Author

ShayDavidson commented Jun 30, 2023

I think this is the problem: stylelint/stylelint#6553

Stylelint 15 fixes the problem, and no longer checks the for parent rule. Once I upgraded, the problem got solved. However, the Linaria documentation and code doesn't seem to officially support Stylelint 15, so I can't be sure it actually works well.

@ShayDavidson ShayDavidson changed the title Stylelint 14 rules do not work because during traversal, node parent lang is undefined Stylelint 14 rules do not work because during traversal, node parent lang is undefined and not template-literal Jun 30, 2023
@github-actions github-actions bot added the needs: triage 🏷 Issue needs to be checked and prioritized label Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized
Projects
None yet
Development

No branches or pull requests

1 participant