stylelint: Error: Undefined rule null - stylelint

I just downloaded stylelint (npm install -g stylelint) on my Mac (OS X 10.12.6 - Sierra) and essentially copied and tried to modify the sample configuration file I found here.
I then tried to run it on a CSS file I had and, after fixing some typos in my ~/.stylelintrc file I end up with an error:
Error: Undefined rule null
at module.exports (/usr/local/lib/node_modules/stylelint/lib/utils/configurationError.js:8:28)
at Object.keys.forEach.ruleName (/usr/local/lib/node_modules/stylelint/lib/augmentConfig.js:302:13)
at Array.forEach (<anonymous>)
at normalizeAllRuleSettings (/usr/local/lib/node_modules/stylelint/lib/augmentConfig.js:297:29)
at augmentConfigBasic.then.then.then.augmentedConfig (/usr/local/lib/node_modules/stylelint/lib/augmentConfig.js:91:14)
at <anonymous>
I have no idea what to do to get past this - I do not want to try to debug the code (I have enough problem debugging my own code, I was hoping this tool would help me - I don't have the bandwidth to try to debug someone else's code)
Help?
Update: As per request - my ~/.stylelintrc file:
{
"rules": {
"at-rule-empty-line-before": "always",
"at-rule-name-case": "lower",
"at-rule-name-newline-after": "always-multi-line",
"at-rule-name-space-after": "always-single-line",
"at-rule-no-unknown": true,
"at-rule-no-vendor-prefix": true,
"at-rule-semicolon-newline-after": "always",
"at-rule-semicolon-space-before": "never",
"block-closing-brace-empty-line-before": "always-multi-line",
"block-closing-brace-newline-after": "always",
"block-closing-brace-newline-before": "always",
"block-closing-brace-space-after": ["never-single-line", "never-multi-line"],
"block-closing-brace-space-before": "never",
"block-no-empty": true,
"block-opening-brace-newline-after": "always",
"block-opening-brace-newline-before": ["never-single-line", "never-multi-line"],
"block-opening-brace-space-after": ["never-single-line", "never-multi-line"],
"block-opening-brace-space-before": "always",
"color-hex-case": "upper",
"color-hex-length": "long",
"color-named": "always-where-possible",
"color-no-hex": true,
"color-no-invalid-hex": true,
"comment-empty-line-before": "always",
"comment-no-empty": true,
"comment-whitespace-inside": "always",
"custom-property-empty-line-before": "always",
"declaration-bang-space-after": "always",
"declaration-bang-space-before": "always",
"declaration-block-no-duplicate-properties": true,
"declaration-block-no-redundant-longhand-properties": true,
"declaration-block-no-shorthand-property-overrides": true,
"declaration-block-semicolon-newline-after": "always",
"declaration-block-semicolon-newline-before": "always",
"declaration-block-semicolon-space-after": "always",
"declaration-block-semicolon-space-before": "never",
"declaration-block-single-line-max-declarations": 2,
"declaration-block-trailing-semicolon": "always",
"declaration-colon-newline-after": "always",
"declaration-colon-space-after": "always",
"declaration-colon-space-before": "never",
"declaration-empty-line-before": "always",
"declaration-no-important": true,
"declaration-property-unit-blacklist": {},
"declaration-property-unit-whitelist": {},
"declaration-property-value-blacklist": {},
"declaration-property-value-whitelist": {},
"font-family-name-quotes": "always-where-required",
"font-family-no-duplicate-names": true,
"font-weight-notation": "numeric",
"function-calc-no-unspaced-operator": true,
"function-comma-newline-after": "always",
"function-comma-newline-before": "always",
"function-comma-space-after": "always",
"function-comma-space-before": "never",
"function-linear-gradient-no-nonstandard-direction": true,
"function-max-empty-lines": 1,
"function-name-case": "lower",
"function-parentheses-newline-inside": "always",
"function-parentheses-space-inside": "never",
"function-url-no-scheme-relative": true,
"function-url-quotes": "always",
"function-whitespace-after": "always",
"indentation": 4,
"keyframe-declaration-no-important": true,
"length-zero-no-unit": true,
"max-empty-lines": 1,
"max-line-length": 80,,
"max-nesting-depth": 3,
"media-feature-colon-space-after": "always",
"media-feature-colon-space-before": "never",
"media-feature-name-case": "lower",
"media-feature-name-no-unknown": true,
"media-feature-name-no-vendor-prefix": true,
"media-feature-parentheses-space-inside": "never",
"media-feature-range-operator-space-after": "always",
"media-feature-range-operator-space-before": "never",
"media-query-list-comma-newline-after": "never-multi-line",
"media-query-list-comma-newline-before": "never-multi-line",
"media-query-list-comma-space-after": "always",
"media-query-list-comma-space-before": "never",
"no-descending-specificity": true,
"no-duplicate-selectors": true,
"no-empty-source": true,
"no-eol-whitespace": true,
"no-extra-semicolons": true,
"no-invalid-double-slash-comments": true,
"no-missing-end-of-source-newline": true,
"no-unknown-animations": true,
"number-leading-zero": "never",
"number-max-precision": 3,
"number-no-trailing-zeros": true,
"property-case": "lower",
"property-no-unknown": true,
"property-no-vendor-prefix": true,
"rule-empty-line-before": "always",
"selector-attribute-brackets-space-inside": "never",
"selector-attribute-operator-space-after": "always",
"selector-attribute-operator-space-before": "never",
"selector-attribute-quotes": "always",
"selector-combinator-space-after": "always",
"selector-combinator-space-before": "never",
"selector-descendant-combinator-no-non-space": true,
"selector-list-comma-newline-after": "never-multi-line",
"selector-list-comma-newline-before": "never-multi-line",
"selector-list-comma-space-after": "always",
"selector-list-comma-space-before": "never",
"selector-max-attribute": 5,
"selector-max-class": 5,
"selector-max-combinators": 5,
"selector-max-compound-selectors": 5,
"selector-max-empty-lines": 1,
"selector-max-id": 5,
"selector-max-type": 5,
"selector-max-universal": 5,
"selector-no-qualifying-type": true,
"selector-no-vendor-prefix": true,
"selector-pseudo-class-case": "lower",
"selector-pseudo-class-no-unknown": true,
"selector-pseudo-class-parentheses-space-inside": "never",
"selector-pseudo-element-case": "lower",
"selector-pseudo-element-colon-notation": "single",
"selector-pseudo-element-no-unknown": true,
"selector-type-case": "lower",
"selector-type-no-unknown": true,
"shorthand-property-no-redundant-values": true,
"string-no-newline": true,
"string-quotes": "double",
"time-min-milliseconds": 5,
"unit-case": "lower",
"unit-no-unknown": true,
"value-keyword-case": "lower",
"value-list-comma-newline-after": "never-multi-line",
"value-list-comma-newline-before": "never-multi-line",
"value-list-comma-space-after": "always",
"value-list-comma-space-before": "never",
"value-list-max-empty-lines": 1,
"value-no-vendor-prefix": true
}
}

