Giter VIP home page Giter VIP logo

Comments (24)

ddryo avatar ddryo commented on September 24, 2024 1

Yes, here is the setting data.

{
	"html.format.enable": false,
	"javascript.format.enable": false,
	"css.format.enable": false,
	"eslint.format.enable": false,
}

from vscode-stylelint.

ddryo avatar ddryo commented on September 24, 2024 1

This problem occurred when tested in an environment with only the following two files

pckage.json

{
	"name": "stylelint-test",
	"version": "1.0",
	"description": "",
	"main": "dist/index.js",
	"module": "dist/index.js",
	"scripts": {},
	"private": true,
	"license": "MIT",
	"devDependencies": {
		"stylelint": "^16.2.0"
	}
}

test.scss

.test {
	color: red;
	background-color: #fff;

	// background-color: blue;
	
}

// .hoge{
//     color:yellow;
// }

from vscode-stylelint.

ybiquitous avatar ybiquitous commented on September 24, 2024 1

@ddryo Thanks for the minimum reproduction. This problem seems specific to the VSCode extension, so I'll transfer this issue to https://github.com/stylelint/vscode-stylelint.

from vscode-stylelint.

ybiquitous avatar ybiquitous commented on September 24, 2024 1

So I think VS Code plugin and stylelint v16 are incompatible.

It may be correct. The main branch hasn't tested v16 yet:

"stylelint": "^15.10.2",

from vscode-stylelint.

ybiquitous avatar ybiquitous commented on September 24, 2024 1

FYI, I've just opened PR #492 to reduce confusion in README.

from vscode-stylelint.

ybiquitous avatar ybiquitous commented on September 24, 2024

@ddryo Thanks for the report with a real reproduction video. Probably, this is the same problem as #490.

from vscode-stylelint.

ybiquitous avatar ybiquitous commented on September 24, 2024

@ddryo Can you provide your .vscode/settings.json?

from vscode-stylelint.

ybiquitous avatar ybiquitous commented on September 24, 2024

Thanks for the quick response. But I cannot reproduce the problem for some reason. 🤔

Can you reproduce it on your console (CLI) instead? E.g.

npx stylelint test.scss --fix

from vscode-stylelint.

ddryo avatar ddryo commented on September 24, 2024

@ybiquitous
No, the command does not reproduce.

As explained at the beginning, this only occurs when auto-formatting with VS Code extensions.

from vscode-stylelint.

ddryo avatar ddryo commented on September 24, 2024

this plugin
https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint

from vscode-stylelint.

ddryo avatar ddryo commented on September 24, 2024

Come to think of it, I use pnpm.

node is v18.19.0.

from vscode-stylelint.

ddryo avatar ddryo commented on September 24, 2024

Additional verification.

It does not occur in stylelint v.15.11.0, it occurs starting from v.16.0.0.

from vscode-stylelint.

ybiquitous avatar ybiquitous commented on September 24, 2024

Just to confirm, does this problem happen without the config file (.stylelintrc.cjs)?

from vscode-stylelint.

ddryo avatar ddryo commented on September 24, 2024

No, this occurred with or without .stylelintrc.cjs.

from vscode-stylelint.

ddryo avatar ddryo commented on September 24, 2024

If I wanted to use stylelint-prettier v5 or later, I had to use stylelint v16 or later to get it to work, so I updated to stylelint v16 and encountered this bug.

At first I thought it might be due to prettier, but as I described above, it also occurred in an environment with only 2 files (counted before node_module installation). So I think VS Code plugin and stylelint v16 are incompatible.

from vscode-stylelint.

ybiquitous avatar ybiquitous commented on September 24, 2024

It's strange. I cannot reproduce this problem for now with the 2 files and node_modules. 🤔

from vscode-stylelint.

ybiquitous avatar ybiquitous commented on September 24, 2024

I think there is no problem if Stylelint and the extension are configured properly. The following files are in my environment:

stylelint.config.mjs:

export default {
  customSyntax: "postcss-scss",
  rules: {
    "function-name-case": "upper",
  },
};

package.json (need to run npm install):

{
  "devDependencies": {
    "postcss-scss": "^4.0.9",
    "stylelint": "^16.2.0"
  }
}

.vscode/settings.json:

{
  "stylelint.validate": ["css", "scss"],
  "editor.codeActionsOnSave": {
    "source.fixAll.stylelint": true
  }
}

test.scss:

a {
  color: calc(1 + 2);
}

When the file above is saved, it's automatically converted to:

- color: calc(1 + 2);
+ color: CALC(1 + 2);

Screen.Recording.2024-01-29.at.23.22.17.mov

from vscode-stylelint.

ddryo avatar ddryo commented on September 24, 2024

Thank you very much! However, the bug did occur...

CleanShot.2024-01-29.at.23.27.00-converted.mp4

from vscode-stylelint.

ybiquitous avatar ybiquitous commented on September 24, 2024

Hum, I cannot reproduce unintentionally inserted comments... 🤔

I wonder if .vscode/settings.json is different. Is your .vscode/settings.json the same as mine? ⬇️

{
  "stylelint.validate": ["css", "scss"],
  "editor.codeActionsOnSave": {
    "source.fixAll.stylelint": true
  }
}

from vscode-stylelint.

ddryo avatar ddryo commented on September 24, 2024

Yes. But for some reason, when I reload the project, the true part seems to be automatically switched to "explicit" as shown below.

{
  "stylelint.validate": ["css", "scss"],
  "editor.codeActionsOnSave": {
    "source.fixAll.stylelint": "explicit"
  }
}

from vscode-stylelint.

ybiquitous avatar ybiquitous commented on September 24, 2024

The behavior doesn't seem to change between true and explicit.
See https://code.visualstudio.com/updates/v1_85#_code-actions-on-save-and-auto

from vscode-stylelint.

ajiho avatar ajiho commented on September 24, 2024

在stylelint16.x中我也遇到了同样的问题,格式化的时候,它会无限的追加注释

"stylelint": "^16.2.0",
"stylelint-config-recess-order": "^4.4.0",
"stylelint-config-standard-scss": "^13.0.0"

from vscode-stylelint.

mashirozx avatar mashirozx commented on September 24, 2024

same here

from vscode-stylelint.

mashirozx avatar mashirozx commented on September 24, 2024
/** @type {import('stylelint').Config} */
const config = {
  // extends: require.resolve('@umijs/max/stylelint'),
  extends: 'stylelint-config-standard-less',
  // extends: 'stylelint-config-standard',
  // plugins: ['stylelint-order'],
  // customSyntax: 'postcss-less',
  rules: {
    'selector-class-pattern': [
      '^([a-z][a-z0-9]*)(-[a-z0-9]+)*[a-zA-Z0-9]*$',
      {
        message: 'kebab-case or camelCase only',
      },
    ],
    'selector-pseudo-class-no-unknown': [
      true,
      {
        ignorePseudoClasses: ['global', 'local'],
      },
    ],
    'shorthand-property-no-redundant-values': [
      true,
      {
        severity: 'warning',
      },
    ],
    'length-zero-no-unit': [
      true,
      {
        severity: 'warning',
      },
    ],
    'declaration-block-no-redundant-longhand-properties': null,
    // 'declaration-colon-space-after': 'always',
    // 'selector-combinator-space-after': 'always',
    // 'block-opening-brace-space-before': 'always',
    'rule-empty-line-before': [
      'always',
      {
        except: ['after-single-line-comment', 'first-nested'],
      },
    ],
    'color-function-notation': 'modern',
    // 'max-empty-lines': [
    //   1,
    //   {
    //     ignore: ['comments'],
    //   },
    // ],
    'media-query-no-invalid': null,
  },
};

module.exports = config;
"stylelint": "16.3.1",
"stylelint-config-standard": "36.0.0",
"stylelint-config-standard-less": "3.0.1",
"stylelint-order": "6.0.4",

from vscode-stylelint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.