Skip to content

Commit

Permalink
Remove various old AST props
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilsson committed Jan 24, 2019
1 parent 5b53193 commit d46bf4e
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 127 deletions.
8 changes: 2 additions & 6 deletions lib/linters/empty_rule.js
Expand Up @@ -7,7 +7,7 @@ module.exports = {

lint: function emptyRuleLinter (config, node) {
// If it's a bodiless rule or a mixin function definition, bail.
if (node.empty || node.params) {
if (node.params) {
return;
}

Expand All @@ -19,17 +19,13 @@ module.exports = {

const nodeTypes = ['atrule', 'decl'];
node.walk((child) => {
if (nodeTypes.includes(child.type) || (child.type === 'rule' && child.empty)) {
if (nodeTypes.includes(child.type)) {
hasDeclarations = true;

return false;
}
});

if (hasDeclarations) {
return;
}

if (!hasDeclarations || !node.nodes.length) {
return [{
message: this.message
Expand Down
10 changes: 1 addition & 9 deletions lib/linters/newline_after_block.js
Expand Up @@ -9,11 +9,7 @@ module.exports = {
const { parent } = node;

// Ignore at-rules without a body
if (node.empty || (node.type === 'atrule' && !node.nodes)) {
/**
* Hopefully node.empty will be implemented on AtRule nodes
* in the future: https://github.com/webschik/postcss-less/issues/55
*/
if (node.type === 'atrule' && !node.nodes) {
return;
}

Expand All @@ -39,10 +35,6 @@ module.exports = {
return;
}

if (regexp.test(prev.raws.right)) {
return;
}

prev = prev.prev ? prev.prev() : {};
}

Expand Down
8 changes: 1 addition & 7 deletions lib/linters/single_line_per_property.js
Expand Up @@ -45,15 +45,9 @@ module.exports = {
}

const childEnd = child.source.end || {};
const prevNode = child.prev();

let validBefore = hasNewline(child.raws.before);
const validBefore = hasNewline(child.raws.before);
let validAfter = isValidAfter(child, index);

if (prevNode && hasNewline(prevNode.raws.right)) {
validBefore = true;
}

// Check if the closing bracket is on the same line as the last property
if (index === node.nodes.length - 1 && childEnd.line === nodeEnd.line) {
validAfter = false;
Expand Down
7 changes: 1 addition & 6 deletions lib/linters/space_before_brace.js
Expand Up @@ -21,12 +21,7 @@ module.exports = {
}

// If the node is a bodiless rule or atrule, bail
if (node.empty ||
/**
* Hopefully node.empty will be implemented on AtRule nodes
* in the future: https://github.com/webschik/postcss-less/issues/55
*/
(node.type === 'atrule' && !node.nodes)) {
if (node.type === 'atrule' && !node.nodes) {
return;
}

Expand Down

0 comments on commit d46bf4e

Please sign in to comment.