question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi, I need help regarding a behavior in a rule.

We use sass-lint (https://github.com/sasstools/sass-lint) on some projects, but we’re migrating to stylelint. In sass-lint, we use the indentation rule and it has a slightly different behavior in its validation.

Look at the illustrations:

indentation with sass-lint: indentation_sass-lint

indentation with stylelint: indentation_stylelint

We found that there is a difference in the validation. Sass-lint validates even the beginning of the style block, not allowing indentation in the initial part. If I indent all the contents of the block, the stylelint allows, but the sass-lint does not.

I wanted your opinion on this behavior. Does sass-lint validation make sense? Can I simulate the same validation with stylelint?

Thanks in advance for your help,

Jackson

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
gucong3000commented, Aug 17, 2018

I’m trying to solve this problem. I’ve added an option baseIndentLevel, you can set this option to 0 to make the CSS indent level equal to the parent element.

"use strict";
const stylelint = require("stylelint")    // npm i stylelint/stylelint#indent_infer
stylelint.lint({
  code: `
    <style>
      a {
        display:block;
      }
    </style>`,
  codeFilename: "a.html",
  config: {
    rules: {
      indentation: [
        2,
        {
          baseIndentLevel: 0,
        }
      ]
    },
  },
  fix: true,
}).then(result => console.log(result.output));
$ node indent_test.js

    <style>
    a {
      display:block;
    }
    </style>
0reactions
jeddy3commented, Oct 9, 2018

@CodeLittlePrince Please ensure your using the latest version of stylelint (by deleting your node_modules folder and any globally installed versions). If that doesn’t fix the problem, please create a new issue (using the “Report a bug” template) so that we can better help you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When Do You Indent a Paragraph? - Grammarly
First line indentation begins to the right of where the next line begins. APA requires most paragraphs to adhere to first line indentation....
Read more >
How to Indent Your Code | Introduction to Computer Science
Basically, the general rule for indenting is that code between curly brackets should be indented. Curly brackets are { and } .
Read more >
Examples of Indentation in Compositions - ThoughtCo
Indentation, a blank space between a margin and the beginning of a line of text, is used in composition to format paragraphs as...
Read more >
A Guide to Indenting Paragraphs | Proofed's Writing Tips
In APA, you should indent the first line of each paragraph by 0.5” (1.27 cm). This rule also applies to the abstract, except...
Read more >
Indentation style - Wikipedia
In computer programming, an indentation style is a convention governing the indentation of blocks of code to convey program structure.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found