Giter VIP home page Giter VIP logo

vscode-stylelint's Introduction

vscode-stylelint

Testing Linting

The official Visual Studio Code extension for Stylelint

Screenshot of Stylelint errors displayed in VS Code

Notice: 1.x of this extension has breaking changes from 0.x versions, including, but not limited to, changes to which documents are linted by default. See the migration section for more information.

Table of Contents

Installation

  1. Execute the Extensions: Install Extensions command from the Command Palette.
  2. Type @id:stylelint.vscode-stylelint into the search form and install the topmost one.

The extension first looks for a copy of Stylelint installed in the open workspace folder, then for a globally installed version if it can't find one. If neither can be found, it will not lint any documents.

Read the extension installation guide for more details.

Disable VS Code's Built-In Linters (optional)

To prevent both VS Code's built-in linters and Stylelint from reporting the same errors, you can disable the built-in linters in either the user or workspace settings for the languages you intend to use in your workspace.

Screenshot of duplicate error messages

An example of duplicate error messages emitted by both the built-in linter and vscode-stylelint.

For example, the following entries in .vscode/settings.json would disable the built-in CSS, Less, and SCSS linters:

"css.validate": false,
"less.validate": false,
"scss.validate": false

Usage

See the Stylelint getting started guide for more information.

Once you create a Stylelint configuration file or configure the Stylelint extension's settings, Stylelint will automatically validate CSS and PostCSS documents (those with language identifiers css and postcss, respectively).

Screenshot of UI to select a language identifier

You can see or change the current document's language in the bottom-right corner of the editor window.

Migrating from vscode-stylelint 0.x/Stylelint 13.x

⚠️ Stylelint 13.x and Prior is No Longer Supported

See also: Stylelint 14 migration guide

vscode-stylelint 1.x expects to use Stylelint 14 at minimum. Usage with prior versions of Stylelint is no longer supported. While older versions may continue to work for a while, you may encounter unexpected behaviour. You should upgrade your copy of Stylelint to version 14 or later for the best experience.

The syntax and configOverrides options have been removed from Stylelint 14 and this extension. See the following section for information on how to use different syntaxes.

⚠️ Stylelint is No Longer Bundled

Unlike 0.x, 1.x no longer provides a copy of Stylelint bundled with the extension. Bundling Stylelint brought up many unwanted side effects and significantly increased the extension's size.

Starting with 1.x, vscode-stylelint will depend on having a copy of Stylelint installed in the open workspace (recommended) or globally (not recommended). If the extension doesn't seem to be linting any documents, make sure you have Stylelint installed.

⚠️ Only CSS and PostCSS are Validated by Default

The 0.x versions of this extension, which used Stylelint 13.x and prior, supported validating many different languages out of the box without any additional configuration. However, this added a lot of complexity and resulted in many cases of unwanted or unexpected behaviour.

