GithubHelp home page GithubHelp logo

bedrockstreaming / bemlinter Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 1.0 132 KB

A cli tool to lint bem component isolation in CSS / SCSS files

License: MIT License

CSS 13.88% JavaScript 86.12%
bem css linter scss

bemlinter's People

Contributors

tzi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

samunplugged

bemlinter's Issues

Should we compile the scss?

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

Add a quality snapshot setting

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?

Add option to explore the snapshot

For example:

  • a status command
$ bemlinter status
There is currently 2 errors on 2 blocks.
 - root: 1 errors on 1 blocks
 - module:  1 errors on 1 blocks
  • a status command for a module
$ bemlinter status --module root
There is currently 1 errors on 1 blocks for the root module.
  • a error listing command
$ 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.
  • a error listing command for a module
$ 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.

new rule: allow to style a block according to a page context

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.

Allow file prefix, file suffix or even file pattern

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?

  • filePrefix: ['', 'project-'] default ['']
  • fileSuffix: ['.scss', '.theme.scss'] default ['.scss']

Or should we create only one option named filePattern?

Regexp stored in JSON seems broken

This is not a valid JSON file

{
  "filePattern": "([^.]*)(?:\.theme)?\.scss",
}

However, if we escape the backslashes we get double backslash in the parsed data 😞

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.