Skip to content
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

Feat/add comment exclusions #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mihaisavezi
Copy link

@mihaisavezi mihaisavezi commented Apr 25, 2020

First stab at handling comments exclusions, see #17

@mihaisavezi
Copy link
Author

stab at #17

const commentStart = 'no important-start';
const commentEnd = 'no important-end';

if(node.text === commentStart) {
Copy link
Owner

Choose a reason for hiding this comment

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

Do we have to worry about comparing whitespace here? Perhaps we need to node.text.trim()?

Comment on lines +63 to +64
const commentStart = 'no important-start';
const commentEnd = 'no important-end';
Copy link
Owner

Choose a reason for hiding this comment

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

Do we have to

Suggested change
const commentStart = 'no important-start';
const commentEnd = 'no important-end';
const enableComment = 'postcss-increase-specificity enable';
const disableComment = 'postcss-increase-specificity disable';

// Avoid adding additional selectors (stackableRoot) to descendant rules of @keyframe {}
// i.e. `from`, `to`, or `{number}%`
var isInsideKeyframes = rule.parent.type === 'atrule' && rule.parent.name === 'keyframes';
let isExcluded = false;
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
let isExcluded = false;
let isDisabled = false;

@@ -52,6 +52,10 @@ describe('postcss-increase-specificity', function() {
return testPlugin('./test/fixtures/classes.css', './test/fixtures/classes.expected.css');
});

it('should handle exclusion commments', function () {
return testPlugin('./test/fixtures/comments-to-exclude.css', './test/fixtures/comments-to-exclude.expected.css');
Copy link
Owner

Choose a reason for hiding this comment

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

disable-enable-with-comments.css

@@ -55,14 +55,33 @@ module.exports = postcss.plugin('postcss-increase-specificity', function(options
var opts = objectAssign({}, defaults, options);
Copy link
Owner

Choose a reason for hiding this comment

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

Sorry for the delay @mihaisavezi 🙇

This looks like a great v1 we can merge of this feature 👍

My comments are mainly framing everything in terms of disable/enable instead of exclude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants