Search code examples
csssassnestedindentationcompass-sass

scss formatting : indent and NestingDepth


I have a scss file in my ionic 3 project and when I run this command : npm run scss-lint to test the scss syntaxe i got those warning in my cmd :

src/pages/profile/profile.scss:3:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:9:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:15:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:20:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:28:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:33:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:37:1 [W] SelectorDepth: Selector should have depth of applicability no greater than 3, but was 4
src/pages/profile/profile.scss:37:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:38:1 [W] Indentation: Line should be indented 4 spaces, but was indented 3 spaces
src/pages/profile/profile.scss:39:1 [W] Indentation: Line should be indented 4 spaces, but was indented 3 spaces
src/pages/profile/profile.scss:42:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:47:1 [W] SelectorDepth: Selector should have depth of applicability no greater than 3, but was 5
src/pages/profile/profile.scss:47:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:53:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:57:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:61:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:68:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:72:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:79:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:85:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:93:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:97:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:101:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:108:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:115:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:120:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:128:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:132:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:136:1 [W] SelectorDepth: Selector should have depth of applicability no greater than 3, but was 4
src/pages/profile/profile.scss:136:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:143:1 [W] SelectorFormat: Selector `Progress-main` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:143:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:150:1 [W] SelectorFormat: Selector `Progress-main` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:150:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:154:1 [W] SelectorFormat: Selector `Progress-main` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:154:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:158:1 [W] SelectorFormat: Selector `Progress-bar` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:158:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:164:1 [W] SelectorFormat: Selector `Progress-value` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:164:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:165:23 [W] HexLength: Color `#0000ff` should be written as `#00f`
src/pages/profile/profile.scss:170:1 [W] Indentation: Line should be indented 2 spaces, but was indented 1 spaces
src/pages/profile/profile.scss:170:3 [W] NameFormat: Name of variable `progress_bar_colour` should be written in all lowercase letters with hyphens instead of underscores
src/pages/profile/profile.scss:172:1 [W] SelectorFormat: Selector `Progress-label-left` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:172:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:182:1 [W] SelectorFormat: Selector `Progress-label-right` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:182:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:193:1 [W] SelectorFormat: Selector `Progress-label-center` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:193:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:202:1 [W] SelectorFormat: Selector `Progress-main` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:202:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:209:1 [W] SelectorFormat: Selector `Progress-main` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:209:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:213:1 [W] SelectorFormat: Selector `Progress-main` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:213:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:214:17 [W] NameFormat: Name of variable `progress_bar_colour` should be written in all lowercase letters with hyphens instead of underscores
src/pages/profile/profile.scss:217:1 [W] SelectorFormat: Selector `Progress-main` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:217:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:221:1 [W] SelectorFormat: Selector `Progress-main` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:221:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:226:1 [W] SelectorFormat: Selector `Progress-bar` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:226:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:228:23 [W] NameFormat: Name of variable `progress_bar_colour` should be written in all lowercase letters with hyphens instead of underscores
src/pages/profile/profile.scss:232:1 [W] SelectorFormat: Selector `Progress-value` should be written in hyphenated BEM (Block Element Modifier) format
src/pages/profile/profile.scss:232:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:238:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2
src/pages/profile/profile.scss:245:3 [W] NestingDepth: Nesting should be no greater than 1, but was 2

here is my scss file pasted in pastbin https://pastebin.com/1ZqC2Ptc

can you please give some link that help me to formatting the scss file, or is there any plugin to configure on visual code editor with that , I tried a lot of time to solve the problems of Indentation and nestingdepth..?


Solution

  • The error NestingDepth: Nesting should be no greater than 1 doesn't refer to brace nesting, it refers to selector nesting.

    Remember that brace nesting in SASS is just sugar to help make the source more readable.

    For example,

    div {
        a {
          font-size: 15px;
        }
    }
    

    Is just SASS sugar for

    div a {
        font-size: 15px;
    }
    

    Which means that, to take from your example:

    page-profile {
       .profileinformations> h1 > ion-icon {
         font-size: 15px;
         color: color($colors, icon-color);
       }
    }
    

    Has a NestingDepth of 4: page-profile .profileinformations > h1 > ion-icon.