question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature: automate file-name definititions

See original GitHub issue

This really perhaps really a feature-request for stylelint-selector-bem-pattern, but I’ll leave it here since that module mostly wraps this one.

I know explicit definitions are great, and they work for many people, but… I’m lazy. I would like to enforce our rules BEM rules.

Let’s say for an example project we standardize on SUIT, and mandate it into our component file-structure. File-structure looks something like:

components/DogCard/DogCard.js
components/DogCard/DogCard.css
components/DogList/DogList.js
components/DogList/DogList.css

So, we setup our config

"rules": {
  "plugin/selector-bem-pattern": {
    "preset": "suit"
  }
}

Now, we have something like 50 components to add a “define” block too to enforce our pattern and manually enforce new components include the define.

This is okay, but if we just implicit the define from the filename.

"rules": {
  "plugin/selector-bem-pattern": {
    "preset": "suit",
    "implyFilenameDefine": true
  }
}

Now, when components/DogCard/DogCard.css is passed to the linter we imply

/** @define DogCard */

If someone wants to add a utility lib, no problem, they’ll get a warning can use utilities to opt-out.

/** @define utilities */

I’m sure some work will need to be done to stylelint-selector-bem-pattern as well, but it probably starts here.

//cc @davidtheclark

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
simonsmithcommented, Jun 2, 2016

I like this. I think opt-in is a nice route as it’s the least disruptive for existing users.

So with components we’d use the filename as the definition, and with utilities if the glob matched then we’d assume it wanted to be linted?

2reactions
simonsmithcommented, Aug 31, 2016

I think the goal here is just to use the filename for componentName as that is the part that is always required manually with a @define - https://github.com/postcss/postcss-bem-linter#componentname

The part after is componentSelectors and that would need to remain a regex. I presume on most projects people use the default SUIT or BEM presets for the part after componentName.

Read more comments on GitHub >

github_iconTop Results From Across the Web

File actions reference - Power Automate | Microsoft Learn
See all the available file actions. ... This rename scheme searches each file name, and removes the entered text anywhere in the name, ......
Read more >
How to automate file naming - Fluix
The first thing. You set up a naming convention in the file template and upload it to your storage folder, which is used...
Read more >
Power Automate: Use Criteria on OneDrive file names
This video shows you how to search for keywords within file names of files in OneDrive or OneDrive for Business to manage to...
Read more >
Automated File Names - SumProduct
Automated File Names. This article derives a formula to display the name of the workbook automatically. But be warned: it ain't pretty.
Read more >
Auto-name Files and Configure File Save Naming - Win2PDF
Click the "Document" tab display the Auto-name configuration options. Auto-name Files and Configure File Save Naming.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found