matype / stylefmt

stylefmt is a tool that automatically formats stylesheets.
Other
2.1k stars 89 forks source link

Error: can't find "rules" #233

Closed herkulano closed 7 years ago

herkulano commented 7 years ago

Getting the error: No rules found within configuration. Have you provided a "rules" property?

Running it in a npm script: "css": "postcss -c .postcss.json",

Config file for postcss:

{
  "use": ["stylefmt", "postcss-sorting"],
  "syntax": "postcss-scss",
  "input": "src/**/*.scss",
  "local-plugins": true,
  "replace": true,
  "stylefmt": {
    "config": ".stylelintrc"
  },
 "postcss-sorting": {}
}

Testing simple rules in .stylelintrc

{
  "rules": {
    "string-quotes": "single",
    "color-hex-case": "lower",
    "color-hex-length": "short"
  }
}

with this scss:

.test {
  color: #AAAAAA;
}
techieshark commented 7 years ago

I assume this is a typo, but your postcss config has:

  "stylefmt": {
    "config": ".stylelintrc"
  },

while your description is missing the t in the filename: "Testing simple rules in .stylelinrc".

herkulano commented 7 years ago

@techieshark Thanks for pointing that out. It is indeed a typo. The file in the project is correctly named .stylelintrc

techieshark commented 7 years ago

Hmm. Does stylefmt work for you as a standalone command, rather than when used via postcss?

gucong3000 commented 7 years ago

@herkulano ,@techieshark Option of stylefmt is wrong, try this:

  "stylefmt": {
    "config": {
      ...
    }
  },

or

  "stylefmt": {
    "configFile": ".stylelintrc"
  },

See: http://stylelint.io/user-guide/node-api/

gucong3000 commented 7 years ago

@morishitter I think we need a document to describe Node API, just like: https://github.com/stylelint/stylelint/blob/master/docs/user-guide/node-api.md

herkulano commented 7 years ago

@morishitter Thanks, it works great! 👍