Skip to content

feat: Require the :scope pseudo for root states. #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 19, 2018
Merged

Conversation

amiller-gh
Copy link
Contributor

  • Buggy getBlockNode removed from block-intermediates
  • block-intermediates made a private utility of BlockParser
  • Unrelated: Fix webpack plugin file watcher for auto rebuilds

Still TODO (at a later date): This PR starts to clean up the distinctions between block-intermediates and, BlockPath parser and the AttrToken interface, but there is still more to do! Step in the right direction.

Copy link
Contributor

@chriseppstein chriseppstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great patch. Just some minor comments.

ARCHITECTURE.md Outdated
@@ -175,7 +175,7 @@ We can easily conceptualize the `RewriteMapping` data for each element in develo
```javascript
// For Element 1:
// - `.class-0` is always applied
// - [state|active] is *only* applied when `isActive` is true
// - `:scope[state|active]` is *only* applied when `isActive` is true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be .class-0[state|active]?

*/
export function isExternalBlock(object: NodeAndType): boolean {
return object.blockType === BlockType.block;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should name the anonymous interfaces in NodeAndType and then this (and the other related isXXX checks) should become typeguards.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmmkay refactored 👍 (Even though its going away...soon...hopefully...)

throw new errors.InvalidBlockSyntax(
`It's redundant to specify a state with an explicit .root: ${rule.selector}`,
loc(file, rule, found.node),
`States without an explicit :scope or class selector are not yet supported: ${rule.selector}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't say "yet" here. It may not happen 🤷‍♂️

}
throw new errors.InvalidBlockSyntax(
`Missing global state selector on external Block '${result.node.value}'. Did you mean one of: ${globalStates.map((s) => s.asSource()).join(" ")}`,
loc(file, rule, sel.nodes[0]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be an error for when the state with that name exists, but it's not global.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent.

@@ -33,11 +33,52 @@ export class BlockInheritance extends BEMProcessor {
);
});
}
@test "Global state usage must be specify a global state if present"() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"must be specify" => "must be able to specify"?

@@ -198,7 +198,7 @@ export class Test {
).then((analyzer: Analyzer) => {
let result = analyzer.serialize();
let analysis = result.analyses[0];
assert.deepEqual(analysis.stylesFound, ["bar.pretty", "bar.pretty[state|awesome]", "bar:scope", "bar[state|awesome]"]);
assert.deepEqual(analysis.stylesFound, ["bar.pretty", "bar.pretty[state|awesome]", "bar:scope", "bar:scope[state|awesome]"]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bar:scope I don't think we should ever use :scope in combination with a block name.

block-b[state|bar=two] (blocks/b.block.css:4:40)`,
block-a:scope[state|foo=one] (blocks/foo.block.css:4:46)
block-b:scope[state|bar=one] (blocks/b.block.css:3:43)
block-b:scope[state|bar=two] (blocks/b.block.css:4:46)`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weith an explicit block name the :scope is redundant. I think the scope selector is best reserved for inside the block file where the name of the block is a suggestion at best.

amiller-gh and others added 6 commits April 19, 2018 11:13
 - All local types have been pulled out to the project directory.
 - Packages moved to /packages/@css-blocks for module name generation.
 - typedoc.js configuration file added.
 - packages/css-blocks => packages/@css-blocks/core
 - packages/webpack-plugin => packages/@css-blocks/webpack.
 - packages/glimmer-templates => packages/@css-blocks/glimmer.
 - packages/runtime/src/runtime.ts => packages/@css-blocks/runtime/src/index.ts.
 - yarn run docs will generate a typedoc site at /docs.
 - TODO: Uses pre-built forked version of typedoc-plugin-external-module-map. Remove when merged.
 - Buggy getBlockNode removed from block-intermediates
 - block-intermediates made a private module of BlockParser
 - Unrelated: Fix webpack plugin file watcher for auto rebuilds
@amiller-gh amiller-gh changed the base branch from typedocs to master April 19, 2018 21:21
@amiller-gh amiller-gh merged commit 370dfd1 into master Apr 19, 2018
@amiller-gh amiller-gh deleted the require-scope branch April 19, 2018 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants