Comments (13)
I ended up using the stylelint.config.js
option to solve the problem, it solves it for the cmd
and vscode
:
// stylelint.config.js
const argv = require("yargs").argv;
const glob = argv["_"] && argv["_"][0];
const isJsTsxFiles = glob && /.{js,jsx,tsx}/.test(glob);
if (isJsTsxFiles) {
module.exports = {
extends: ["stylelint-config-standard", "stylelint-config-styled-components"],
processors: ["stylelint-processor-styled-components"],
plugins: ["stylelint-order"],
rules: {
"font-family-no-missing-generic-family-keyword": null,
"order/properties-alphabetical-order": true,
indentation: 4,
"declaration-empty-line-before": null,
"no-eol-whitespace": null
}
};
}
module.exports = {
extends: ["stylelint-config-standard"],
processors: [],
plugins: ["stylelint-scss", "stylelint-order"],
rules: {
indentation: 4
}
};
from stylelint-processor-styled-components.
The problem is that I didn't run stylelint by myself, I just run it via vscode's plugin, so it will run it against all file I guess.
from stylelint-processor-styled-components.
Recently, we released v1.8.0(#267) which supports the option ignoreFiles
to make the processor skip some files. Maybe it can help.
from stylelint-processor-styled-components.
I've also came accross with this problem when linting jsx
and scss
files at the same time. Linting works as expected when only a kind of file is linted at once but this error arises when types are mixed up.
I think README.md
should be updated to reflect that jsx
/js
files should be linted in a separated go than css
/scss
/less
files. The below line appearing at the moment is confusing:
NOTE: Don't worry about passing in files that don't contain any styled-components code – we take care of that.
from stylelint-processor-styled-components.
Same here:
$ stylelint './packages/**/*.tsx'
SyntaxError: Unexpected token, expected , (155:10)
at Parser.pp$5.raise (/Users/.../node_modules/babylon/lib/index.js:4452:13)
at Parser.pp.unexpected (/Users/.../node_modules/babylon/lib/index.js:1761:8)
at Parser.pp.expect (/Users/.../node_modules/babylon/lib/index.js:1749:33)
at Parser.pp$3.parseParenAndDistinguishExpression (/Users/.../node_modules/babylon/lib/index.js:3812:12)
at Parser.pp$3.parseExprAtom (/Users/.../node_modules/babylon/lib/index.js:3707:19)
at Parser.parseExprAtom (/Users/.../node_modules/babylon/lib/index.js:7113:22)
at Parser.pp$3.parseExprSubscripts (/Users/.../node_modules/babylon/lib/index.js:3492:19)
at Parser.pp$3.parseMaybeUnary (/Users/.../node_modules/babylon/lib/index.js:3472:19)
at Parser.pp$3.parseExprOps (/Users/.../node_modules/babylon/lib/index.js:3402:19)
at Parser.pp$3.parseMaybeConditional (/Users/.../node_modules/babylon/lib/index.js:3379
Unfortunately no source file. So I don't know where to fix this.
from stylelint-processor-styled-components.
@linonetwo Are you running this processor on a .css
file? That probably won't work and is nothing we can support I don't think?
@JonWallsten your issue is that you're using TypeScript
, but we're using Babylon for parsing which doesn't support Typescript 😢
from stylelint-processor-styled-components.
I'll mark this as wontfix since you shouldn't run this processor when linting .css
files, but maybe there's something I'm missing here!
from stylelint-processor-styled-components.
Hmmm... I'm not quite an expert on stylelint, but I just searched a bit, and could it be true that there is no way to specify different stylelint configurations for different file types?
Because yeah, this processor as of right now only supports Javascript files.
@AntonioRedondo if it's true there is currently no way to specify different configs based on a regex, maybe you should open an issue with the Stylelint repo?
And yeah it definitely wouldn't hurt slightly updating the README to reflect that we truly only support Javascript files if that isn't clear enough, feel free to submit a PR with the clarifications you feel are needed :).
from stylelint-processor-styled-components.
and could it be true that there is no way to specify different stylelint configurations for different file types?
The way I know of is to use the cli with the config flag:
stylelint "*.css" --config config-for-css.json
stylelint "*.jsx" --config config-for-jsx.json
However I think the node implementation of stylelint just looks for the standard config files.
from stylelint-processor-styled-components.
Yeah that's definitely a possibility.
But I guess that wouldn't work for for example text editor plugins.
You would need a webpack'ish implementation of
test: /\.jsx?/,
loader: [
stylelint,
config: { ... }
],
test: /\.css/,
loader: [
stylelint,
config: { ... }
]
implemented I guess, which would be a stylelint issue / PR that should be opened there.
from stylelint-processor-styled-components.
Yeah. Nothing we can do about it anyway.
from stylelint-processor-styled-components.
Is there a way to configure stylelint differently for css and js files in the stylelint section of package json or is the only option to write a different config file and run stylelint twice?
from stylelint-processor-styled-components.
Currently Stylelint (as far as I know) doesn't allow putting in different configs for different files in an easy way, you could either get this to happen by contributing to #163 so we can get that merged, or helping get that implemented for Stylelint itself
from stylelint-processor-styled-components.
Related Issues (20)
- Autofix stylelint doesn't work HOT 3
- Release a new version with stylelint 10 changes HOT 2
- Using other styled components in selectors not working HOT 8
- Add support for css prop HOT 4
- Remove or rename invalid `-styled-mixin0` CSS properties caused by using mixins HOT 5
- Variables start with $ don't throw errors HOT 2
- Upgrade outdated "@babel/parser" dependency HOT 3
- Add Support for Object Syntax HOT 3
- Deprecated package HOT 10
- CSS partials cause `CssSyntaxError` HOT 1
- An in-range update of postcss is breaking the build 🚨 HOT 2
- Possible to lint styles outside styled component definition? HOT 4
- Nested `css` blocks inside of styled-components creates invalid code HOT 1
- Support babel 7.8 syntax like null coalescing without plugins HOT 2
- Stylelint doesn't lint nested conditional block of styles
- Stylelint: Unknown word (CssSyntaxError) when commenting out valid css HOT 2
- Do I need this? HOT 2
- style lint don't work HOT 1
- Template literal types cannot have any substitution HOT 1
- Vulnerability Issue HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stylelint-processor-styled-components.