It appears there are two commas after the "max-line-length": 80,, line. This is invalid JSON.
Using a tool like JSONLint, or a code editor with JSON syntax checking will help uncover these.

Related

VS code indentation mode changes from spaces to tab

I am using VS code with a number of extensions, including pylance , editorconfig, prettier, . No matter how many times I change the insertSpaces to true for the different languages or any indentation related settings to spaces mode, at some point (sometimes after a couple of minutes of usage, sometimes after reopening VS code) the tab key starts indenting with tab. I notice this mostly by pressing enter. How can I figure out which extension is doing overriding the spaces indentation mode? I don't want to go through the exercise of testing them one by one. Here's my settings.json that I have pruned down to remove nonrelevant settings.
{
"workbench.statusBar.visible": true,
"editor.insertSpaces": true,
"editor.tabSize": 4,
//"shellformat.useEditorConfig": true,
"editor.fontSize": 10,
"editor.tabCompletion": "on",
"editor.renderWhitespace": "all",
"editor.suggestSelection": "first",
"editor.codeLens": true,
// Generic
"cSpell.enabled": true,
"cSpell.language": "en",
"python.linting.enabled": true,
"python.linting.pylintArgs": [
"--disable=C0303",
"--indent-string=\" \""
],
"python.linting.pylintEnabled": true,
"python.autoComplete.addBrackets": true,
"python.terminal.activateEnvironment": true,
"[python]": {
"editor.defaultFormatter": "ms-python.vscode-pylance",
"editor.tabSize": 4,
"editor.autoClosingBrackets": "always",
"editor.insertSpaces": true,
},
"prettier.useEditorConfig": true,
"prettier.tabWidth": 4,
"python.linting.pylintCategorySeverity.convention": "Hint",
"python.linting.pylintCategorySeverity.refactor": "Warning",
"python.linting.maxNumberOfProblems": 200,
"python.linting.pycodestyleArgs": [
"--max-line-length=100"
],
"python.jediEnabled": false,
"vsintellicode.python.completionsEnabled": true,
"[json]": {
"editor.insertSpaces": true
},
// R
"[r]": {
"editor.autoClosingBrackets": "always",
"editor.defaultFormatter": "Ikuyadeu.r",
"editor.comments.insertSpace": true,
},
"r.interpreter": 0,
"r.linting.enable": true,
"r.lsp.debug": true,
"r.linting.maxLineLength": 105,
"r.editor.tabSize": 2,
"r.linting.noTabs": true,
"editor.detectIndentation": false,
"editor.comments.insertSpace": true,
"prettier.useTabs": false,
"editor.useTabStops": true,
"editor.stickyTabStops": false,
"update.enableWindowsBackgroundUpdates": false,
"breadcrumbs.enabled": true,
// REMOTE connection
"remote.SSH.showLoginTerminal": true,
"remote.SSH.lockfilesInTmp": true,
"window.openFoldersInNewWindow": "on",
"search.showLineNumbers": true,
"r.lsp.diagnostics": false,
"diffEditor.ignoreTrimWhitespace": false,
"workbench.iconTheme": "vscode-icons",
"material-icon-theme.showUpdateMessage": false,
"window.zoomLevel": 3,
"sync.removeExtensions": true,
"sync.syncExtensions": true,
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"python.analysis.extraPaths": [],
"python.terminal.activateEnvInCurrentTerminal": true,
"python.workspaceSymbols.enabled": true,
"python.analysis.completeFunctionParens": true,
"python.languageServer": "None",
"gitlens.currentLine.enabled": false,
"gitlens.hovers.currentLine.over": "line",
"gitlens.statusBar.enabled": false,
"jupyter.askForKernelRestart": false,
"[ignore]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"editor.autoIndent": "brackets",
"formattingToggle.affects": [
"editor.formatOnPaste",
"editor.formatOnSave",
"editor.formatOnType"
],
}