In current versions of the extension, the extension only supports validating CSS and PostCSS out of the box and requires additional configuration to validate other languages. You will need to:

  1. Install the PostCSS syntax for the language you want to validate into your workspace, e.g. postcss-scss.

  2. Configure Stylelint to use the syntax by providing the module name in the customSyntax option using overrides (or use the corresponding option in this extension's settings).

    Example Stylelint config:

    module.exports = {
      overrides: [
        {
          files: ["**/*.scss"],
          customSyntax: "postcss-scss"
        }
      ]
    };
  3. Add the language identifiers for the documents you want to validate to the extension's workspace or user settings using the stylelint.validate option.

    Example VS Code config:

    {
      "stylelint.validate": ["css", "scss"]
    }

Extension Settings

Though relying on a Stylelint configuration file in your project is highly recommended, you can instead use the following extension settings:

stylelint.enable

Type: boolean
Default: true

Controls whether this extension is enabled or not.

stylelint.config

Type: Object
Default: null

Sets the Stylelint config option. Note that when this option is enabled, Stylelint doesn't load configuration files.

stylelint.configFile

Type: string
Default: ""

Sets the Stylelint configFile option. Path to a JSON, YAML, or JS file that contains your configuration object. Use this option if you don't want Stylelint to search for a configuration file.

stylelint.configBasedir

Type: string
Default: ""

Sets the Stylelint configBasedir option. The path to the directory to which relative paths defining "extends" and "plugins" are relative. Only necessary if these values are relative paths.

stylelint.customSyntax

Type: string
Default: ""

Sets the Stylelint customSyntax option, which points to a PostCSS syntax module. Must be either the package name or an absolute path to the module.

e.g.

  "stylelint.customSyntax": "sugarss"

You can use ${workspaceFolder} to refer to the folder opened in VS Code.

e.g.

  "stylelint.customSyntax": "${workspaceFolder}/custom-syntax.js"

stylelint.reportDescriptionlessDisables

Type: boolean
Default: false

Sets the Stylelint reportDescriptionlessDisables option. If true, Stylelint reports stylelint-disable comments without a description.

stylelint.ignoreDisables

Type: boolean
Default: false

Sets the Stylelint ignoreDisables option. If true, Stylelint ignores stylelint-disable (e.g. /* stylelint-disable block-no-empty */) comments.

stylelint.reportNeedlessDisables

Type: boolean
Default: false

Sets the Stylelint reportNeedlessDisables option. If true, Stylelint reports errors for stylelint-disable comments that are not blocking a lint warning.

stylelint.reportInvalidScopeDisables

Type: boolean
Default: false

Sets the Stylelint reportInvalidScopeDisables option. If true, Stylelint reports errors for stylelint-disable comments referring to rules that don't exist within the configuration object.

stylelint.validate

Type: string[]
Default: ["css", "postcss"]

An array of language identifiers specifying which files to validate.

stylelint.stylelintPath

Type: string
Default: ""

Used to supply a custom path to the Stylelint module.

stylelint.packageManager

Type: "npm" | "yarn" | "pnpm"
Default: "npm"

Controls the package manager to be used to resolve the Stylelint library. This setting only has an effect if the Stylelint library is resolved globally. Valid values are "npm" or "yarn" or "pnpm".

stylelint.snippet

Type: string[]
Default: ["css", "postcss"]

An array of language identifiers specifying which files to enable snippets for.

editor.codeActionsOnSave

This extension provides an action that you can use with VS Code's editor.codeActionsOnSave setting. If provided a source.fixAll.stylelint property set to explicit, all auto-fixable Stylelint errors will be fixed on save.

  "editor.codeActionsOnSave": {
    "source.fixAll.stylelint": "explicit"
  }

The following turns on auto fix for all providers, not just Stylelint:

  "editor.codeActionsOnSave": {
    "source.fixAll": "explicit"
  }

You can also selectively disable Stylelint:

  "editor.codeActionsOnSave": {
    "source.fixAll": "explicit",
    "source.fixAll.stylelint": "never"
  }

You can also selectively enable and disable specific languages using VS Code's language-scoped settings. For example, to disable codeActionsOnSave for HTML files, use the following:

  "[html]": {
    "editor.codeActionsOnSave": {
      "source.fixAll.stylelint": "never"
    }
  }

Commands

This extension contributes the following commands to the command palette:

  • Fix all auto-fixable problems: applies Stylelint resolutions to all automatically fixable problems.

Troubleshooting

vscode-stylelint writes logs to the VS Code output panel:

Screenshot of the Output window

You can enable more verbose log output by running VS Code with the NODE_ENV environment variable set to development. You can do this on macOS and *nix by running:

NODE_ENV=development code

And on Windows by running:

cmd /C "set NODE_ENV=development&&code"

Contributors

Stylelint is maintained by volunteers. Without the code contributions from all these fantastic people, Stylelint would not exist. Become a contributor.

Sponsors

Thank you to all our sponsors! Become a sponsor.

Backers

Thank you to all our backers! Become a backer.

Licence

MIT

vscode-stylelint's People

Contributors

adalinesimonian avatar beeplin avatar bpscott avatar calme1709 avatar charlescrtr avatar coliff avatar dependabot-preview[bot] avatar dependabot[bot] avatar flying-sheep avatar germanfrelo avatar hudochenkov avatar iansoper avatar jeddy3 avatar kaisermann avatar karlhorky avatar kizu avatar lostintangent avatar masumsoft avatar mattxwang avatar mrmlnc avatar ntwb avatar orta avatar ota-meshi avatar patrickkunka avatar patsissons avatar rchl avatar remcohaszing avatar shinnn avatar thibaudcolas avatar ybiquitous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-stylelint's Issues

Versioning

I wonder why we skip versions?

0.51.0
0.60.0
0.70.0

Fix Cannot find module postcss-html/extract error

Clearly describe the bug

Open a markdown file (empty or with content) and receive an error.

What code is needed to reproduce the bug?

Just a markdown file.

What stylelint configuration is needed to reproduce the bug?

Looking at the trace, I don't think it matters, but I can provide my stylelint config if needed.

Which version of stylelint are you using?

13.2.0

How are you running stylelint: CLI, PostCSS plugin, Node.js API?

VSCode extension: https://github.com/stylelint/vscode-stylelint

What did you expect to happen?

With the old shinnn VSCode plugin, and version 11.0 of stylelint, I had no errors.

What actually happened (e.g. what warnings or errors did you get)?

VSCode reports the following error:

d:\MyProject\node_modules\postcss-markdown\extract.js - 
d:\MyProject\node_modules\postcss-syntax\processor.js - 
d:\MyProject\node_modules\postcss-syntax\parse.js - 
d:\MyProject\node_modules\postcss-syntax\index.js - 
d:\MyProject\node_modules\stylelint\lib\getPostcssResult.js - 
d:\MyProject\node_modules\stylelint\lib\createStylelint.js - 
d:\MyProject\node_modules\stylelint\lib\index.js - 
c:\Users\username\.vscode\extensions\stylelint.vscode-stylelint-0.83.0\lib\stylelint-vscode\index.js - 
c:\Users\username\.vscode\extensions\stylelint.vscode-stylelint-0.83.0\server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:627:15)
at Function.Module._load (internal/modules/cjs/loader.js:531:27)
at Module.require (internal/modules/cjs/loader.js:685:19)
at require (internal/modules/cjs/helpers.js:16:16)
at mdParser (d:\MyProject\node_modules\postcss-markdown\extract.js:9:12)
at processor (d:\MyProject\node_modules\postcss-syntax\processor.js:25:43)
at Object.parse (d:\MyProject\node_modules\postcss-syntax\parse.js:25:10)
at new LazyResult (d:\MyProject\node_modules\postcss\lib\lazy-result.js:60:16)
at d:\MyProject\node_modules\stylelint\lib\getPostcssResult.js:123:19

Source: stylelint (Extension)

Edit: Might this issue make more sense in the extension's repository?

Install instructions are no longer correct

README.md recommends:

Type @sort:installs stylelint into the search form and install the topmost one.

Unfortunately, with the extension handover this is no longer true:

image

One option would be to recommend users explicitly search for the exact extension name with the author prefix: thibaudcolas.stylelint

image

Incidentally, it might be nice to add a warning banner at the top of the readme informing users that they'll need to uninstall the old extension and install this new one to receive upgrades -- otherwise they'll be stuck on the old extension (which has been removed from the marketplace) forever.

Add code action to show link to rule documentation

Describe the issue. Is it a bug or a feature request (new rule, new option, etc.)?

A new Feature where you get the link to the rule page.
Eg. to https://stylelint.io/user-guide/rules/no-descending-specificity

Which rule, if any, is this issue related to?

#39 (shows the how prettier solved this)

What CSS is needed to reproduce this issue?

Any warning/error.

What stylelint configuration is needed to reproduce this issue?

Any

Which version of stylelint are you using?

13.1.0

How are you running stylelint: CLI, PostCSS plugin, Node API?

(not that it matters) CLI with stylelint **/*.scss

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

No

What did you expect to happen?

Show a lint to the rule that applies, similar to the MDN links in HTML:

image

What actually happened (e.g. what warnings or errors you are getting)?

Does not apply to feature request.

postcss error

Clearly describe the bug

An error occured when I opened a project in WSL

[stylelint.vscode-stylelint]: Unknown language in contributes.vscode-stylelint.language. Provided value: postcss

What code is needed to reproduce this issue?

Not sure, the project does not use stylelint

What vscode-stylelint configuration is needed to reproduce the bug?

n/a

Is this issue related to autofix? (editor.codeActionsOnSave)

No

Which version of vscode-stylelint are you using?

0.83.0

Which version of stylelint are you using?

n/a

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

n/a

What did you expect to happen?

No error

What actually happened (e.g. what warnings or errors you are getting)?

error

stylelint lint Commonjs JavaScript file (.cjs file)

  • install stylelint.vscode-stylelint extension
  • touch a.cjs file
  • add below content into file
module.exports = {
  'accessor-pairs': [
    'error',
    {
      setWithoutGet: true,
      getWithoutSet: false,
    },
  ],
};

it show error:

{
	"resource": "/Users/myhome/myproject/a.cjs",
	"owner": "stylelint",
	"code": "CssSyntaxError",
	"severity": 8,
	"message": "Unknown word (CssSyntaxError)",
	"source": "stylelint",
	"startLineNumber": 5,
	"startColumn": 7,
	"endLineNumber": 5,
	"endColumn": 7
}

error will disappear if rename file from a.cjs into a.js.

Support for options available in CLI

stylelint has options available via CLI.
I want to support the following options:

  • #117 --config-basedir
  • #119 --syntax
  • #42 --custom-syntax
  • #118 --ignore-disables
  • #70 --report-needless-disables (If true, display markers at reported locations.#39)
  • #114 --report-invalid-scope-disables (If true, display markers at reported locations.#39)

Remove the stylelint dependency

This is a follow up to #26 where support was added to use the locally installed version of stylelint in a repo/folders node_modules folder.

Unbundling the stylelint version from this extension will be beneficial in allowing projects to use whatever version of stylelint they choose.

It will also lessen the maintenance burden on having to have this extension updated and published whenever there is a new stylelint release.

We should ensure that the extension includes tests to support local and global installs of stylelint and works with npm, Yarn, and pnpm.

The stylelint server crashed 5 times in the last 3 minutes. The server will not be restarted.

description

When install stylelint globally, and set stylelint.stylelintPath to the global path, stylelint server crashes when vscode starts.

info

This is the vscode version info.

Version: 1.44.0
Commit: 2aae1f26c72891c399f860409176fe435a154b13
Date: 2020-04-08T08:23:56.137Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.4.0

What vscode-stylelint configuration is needed to reproduce the bug?

  "stylelint.enable": true,
  "stylelint.stylelintPath": "/Users/username/.nvm/versions/node/v14.0.0/bin/stylelint",
  "editor.codeActionsOnSave": { "source.fixAll": true },

Is this issue related to autofix? (editor.codeActionsOnSave)

No.

Which version of vscode-stylelint are you using?

0.84.0

Which version of stylelint are you using?

13.3.3

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

no

What did you expect to happen?

globally installed stylelint should work since configuration item stylelint.stylelintPath has been provided.

What actually happened (e.g. what warnings or errors you are getting)?

vscode 'official' extension crashed

This issue has nothing to do with style lint

Document this as official extension in README

This repo was originally published at https://marketplace.visualstudio.com/items?itemName=thibaudcolas.stylelint, but has since moved to https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint.

What's going to happen to the extension published in the thibaudcolas namespace? Shall it be deleted? Deletion is be a bit of short-term pain - people wondering where their extension went - for long term consolidation around stylelint.vscode-stylelint.

Autofix fails with `"source.fixAll.stylelint": true`

Using the following config *.js files are saved with unexpected results:

	"css.validate": false,
	"less.validate": false,
	"scss.validate": false,
	"editor.formatOnSave": false,
	"editor.codeActionsOnSave": {
		"source.fixAll.eslint": false,
		"source.fixAll.stylelint": true
	},
	"files.autoSaveDelay": 500,
	"stylelint.packageManager": "npm",
	"prettier.disableLanguages": [
		".foo"
	],
	"prettier.ignorePath": ".prettierignorerc",
    "stylelint.ignoreDisables": true

Screen Recording 2020-02-16 at 4 38 34 pm

Changing "source.fixAll.stylelint": true to false resolves the issue


Note: I'm using master so it may be due to local file changes, will update this if that is the case

Autofix clears files

Newly released version of extension wipes out file contents on save.

Reproduce is rather straightforward:

  1. .vscode/settings.json with following contents:
{
  "editor.codeActionsOnSave": {
    "source.fixAll.stylelint": true
  }
}
  1. Add file to folder, for instance index.ts:
export default () => {
    console.log("Hello world")
}
  1. Hit "Save".

Expected: File contents saved successfully.
Actual: File is saved, but contents are gone.

Happens for other files as well, e.g. .html and .css. stylelint.vscode-stylelint is a single enabled extension, so definitely it's not a conflict with other extensions. Also no errors/warnings are displayed in Output-Extensions.

Extension version: 0.70.0
VS Code version: 1.41.1

"Undefined rule unicode-bom" prevents linting

obraz

This one prevents any linting in VSCode. The same happened with original extension from @shinnn . The problem must be with the extension because stylelint detects unicode-bom rule as expected:

obraz

To reproduce:

  1. NPM local packages:
"stylelint": "^12.0.0",
"stylelint-config-twbs-bootstrap": "^1.0.0",
  1. .stylelintrc.json:
{
    "extends": "stylelint-config-twbs-bootstrap/scss"
}

or simple rule without bootstrap config:

{
    "rules": {
        "unicode-bom": "never"
    }
}
  1. vscode-stylelint v.0.51.0

Replace inlined packages/modules

@thibaudcolas Some questions if I may please:

  1. Can I ask what the indented purpose of e9a6894 to "Inline stylelint-vscode into this repository" in lib/stylelint-vscode? Was it to just include an archive of the original repo?

  2. Similar reasoning I guess behind adding this also? We do not know if or when these modules will also be deleted from npm?
    • Inline stylelint-warning-to-vscode-diagnostic into this repository
    • Inline array-to-sentence into this repository
    • Inline array-to-error into this repository
    • Inline inspect-with-kind into this repository
    • Inline find-pkg-dir into this repository


So the packages from 2. are being used for the nyc tests

Each test passes except for the npm run test:inspect-with-kind test added in 49c9163 and updated in 516035a

I'm guessing we should begin replacing these inline modules with alternate modules, for example swapping out find-pkg-dir for find-pkg or one of @sindresorhus pkg-* packages. And similar for the the other packages

command 'stylelint.executeAutofix' not found

Clearly describe the bug

When I install stylelint vs code, I would expect the .scss to be formatted on auto-format.

What's actually happening: command 'stylelint.executeAutofix' not found error shown in vs code notification

What code is needed to reproduce this issue?

e.g.

ul {
  font-weight:normal;
}

->

ul {
  font-weight: normal;
}

What vscode-stylelint configuration is needed to reproduce the bug?

(updated 4/13/20)

{
  "eslint.alwaysShowStatus": true,
  "eslint.format.enable": true,
  "eslint.lintTask.enable": true,
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll": true,
    "source.fixAll.stylelint": true
  },
  "stylelint.enable": true,
  "css.validate": false,
  "scss.validate": false
}

.stylelintrc.json

{
  "extends": "stylelint-config-sass-guidelines"
}

Is this issue related to autofix? (editor.codeActionsOnSave)

Yes

Which version of vscode-stylelint are you using?

0.84.0

Which version of stylelint are you using?

[email protected]

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

Not related.

Using a shared .stylelintrc.json not in current working directory in user settings of vscode

What is the problem you're trying to solve?

Say I put the .stylelintrc.json in a shareable-config file (all the dependency and required node_modules are there, and this configuration is not in my current working directory) so I can let all my projects use the same version of stylelint and related dependency.

Is there any chance to use something like ‘a string of path’ to replace the vscode settings.json stylelint.config replace by a .stylelintrc.json file which is not in current working directory

What solution would you like to see?

(in vscode user settings.json)

{ "stylelint.config”: “../code/my-sharable-stylelint/.stylelintrc.json” }

Cannot read property 'buildError' of undefined

Clearly describe the bug

I don't know why this extension will check the TypeScript .d.ts file and throw this error.

Which rule, if any, is the bug related to?

stylelint-error

What configuration is needed to reproduce the bug?

{
    "extends": ["stylelint-config-standard", "stylelint-config-rational-order", "stylelint-config-prettier"],
    "plugins": ["stylelint-order", "stylelint-declaration-block-no-ignored-properties"],
    "rules": {
        "comment-empty-line-before": null,
        "declaration-empty-line-before": null,
        "function-name-case": "lower",
        "no-descending-specificity": null,
        "no-invalid-double-slash-comments": null
    },
    "ignoreFiles": ["node_modules/**/*", "src/assets/**/*", "dist/**/*"]
}

