bedrockstreaming / bemlinter Goto Github PK
View Code? Open in Web Editor NEWA cli tool to lint bem component isolation in CSS / SCSS files
License: MIT License
A cli tool to lint bem component isolation in CSS / SCSS files
License: MIT License
Because we do not compile the SCSS files, we can not detect BEM errors like this one:
.block__element {
&__antoher-element {}
}
Another example is a selector created by a mixin.
For now, we choose to throw an error when the & operator is used to concatenate class name #4
Allow to snap the current quality (number of errors) of each component.
So having an error would not block the lint, but having more error than the last check would.
This feature would allow to have a good view of the code base quality (instead of the current block blacklist) and to easy continuous improvment (fix an error instead of an entire block).
Who's in?
For example:
$ bemlinter status
There is currently 2 errors on 2 blocks.
- root: 1 errors on 1 blocks
- module: 1 errors on 1 blocks
$ bemlinter status --module root
There is currently 1 errors on 1 blocks for the root module.
$ bemlinter list
There is currently 2 errors on 2 blocks.
✗ unprefixed
[unprefixed.scss:8] Error: \".c-prefixed\" is incoherent with the file name, \".unprefixed\" expected.
✗ module / prefixed
[module-prefixed.scss:1] Error: \".c-prefixed\" is incoherent with the file name, \".prefixed\" expected.
$ bemlinter list --module root
There is currently 1 errors on 1 blocks for the root module.
✗ unprefixed
[unprefixed.scss:8] Error: \".c-prefixed\" is incoherent with the file name, \".unprefixed\" expected.
For every module, you should be able to define a root block.
This will allow to define every component according to a root block state.
Example :
.app--loading .component {
background: lightgray;
}
The best practice is to not use cascade to style a component.
This rule is made to insure component isolation.
But a root element is always present, so this exception allow us to style according to a page context.
Most of all, this exception doesn't break reusability.
We should sort the quality snapshot to easy snapshot difference reading ❤️
The bem linter get the block name from the file name.
We should authorize prefix in file name, like project-block.scss
, or suffix, like block.theme.scss
.
So should we create two properties?
['', 'project-']
default ['']
['.scss', '.theme.scss']
default ['.scss']
Or should we create only one option named filePattern
?
This is not a valid JSON file
{
"filePattern": "([^.]*)(?:\.theme)?\.scss",
}
However, if we escape the backslashes we get double backslash in the parsed data 😞
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.