Prettier extension not working even after creating a config file

I have been trying to set up Prettier for VS Code globally so that I have all the basic features as well as single quotes. Before installing Prettier I uncommented VS Code's default Prettier configurations in settings.json file but it wasn't working.
Then I installed Prettier and enabled what I needed from VS Code's Settings > Extensions > Prettier tab but it still wasn't working. After that I created .prettierrc.json file and put it right beside where VS Code's settings.json file is, which is in c:\\Users\\Admin\\AppData\\Roaming\\Code\\User\\settings.json. Then I added this path in VS Code's Settings > Extensions > Prettier > Config Path field. And guess what, it is still not working.
What am I doing wrong here?
Here's how my settings.json file looks like:
{
"terminal.integrated.shell.windows": "D:\\Program Files\\Git\\bin\\bash.exe",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.autoClosingBrackets": "always",
"editor.bracketPairColorization.enabled": true,
"editor.maxTokenizationLineLength": 2000000,
"diffEditor.maxFileSize": 0,
"json.maxItemsComputed": 50000000,
"svelte.enable-ts-plugin": true,
"liveServer.settings.donotShowInfoMsg": true,
"bracketPairColorizer.depreciation-notice": false,
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"javascript.updateImportsOnFileMove.enabled": "always",
"workbench.colorTheme": "Community Material Theme Palenight High Contrast",
"reactSnippets.settings.importReactOnTop": false,
"reactSnippets.settings.prettierEnabled": true,
"html.completion.attributeDefaultValue": "singlequotes",
"html.format.indentInnerHtml": true,
"powermode.enabled": true,
"powermode.combo.counterEnabled": "hide",
"powermode.shake.enabled": false,
"powermode.combo.location": "off",
"powermode.presets": "flames",
// "prettier.jsxBracketSameLine": true,
"prettier.jsxSingleQuote": true,
"prettier.singleQuote": true,
// "prettier.tabWidth": 4,
// "prettier.useTabs": true,
"prettier.bracketSpacing": true,
"prettier.tabWidth": 4,
"prettier.useTabs": true,
"prettier.arrowParens": "avoid",
"prettier.configPath": "c:\\\\Users\\\\Admin\\\\AppData\\\\Roaming\\\\Code\\\\User\\\\.prettierrc.json"
// "prettier.bracketSameLine": true,
// "prettier.arrowParens": "avoid",
// "editor.wordWrapColumn": 120
}
And this is my .prettierrc.json file:
{
"arrowParens": "avoid",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": true,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "es5",
"useTabs": true,
"vueIndentScriptAndStyle": false,
"parser": "json",
"filepath": "c:\\Users\\Admin\\AppData\\Roaming\\Code\\User\\.prettierrc.json"
}
Any suggestions?

VSCode Prettier Extension vs Prettier CI (Svelte)

For some reason, my format-on-save is giving me different results than when I run the following command:
prettier --write src/pages/file.svelte`
The difference between formats is a new line being inserted with the --write command. Is there anyway to check why this is happening?
.vscode/settings.json
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
.prettierrc
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": true,
"jsxSingleQuote": false,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"singleQuote": false,
"useTabs": true,
"tabWidth": 2,
"printWidth": 120,
"semi": true,
"trailingComma": "all",
"svelteSortOrder": "styles-scripts-markup",
"svelteStrictMode": false,
"svelteBracketNewLine": true,
"svelteAllowShorthand": false,
"plugins": ["./node_modules/prettier-plugin-svelte"]
}
Thanks to #dummdidumm for the answer
Prettier did a breaking change to the library and prettier-plugin-svelte had to work around that in a newer version.
Updating prettier-plugin-svelte to ^2.4.0 fixed the issue.

How to set indent and formatting behavior for each language in visual studio code?

Is there a way to make vscode format python files using 4 spaces while formatting files from other languages such JS, Typescript and HTML using 2 spaces only?
It`s pretty annoying to have to indent manually every time.
All of this trying is setting up a mess on my settings and still, I can`t make it work as I want.
This is what my settings.json looks like for the moment
{
"python.jediEnabled": false,
"miramac.node.terminalMode": false,
"python.pythonPath": "/usr/local/bin/python3",
"workbench.colorTheme": "Dracula",
"workbench.startupEditor": "newUntitledFile",
"workbench.editor.labelFormat": "short",
"terminal.integrated.fontSize": 12,
"editor.fontFamily": "Fira Code",
"editor.lineHeight": 19,
"editor.fontLigatures":true,
"editor.suggestSelection": "first",
"editor.renderLineHighlight": "gutter",
"editor.detectIndentation": true,
"editor.insertSpaces": false,
"editor.tabSize": 2,
"editor.autoIndent": "full",
"eslint.alwaysShowStatus": true,
"eslint.debug": true,
"eslint.format.enable": true,
"eslint.options": {
},
"python.languageServer": "Microsoft",
"liveServer.settings.donotVerifyTags": true,
"[html]": {
"editor.tabSize": 2,
"editor.codeActionsOnSave": {
"source.fixAll": true,
},
},
"liveServer.settings.donotShowInfoMsg": true,
"prettier.tabWidth": 2,
"[javascript]":{
"editor.codeActionsOnSave": {
"source.fixAll": true,
}
},
"[javascriptreact]":{
"editor.codeActionsOnSave": {
"source.fixAll": true,
}
},
"[typescript]":{
"editor.codeActionsOnSave": {
"source.fixAll": true,
},
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"[typescriptreact]":{
"editor.codeActionsOnSave": {
"source.fixAll": true,
},
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"[python]": {
"editor.tabSize": 4,
"editor.codeActionsOnSave": {
// "source.fixAll": true,
},
},
"extensions.ignoreRecommendations": true,
"explorer.compactFolders": false,
//perguntar se vc confirma delete e drag and drops
"explorer.confirmDragAndDrop": false,
"explorer.confirmDelete": false,
//mostra o caminho completo do arquivo
"breadcrumbs.enabled": true,
"javascript.updateImportsOnFileMove.enabled": "never",
"typescript.updateImportsOnFileMove.enabled": "never",
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=pygame"
],
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
//set zsh theme to my terminal
//"terminal.integrated.shell.osx": "/bin/bash",
"terminal.integrated.shell.osx": "/bin/bash",
//"terminal.integrated.cwd": "",
"editor.renderControlCharacters": false,
"window.zoomLevel": -1,
"git.path": "/usr/local/git/bin/git",
"gitlens.views.repositories.files.layout": "list",
"gitlens.views.compare.files.layout": "tree",
"emmet.syntaxProfiles": {"javascript": "jsx"},
"emmet.includeLanguages": {"javascript": "javascriptreact"},
"typescript.tsserver.log": "verbose",
"javascript.suggest.autoImports": true,
"git.enableCommitSigning": true,
"git.enableSmartCommit": true,
"git.rebaseWhenSync": true,
"git.showPushSuccessNotification": true,
"workbench.sideBar.location": "left",
"workbench.activityBar.visible": true,
"terminal.integrated.automationShell.osx": "",
// "editor.defaultFormatter": "vscode.python",
// "editor.tokenColorCustomizationsExperimental": {},
"workbench.preferredDarkColorTheme": "Dracula",
"workbench.preferredHighContrastColorTheme": "Visual Studio Dark",
"material-icon-theme.activeIconPack": "nest",
"workbench.iconTheme": "material-icon-theme",
"material-icon-theme.folders.associations": {
"infra": "app",
"entities": "class",
"schemas": "class",
"typeorm": "database",
"repositories": "mappings",
"http": "container",
"migrations": "tools",
"modules": "components",
"implementations": "core",
"dtos": "typescript",
"fakes": "mock",
"coverage_reports": "tools",
},
"material-icon-theme.files.associations": {
"ormconfig.json": "database",
"routes.tsx": "routing",
"routes.ts": "routing",
"*.html": "html",
},
"sqlite.databaseExtensions": [
"db",
"db3",
"sdb",
"s3db",
"sqlite",
"sqlite3",
"ts"
],
}
Would there be anyone who can help in this issue?
I believe option + control + "B" should work
It is also a right click on the document and you should see a "format document" option.
It works for me

VS Code is formatting JS files with operators on new line

For the life of me I cannot figure this out. I have a complex VSCode setup and I believe the prettier extension is causing some behavior I do not want, and I hope someone knows how to disable or re-configure it:
JS files:
takes:
child.gender = $(pref).find('#ml').prop('checked')? 'male' : 'female';
And renders:
child.gender = $(pref)
.find('#ml')
.prop('checked')
? 'male'
: 'female';
I really need the formatter and would like to try to fix rather than disable.
Thanks for your help.
existing options:
"workbench.iconTheme": "material-icon-theme",
"php.suggest.basic": false,
"editor.minimap.enabled": false,
"editor.fontLigatures": true,
"editor.fontFamily": "'Fira Code', 'Arial', monospace",
"php.validate.executablePath": "C:\\wamp64\\bin\\php\\php7.2.4\\php.exe",
"files.associations": {
"*.php": "php",
"*.phtml": "php"
},
"php.validate.run": "onType",
"editor.cursorSmoothCaretAnimation": true,
"editor.smoothScrolling": true,
"files.trimFinalNewlines": true,
"emmet.includeLanguages": {
"blade.php": "html"
},
"vetur.format.options.tabSize": 4,
"vetur.format.options.useTabs": false,
"blade.format.enable": true,
"vetur.format.defaultFormatter.html": "prettyhtml",
"vetur.format.defaultFormatter.css": "prettier",
"vetur.format.defaultFormatter.postcss": "prettier",
"vetur.format.defaultFormatter.scss": "prettier",
"vetur.format.defaultFormatter.less": "prettier",
"vetur.format.defaultFormatter.stylus": "stylus-supremacy",
"vetur.format.defaultFormatter.js": "prettier",
"vetur.format.defaultFormatter.ts": "prettier",
"eslint.enable": false,
"window.zoomLevel": 0,
"files.trimTrailingWhitespace": true,
"prettier.singleQuote": true,
"prettier.trailingComma": "es5",
"prettier.eslintIntegration": true,
"prettier.disableLanguages": [],
"eslint.autoFixOnSave": true,
"editor.insertSpaces": true,
"editor.formatOnSave": true,
"editor.detectIndentation": true,
"editor.tabSize": 4,
"editor.formatOnPaste": false,
"editor.formatOnType": true,
"editor.renderControlCharacters": true,
"editor.renderWhitespace": "none",
"files.exclude": {
".babelrc": true,
".editorconfig": true,
".eslintignore": true,
".eslintrc.js": false,
".gitignore": true,
".jshintrc": true,
".postcssrc.js": true,
"**/node_modules": true,
"build": true
},
"eslint.validate": [
{
"autoFix": true,
"language": "javascript"
},
{
"autoFix": true,
"language": "vue"
}
],
"attrsSorter.order": [
"is",
"v-for",
"v-if",
"v-else-if",
"v-else",
"v-show",
"v-cloak",
"v-once",
"v-pre",
"id",
"ref",
"key",
"slot",
"v-model",
"v-model.+",
"v-bind",
"v-bind.+",
":.+",
"v-text",
"v-text.+",
"v-html",
"v-html.+",
"class",
"v-on.+",
"#.+",
"name",
"data-.+",
"ng-.+",
"src",
"for",
"type",
"href",
"values",
"title",
"alt",
"role",
"aria-.+",
"$unknown$"
],
"gitlens.currentLine.enabled": false,
"gitlens.hovers.currentLine.over": "line",
"gitlens.codeLens.enabled": false,
"phpformatter.composer": true,
"phpformatter.pharPath": "php-cs-fixer",
"phpformatter.logging": true,
"laravel_goto_view.quickJump": true,
"laravel_goto_view.folderTip": true,
"git.enableSmartCommit": true,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": true,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": true,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": true,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": true,
"bracketPairColorizer.highlightActiveScope": true