Which version of stylelint are you using?

"stylelint": "^13.2.0",

What did you expect to happen?

No error notification

repository: react-typescript-boilerplate

How to fix?

I can fix it by adding .d.ts files to ignore array:

"ignoreFiles": ["node_modules/**/*", "src/assets/**/*", "dist/**/*", "**/typings/**/*"]

Re-publish extension packages to `npmjs.com`

The following 3 npm packages are published to npm, and have not been updated since this extension was moved to the @stylelint organization:

Options:

  1. Contact with @shinnn to get access to update and publish
  2. Contact npmjs.com and request access if 1. is not possible
  3. If 1. or 2. are not possible republish the packages with alternate names

Inform the user that documents containing disable comments can't be autofixed

Clearly describe the bug

After using /* stylelint-enable */ and /* stylelint-disable */ for couple lines, autofix does not work for the entire document

What code is needed to reproduce this issue?

/* stylelint-disable */ 
div {
	background-attachment: fixed;
}
/* stylelint-enable */

span            {
	background-attachment: fixed;
   }

obraz

What vscode-stylelint configuration is needed to reproduce the bug?

"stylelint.config": {
	"rules": {
		"block-no-empty": true,
		"color-no-invalid-hex": true,
		"comment-no-empty": true,
		"declaration-block-no-duplicate-properties": [
			true,
			{
				"ignore": [
					"consecutive-duplicates-with-different-values"
				]
			}
		],
		"declaration-block-no-shorthand-property-overrides": true,
		"font-family-no-duplicate-names": true,
		"font-family-no-missing-generic-family-keyword": true,
		"function-calc-no-invalid": true,
		"function-calc-no-unspaced-operator": true,
		"function-linear-gradient-no-nonstandard-direction": true,
		"keyframe-declaration-no-important": true,
		"media-feature-name-no-unknown": true,
		"no-descending-specificity": true,
		"no-duplicate-at-import-rules": true,
		"no-duplicate-selectors": true,
		"no-extra-semicolons": true,
		"no-invalid-double-slash-comments": true,
		"property-no-unknown": true,
		"selector-pseudo-class-no-unknown": true,
		"selector-pseudo-element-no-unknown": true,
		"selector-type-no-unknown": true,
		"string-no-newline": true,
		"unit-no-unknown": true,
		"at-rule-empty-line-before": [
			"always",
			{
				"except": [
					"blockless-after-same-name-blockless",
					"first-nested"
				],
				"ignore": [
					"after-comment"
				]
			}
		],
		"at-rule-name-case": "lower",
		"at-rule-name-space-after": "always-single-line",
		"at-rule-semicolon-newline-after": "always",
		"block-closing-brace-empty-line-before": "never",
		"block-closing-brace-newline-after": "always",
		"block-closing-brace-newline-before": "always-multi-line",
		"block-closing-brace-space-before": "always-single-line",
		"block-opening-brace-newline-after": "always-multi-line",
		"block-opening-brace-space-after": "always-single-line",
		"block-opening-brace-space-before": "always",
		"color-hex-case": "lower",
		"color-hex-length": "short",
		"comment-empty-line-before": [
			"always",
			{
				"except": [
					"first-nested"
				],
				"ignore": [
					"stylelint-commands"
				]
			}
		],
		"comment-whitespace-inside": "always",
		"custom-property-empty-line-before": [
			"always",
			{
				"except": [
					"after-custom-property",
					"first-nested"
				],
				"ignore": [
					"after-comment",
					"inside-single-line-block"
				]
			}
		],
		"declaration-bang-space-after": "never",
		"declaration-bang-space-before": "always",
		"declaration-block-semicolon-newline-after": "always-multi-line",
		"declaration-block-semicolon-space-after": "always-single-line",
		"declaration-block-semicolon-space-before": "never",
		"declaration-block-single-line-max-declarations": 1,
		"declaration-block-trailing-semicolon": "always",
		"declaration-colon-newline-after": "always-multi-line",
		"declaration-colon-space-after": "always-single-line",
		"declaration-colon-space-before": "never",
		"declaration-empty-line-before": [
			"always",
			{
				"except": [
					"after-declaration",
					"first-nested"
				],
				"ignore": [
					"after-comment",
					"inside-single-line-block"
				]
			}
		],
		"function-comma-newline-after": "always-multi-line",
		"function-comma-space-after": "always-single-line",
		"function-comma-space-before": "never",
		"function-max-empty-lines": 0,
		"function-name-case": "lower",
		"function-parentheses-newline-inside": "always-multi-line",
		"function-parentheses-space-inside": "never-single-line",
		"function-whitespace-after": "always",
		"indentation": "tab",
		"length-zero-no-unit": true,
		"max-empty-lines": 1,
		"media-feature-colon-space-after": "always",
		"media-feature-colon-space-before": "never",
		"media-feature-name-case": "lower",
		"media-feature-parentheses-space-inside": "never",
		"media-feature-range-operator-space-after": "always",
		"media-feature-range-operator-space-before": "always",
		"media-query-list-comma-newline-after": "always-multi-line",
		"media-query-list-comma-space-after": "always-single-line",
		"media-query-list-comma-space-before": "never",
		"no-eol-whitespace": true,
		"no-missing-end-of-source-newline": true,
		"number-leading-zero": "always",
		"number-no-trailing-zeros": true,
		"property-case": "lower",
		"rule-empty-line-before": [
			"always-multi-line",
			{
				"except": [
					"first-nested"
				],
				"ignore": [
					"after-comment"
				]
			}
		],
		"selector-attribute-brackets-space-inside": "never",
		"selector-attribute-operator-space-after": "never",
		"selector-attribute-operator-space-before": "never",
		"selector-combinator-space-after": "always",
		"selector-combinator-space-before": "always",
		"selector-descendant-combinator-no-non-space": true,
		"selector-list-comma-newline-after": "always",
		"selector-list-comma-space-before": "never",
		"selector-max-empty-lines": 0,
		"selector-pseudo-class-case": "lower",
		"selector-pseudo-class-parentheses-space-inside": "never",
		"selector-pseudo-element-case": "lower",
		"selector-pseudo-element-colon-notation": "double",
		"selector-type-case": "lower",
		"unit-case": "lower",
		"value-keyword-case": "lower",
		"value-list-comma-newline-after": "always-multi-line",
		"value-list-comma-space-after": "always-single-line",
		"value-list-comma-space-before": "never",
		"value-list-max-empty-lines": 0
	}
}

Is this issue related to autofix?

"Yes" (Fix all autofixable Problems)

Which version of vscode-stylelint are you using?

latest release

Which version of stylelint are you using?

I'm using a stylelint included in your plugin

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

"Yes, it's related to SCSS, CSS"

What did you expect to happen?

"Autofix should working"

Support opting-out for languages

Describe the issue. Is it a bug or a feature request (new rule, new option, etc.)?

I have a basic VSCode config that formats files on save with Prettier and fixes files on save with ESLint.

"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
  "source.fixAll.eslint": true
}

This works fine, but when I add "source.fixAll.stylelint": true or just "source.fixAll": true, VSCode stops formatting and fixing files on save altogether, and not just CSS files!

In order to get things working again, I have to add "editor.codeActionsOnSaveTimeout": 5000. It seems that stylelint's fixer blows past VSCode's default budget of 750 ms.

What's most surprising to me is that it affects non-CSS files. Sure, I can wrap the option with "[css]": {...}, but this is far from ideal... and it shouldn't take so long on CSS files either anyway.

Environment

  • Windows 10
  • vscode-stylelint: 0.80.0
  • stylelint: 13.0.0

Vscode Editor Error Notify

TypeError: Cannot read property 'expression' of null at NodePath._getKey (MY_PROJECT_PATH/node_modules/@babel/traverse/lib/path/family.js:178:25) at NodePath.get

Add "stylelint.validate" option

What is the problem you're trying to solve?

I don't want to use stylelint in markdown, but there is no way to turn it off in markdown.
image

What solution would you like to see?

I think we need an option similar to "eslint.validate"

Formatting Style Blocks in Vue Single-File-Components?

Now that you've started re-working on your VS Code extension, any chance of supporting style blocks in Vue SFCs (along with auto-fix on save)?

ESLint VS Code extension v2.0.4 was just released and I was able to dump Prettier, as the new ESLint works as a formatter also!

However I may still need Prettier for formatting these styles. While Vetur could do that, it also relies on Prettier...

PS. ESLint 2 finally supports this new "editor.codeActionsOnSave" infrastructure, as requested in #13

Add autoFix on save

This was added in the hex-ci fork in hex-ci/vscode-stylelint-plus@66dbb72?w=1 (linking to a diff with suppressed whitespace as there's a bunch of noisy reformatting in there too), where its option name autoFixOnSave mimics the usage of the current vscode-eslint plugin.

This probably the most desired missing feature of shinnn's original work and was the reason the hex-ci fork exists. It'd be great to have autofixing in extension as it seems like this is about to become the official stylelint extension.

This would let me update the docs in the prettier vscode plugin to make it recommend this plugin once it gets published.


Longer term I note that the eslint plugin is on the cusp of releasing a v2 which changes how it registers autofixing - the autoFixOnSave option will be removed and replaced with a hook into vscode's native editor.codeActionsOnSave option (see its README). Eventually it's probably worth reworking the plugin to mimic how vscode-eslint is architected to allow for this autofixing and to ensure the plugin uses the locally installed version of stylelint if available, but that rework can be punted down the road for a while, and a stopgap autofix would be great.

Support autofix on autoSave

The vscode files.autoSave: "afterDelay" option in settings.json is not fixing stylelint issues when these vscode-stylelint settings are also applied in settings.json:

  "editor.codeActionsOnSave": {
    "source.fixAll.stylelint": true
  }

Which version of stylelint are you using?

0.70.0

How are you running stylelint: CLI, PostCSS plugin, Node API?

vscode-stylelint

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

verified I was able to reproduce in both scss and css

What did you expect to happen?

When creating an error in an scss or css file that can be auto fixed by vscode-stylelint (such as omitting a space in a rule background:red;), the file is autosaved successfully and the errors are fixed without having to save manually via files.autoSave: "afterDelay".

What actually happened (e.g. what warnings or errors you are getting)?

When creating an error in an scss or css file that can be auto fixed by vscode-stylelint (such as omitting a space in a rule background:red;), the file is autosaved successfully, but the error will not be fixed unless the user saves the file manually.

Add code action for fixing / disabling issues

VSCode supports "code actions" on particular lines, which appear as little light bulbs on hover.

The ESLint extension uses them to expose quick fixes for lines that contain a rule violations allowing the user to autofix the issue (if available), or to disable linting for that line by adding an eslint-disable-next-line [ruleName] comment above the rule.

For example in the following screenshot there is a violation of the prettier/prettier rule - the extra space after the }:

Screen Shot 2020-01-06 at 9 43 27 AM

It'd be neat if this extension could do the same for offering the option to add ignore comments to lines with violations

Option to ignore (exclude) minified files

Describe the issue. Is it a bug or a feature request (new rule, new option, etc.)?

Future request. I'm not sure it's a logical idea but maybe?

What CSS is needed to reproduce this issue?

Any minified css file

What stylelint configuration is needed to reproduce this issue?

https://github.com/stylelint/stylelint-config-standard
https://github.com/stylelint/stylelint-config-recommended

Which version of stylelint are you using?

obraz

How are you running stylelint: CLI, PostCSS plugin, Node API?

I just use your stylelint plugin in VSCode

What did you expect to happen?

No warnings to be flagged if it's minified file

autoFix removing all js/ts content on styled-components file

Clearly describe the bug

I'm trying to lint my code by using css in js with styled components, but when i save the file all the javascript code is removed and only remains the css code.

What code is needed to reproduce this issue?
.stylelintrc.json:

{
  "plugins": ["stylelint-prettier"],
  "rules": {
    "prettier/prettier": true,
    "rule-empty-line-before": "always",
    "order/properties-order": [
      [
        {
          "emptyLineBefore": "always",
          "order": "flexible",
          "properties": [
            "position",
            "top",
            "right",
            "bottom",
            "left",
            "z-index"
          ]
        },
        {
          "emptyLineBefore": "always",
          "order": "flexible",
          "properties": [
            "box-sizing",
            "float",
            "width",
            "height",
            "max-width",
            "max-height",
            "min-width",
            "min-height",
            "padding",
            "padding-top",
            "padding-right",
            "padding-bottom",
            "padding-left",
            "margin",
            "margin-top",
            "margin-right",
            "margin-bottom",
            "margin-left",
            "margin-collapse",
            "margin-top-collapse",
            "margin-right-collapse",
            "margin-bottom-collapse",
            "margin-left-collapse",
            "overflow",
            "overflow-x",
            "overflow-y",
            "clip",
            "clear"
          ]
        },
        {
          "emptyLineBefore": "always",
          "order": "flexible",
          "properties": [
            "display",
            "flex-flow",
            "flex-direction",
            "flex-wrap",
            "justify-content",
            "align-items",
            "align-content",
            "order",
            "flex",
            "flex-grow",
            "flex-shrink",
            "flex-basis",
            "align-self"
          ]
        },
        {
          "emptyLineBefore": "always",
          "order": "flexible",
          "properties": [
            "background",
            "background-attachment",
            "background-color",
            "background-image",
            "background-position",
            "background-repeat",
            "color",
            "cursor",
            "content",
            "font",
            "font-family",
            "font-size",
            "font-variant",
            "font-weight",
            "font-style",
            "letter-spacing",
            "line-height",
            "list-style",
            "list-style-image",
            "list-style-position",
            "list-style-type",
            "page-break-after",
            "page-break-before",
            "stroke-dasharray",
            "stroke-dashoffset",
            "stroke-width",
            "text-align",
            "text-decoration",
            "text-indent",
            "text-transform",
            "text-overflow",
            "text-justify",
            "visibility",
            "opacity",
            "white-space",
            "word-break",
            "word-spacing",
            "word-wrap"
          ]
        }
      ],
      { "unspecified": "bottom" }
    ]
  },
  "extends": ["stylelint-config-idiomatic-order"],
  "processors": ["stylelint-processor-styled-components"]
}

What vscode-stylelint configuration is needed to reproduce the bug?

"editor.codeActionsOnSave": {
  "source.fixAll.stylelint": true
}

Is this issue related to autofix? (editor.codeActionsOnSave)

e.g. "Yes"

Which version of vscode-stylelint are you using?

e.g. 0.84.0

Which version of stylelint are you using?

e.g. 13.2.0

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

e.g. "Yes, it's related to CSS in JS with styled-components."

What did you expect to happen?

e.g. "No code disappearing just lint the code"

What actually happened (e.g. what warnings or errors you are getting)?

styles.ts

import styled from 'styled-components';

export const Container = styled.div`
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;

  background: ${(props) => (props.color ? props.color : '#45f')};

  > h1 {
    color: #fff;
    font-size: 48px;
  }
`;

turns into

.a {
  position: relative;

  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;

  background: $dummyValue;

  > h1 {
    color: #fff;
    font-size: 48px;
  }
}

my project: https://github.com/efraim-andrade/stylelint-cra-test

[bug] auto fix will remove js/ts file content on save

Describe the issue. Is it a bug or a feature request (new rule, new option, etc.)?

autofix will clean the ts/js files.

Which rule, if any, is this issue related to?

with auto fix settings

"editor.codeActionsOnSave": {
        "source.fixAll": true,
    }

to reproduce this issue?

file: test.js (or test.ts)

const a = 1;

What stylelint configuration is needed to reproduce this issue?

e.g.

{
    "rules": {},
    "ignoreFiles": ["**/*.ts", "**/*.js"]
}

Which version of stylelint are you using?

stylelint: 12.0.1
stylelint.vscode-stylelint 0.80.0
vscode: 1.41.1

If there are errors that cannot auto-fixable, autofix will not work.

Clearly describe the bug

If there are errors that cannot auto-fixable, autofix will not work.

What CSS is needed to reproduce the bug?

unknown {
              width: 100%;
}

What configuration is needed to reproduce the bug?

{
  "rules": {
    "indentation": 2,
    "selector-type-no-unknown": true,
  }
}

Which version of stylelint are you using?

0.82.0

Does the bug relate to non-standard syntax (e.g. SCSS, Less etc.)?

css

What did you expect to happen?

The following CSS is output.

unknown {
  width: 100%;
}

What actually happened (e.g. what warnings or errors did you get)?

CSS did not change.

Upgrading stylelint-vscode

Hi! Glad to see this extension has been adopted from its previous owner and is seeing new development :)

One thing I'd love to see is an upgrade of stylelint-vscode (a confusingly-named dependency of this package, vscode-stylelint). It's how this extension bundles Stylelint proper -- and unfortunately it's what's caused this package to lag behind official Stylelint releases: the extension bundles Stylelint 9 (specifically this version, it seems).

In the long-term, I think it might be better to behave the same way as vscode-eslint and require a local or global installation of Stylelint rather than bundling one. In the interim, however, it would be really wonderful if we could bump that bundled Stylelint in stylelint-vscode since it no longer works with some newer rules and configs (for example, this config breaks this extension currently).

Unfortunately, it looks like the previous repo for stylelint-vscode got taken down in the handover, but I don't see it in the repo list for the Stylelint org or @thibaudcolas's profile... Does anyone have a clone of it handy?

Saving duplicates lines of code in Styled Component css literal object

Describe the issue. Is it a bug or a feature request (new rule, new option, etc.)?

I ran into a bug when saving a typescript file containing a css object, where the css block was duplicated.

Which rule, if any, is this issue related to?

This doesn't seem related to any specific rule, as far as I can tell.

What CSS is needed to reproduce this issue?

import { createGlobalStyle, css } from 'styled-components';

export default createGlobalStyle`
  ${props => css`
    html {
      height: 100%;

      body {
        display: flex;
        flex-direction: column;
        height: 100%;
        margin: 0;

        #root {
          background: radial-gradient(#282c34cc, #282c34);
          color: #e9e9e9;
          display: flex;
          font-family: sans-serif;
          height: 100%;
          justify-content: center;
          padding: 15px;
        }
      }
    }
  `}
`;

What stylelint configuration is needed to reproduce this issue?

I haven't configured stylelint so the default should reproduce this bug.

Which version of stylelint are you using?

0.81.0

How are you running stylelint: CLI, PostCSS plugin, Node API?

I just installed the extension - no config, not running it.

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

I don't think so (see above).

What did you expect to happen?

I expected the file to save.

What actually happened (e.g. what warnings or errors you are getting)?

The file saved, but duplicated the html block above.

"Cannot find module" when linting project in sub folder using browserslist

Clearly describe the bug

When the project being linted doesn't start at the root folder. So if it's in a sub folder called /frontend then I get Error: Cannot find module .... The root folder only have a .editorconfig file.
If I open VSCode from inside /frontend it works.

The module it cannot find is my @myorg/browserslist-config inside browserslist

# You can see what browsers were selected by your queries by running:
#   npx browserslist

extends @myorg/browserslist-config

The content of is @myorg/browserslist-config

const defaultOptions = [
  'last 2 Chrome major versions',
  'last 2 Edge major versions',
  'last 2 Safari major versions',
  'last 2 iOS major versions',
];

export = defaultOptions;

What code is needed to reproduce this issue?

Any style file. I opened a .less file

What vscode-stylelint configuration is needed to reproduce the bug?

My vscode-stylelint config is default. However I do have "source.fixAll.stylelint": true but doubt it's relevant.

Is this issue related to autofix? (editor.codeActionsOnSave)

No

Which version of vscode-stylelint are you using?

0.84.0

Which version of stylelint are you using?

13.2.0

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

No

What did you expect to happen?

I expected it to work as normal

What actually happened (e.g. what warnings or errors you are getting)?

The following error is shown in VSCode:

Error: Cannot find module '@myorg/browserslist-config' 
Require stack: 
- ~\Repos\MyProject\frontend\node_modules\browserslist\node.js 
- ~\Repos\MyProject\frontend\node_modules\browserslist\index.js
- ~\Repos\MyProject\frontend\node_modules\doiuse\lib\browsers.js
- ~\Repos\MyProject\frontend\node_modules\doiuse\lib\missing-support.js
- ~\Repos\MyProject\frontend\node_modules\doiuse\lib\doiuse.js
- ~\Repos\MyProject\frontend\node_modules\stylelint-no-unsupported-browser-features\lib\index.js
- ~\Repos\MyProject\frontend\node_modules\stylelint\lib\dynamicRequire.js
- ~\Repos\MyProject\frontend\node_modules\stylelint\lib\augmentConfig.js
- ~\Repos\MyProject\frontend\node_modules\stylelint\lib\createStylelint.js
- ~\Repos\MyProject\frontend\node_modules\stylelint\lib\index.js
- c:\Users\myuser\.vscode\extensions\stylelint.vscode-stylelint-0.84.0\lib\stylelint-vscode\index.js
- c:\Users\myuser\.vscode\extensions\stylelint.vscode-stylelint-0.84.0\server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:717:15)
    at Function.resolve (internal/modules/cjs/helpers.js:74:19)
    at Object.loadQueries (~\Repos\MyProject\frontend\node_modules\browserslist\node.js:158:35)
    at Function.select (~\Repos\MyProject\frontend\node_modules\browserslist\index.js:1095:26)
    at ~\Repos\MyProject\frontend\node_modules\browserslist\index.js:336:33
    at Array.reduce (<anonymous>)
    at resolve (~\Repos\MyProject\frontend\node_modules\browserslist\index.js:318:18)
    at browserslist (~\Repos\MyProject\frontend\node_modules\browserslist\index.js:442:21)
    at new BrowserSelection (~\Repos\MyProject\frontend\node_modules\doiuse\lib\browsers.js:6:18)
    at missingSupport (~\Repos\MyProject\frontend\node_modules\doiuse\lib\missing-support.js:74:20)

Replace snippets with completions

The snippets that stylelint offers in VScode are getting in the way of writing the code.

Whenever I try to write display on the scss the suggestions for / * stylelint-disable rule * / appear at the top and hinder me.

Is there any way I can disable these suggestions?

Thanks

Code getting duplicated when auto-formatting.

Hi. I'm using and LOVING this extension with styled-components in React Native. However, I recently ran into an issue with code getting duplicated.

Here's how to reproduce.

  1. Create a styled component containing React Native's Platform.select function.

2020-02-21_12h31_22

  1. Add the styled-components css function to enable syntax coloring.

2020-02-21_12h33_38

  1. Run stylelint's fix all fixable problems.

2020-02-21_12h35_25

Let me know what other details to provide. Thanks!

`source.fixAll.stylelint` bug

Reproduct step (not sure):

Update vscode settings, add

  "editor.codeActionsOnSave": {
    "source.fixAll.stylelint": true
  }

open a dir without stylelintrc (important), edit any js css file, when saving file, the whole file content get lost.

Fix stylelint with Yarn 2.

Just a heads up. The extension breaks when using Yarn 2 for package management. There is no longer a node_modules folder. Maybe the issue?

This is the error.

image

Unknown language in `contributes.vscode-stylelint.language`

Clearly describe the bug

After opening an empty VSCode instance, starting the output window and development tools, I noticed this error

What code is needed to reproduce this issue?,

You don't need any code to reproduce this problem

What vscode-stylelint configuration is needed to reproduce the bug?

Not applicable

Is this issue related to autofix? (editor.codeActionsOnSave)

Not applicable

Which version of vscode-stylelint are you using?

latest

Which version of stylelint are you using?

version included in vscode-styline

Does your issue relate to non-standard syntax (e.g. SCSS, nesting, etc.)?

Not applicable

What did you expect to happen?

Expects there will be no error

What actually happened (e.g. what warnings or errors you are getting)?

Adnotacja 2020-04-28 164349

Environment

Version: 1.44.2 (system setup)
Commit: ff915844119ce9485abfe8aa9076ec76b5300ddd
Date: 2020-04-16T16:36:23.138Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363

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.