glortho / glortho/styled-import

Should matched selectors be returned alongside declarations?

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
60
Forks
2
PR merge metrics
No merged PRs in 30d

Description

This may not be useful in simple string matching like `'.foo'` but what about for regex matches?

For example, here is functionality as of v0.3.0:

_./stylesheet.css_
```css
.foo {
color: blue;
}

.footer {
color: black;
}
```

```javascript
declarations = styledImport('./stylesheet.css', /foo/)
// declarations is 'color: blue;'

declarations = styledImport('./stylesheet.css', /foo/g)
// declarations is ['color: blue;', 'color: black;']
```

Would it be better to return the selectors also? For example:

```javascript
matches = styledImport('./stylesheet.css', /foo/g)

// matches could be:

[{
selector: '.foo',
declarations: 'color: blue;'
}, {
selector: '.footer',
declarations: 'color: black;'
}]
```

There are probably other cases where having selectors back would be useful.

It could be behind an options flag of some sort.

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no source files or tests; start by locating the styledImport entry point and its regex-matching behavior using the stylesheet.css examples. Review how simple and global matches currently differ, then determine whether selector/declaration pairs and an options flag fit the API. Done means the behavior and compatibility choice are clearly specified and covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, javascript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.