Skip to content

Commit

Permalink
Merge pull request #444 from peterramsing/node-14-update
Browse files Browse the repository at this point in the history
Modern Node update, Linting, and Node 8, 9 deprecation
  • Loading branch information
peterramsing committed Nov 1, 2020
2 parents 22e4bba + 30be80f commit 36166d7
Show file tree
Hide file tree
Showing 32 changed files with 3,049 additions and 2,191 deletions.
47 changes: 23 additions & 24 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
module.exports = {
env: {
es6: true,
node: true
},
plugins: ['prettier'],
extends: 'eslint:recommended',
parserOptions: {
sourceType: 'module'
},
rules: {
'eol-last': 2,
'no-multiple-empty-lines': [2, { max: 2, maxEOF: 1 }],
indent: ['error', 2],
'linebreak-style': ['error', 'unix'],
quotes: [
'error',
'single',
{
avoidEscape: true
}
],
semi: ['error', 'always'],
'prettier/prettier': 'error'
}
env: {
es6: true,
node: true,
},
plugins: ['prettier'],
extends: 'eslint:recommended',
parserOptions: {
sourceType: 'module',
},
rules: {
'eol-last': 2,
'no-multiple-empty-lines': [2, { max: 2, maxEOF: 1 }],
'linebreak-style': ['error', 'unix'],
quotes: [
'error',
'single',
{
avoidEscape: true,
},
],
semi: ['error', 'always'],
'prettier/prettier': 'error',
},
};
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"singleQuote": true,
"trailingComma": "es5"
"trailingComma": "es5",
"tabWidth": 2
}
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
sudo: false
dist: xenial

os: linux

language: node_js

node_js:
- 6
- 8
- 10
- 11
- 12
- 13
- 14
- 15
- node

script:
Expand Down
8 changes: 4 additions & 4 deletions lib/core/lg-logic.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
calcValue: function(fraction, gutter, rounder, unit) {
calcValue: function (fraction, gutter, rounder, unit) {
var calcValue = '';
var gutterLogic = '';

Expand All @@ -18,18 +18,18 @@ module.exports = {
calcValue = `calc(${rounder}${unit} * ${fraction}${gutterLogic})`;
return calcValue;
},
validateUnit: function(value, validUnits) {
validateUnit: function (value, validUnits) {
var validation = false;

if (validUnits.indexOf(value) !== -1) {
validation = true;
}
return validation;
},
parseLostProperty: function(nodes, propertyName, defaultPropertyValue) {
parseLostProperty: function (nodes, propertyName, defaultPropertyValue) {
var propertyValue = defaultPropertyValue;

nodes.forEach(declaration => {
nodes.forEach((declaration) => {
if (declaration.prop === propertyName) {
propertyValue = declaration.value;
declaration.remove();
Expand Down
2 changes: 1 addition & 1 deletion lib/core/lg-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const hToD = function hToD(...h) {
const safeRgbToRgb = function safeRgbToRgb(rgb) {
var value = extractRgbSubstring(rgb)
.split(',')
.map(function(a) {
.map(function (a) {
var b = parseInt(a, 10);
return !isNaN(b) ? b : 0;
});
Expand Down
2 changes: 1 addition & 1 deletion lib/lost-center.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function lostCenterDecl(css, settings, result) {
var lostColumnGutter = 0;
var validUnits = ['%', 'vw'];

var isFractionValue = value => {
var isFractionValue = (value) => {
var lostFractionPattern = /^\d+\/\d+$/;
return lostFractionPattern.test(value);
};
Expand Down
2 changes: 1 addition & 1 deletion lib/lost-column.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = function lostColumnDecl(css, settings, result) {
// Converts the cycle to an integer so that checks on whether it's 0 make sense
lostColumnCycle = parseInt(lostColumnCycle);

decl.parent.nodes.forEach(declaration => {
decl.parent.nodes.forEach((declaration) => {
if (declaration.prop === 'lost-unit') {
if (lgLogic.validateUnit(declaration.value, validUnits)) {
unit = declaration.value;
Expand Down
2 changes: 1 addition & 1 deletion lib/lost-gutter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var lostGutterLocal = require('./lost-vars-gutter-local');
module.exports = function lgGutter(css, settings) {
var gutter, newValue;

css.walkDecls(declaration => {
css.walkDecls((declaration) => {
if (
/(\$lost-gutter)/g.test(declaration.value) &&
!/(\$lost-gutter-local)/g.test(declaration.value)
Expand Down
4 changes: 2 additions & 2 deletions lib/lost-move.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = function lostMoveDecl(css, settings) {
}
});

decl.parent.nodes.forEach(declaration => {
decl.parent.nodes.forEach((declaration) => {
if (declaration.prop === 'lost-column') {
var columnArray = declaration.value.split(' ');
if (columnArray[2]) {
Expand All @@ -39,7 +39,7 @@ module.exports = function lostMoveDecl(css, settings) {
}
});

decl.parent.nodes.forEach(declaration => {
decl.parent.nodes.forEach((declaration) => {
if (declaration.prop === 'lost-row') {
var rowArray = declaration.value.split(' ');
if (rowArray[1]) {
Expand Down
2 changes: 1 addition & 1 deletion lib/lost-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = function lostRowDecl(css, settings, result) {
}
});

decl.parent.nodes.forEach(declaration => {
decl.parent.nodes.forEach((declaration) => {
if (declaration.prop === 'lost-unit') {
if (lgLogic.validateUnit(declaration.value, validUnits)) {
unit = declaration.value;
Expand Down
2 changes: 1 addition & 1 deletion lib/lost-vars-gutter-local.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function lostVarsGutterLocal(declaration, settings) {
var newLocalValue = settings.gutter;

declaration.parent.nodes.forEach(parentDeclaration => {
declaration.parent.nodes.forEach((parentDeclaration) => {
var declarationArray = parentDeclaration.value.split(' ');

if (
Expand Down
4 changes: 2 additions & 2 deletions lib/lost-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var variableFunctions = {
};

module.exports = function lostVarsDecl(css, settings) {
css.walkDecls(declaration => {
css.walkDecls((declaration) => {
var value = declaration.value,
variables = [],
// eslint-disable-next-line
Expand All @@ -26,7 +26,7 @@ module.exports = function lostVarsDecl(css, settings) {
}
}

variables.forEach(variable => {
variables.forEach((variable) => {
var func = variableFunctions[variable];

if (typeof func !== 'function') {
Expand Down
6 changes: 2 additions & 4 deletions lib/lost-waffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,13 @@ module.exports = function lostWaffleDecl(css, settings) {
}
});

decl.parent.nodes.forEach(declaration => {
decl.parent.nodes.forEach((declaration) => {
if (declaration.prop === 'lost-unit') {
if (lgLogic.validateUnit(declaration.value, validUnits)) {
unit = declaration.value;
} else {
throw declaration.error(
`lost-unit: property ${
declaration.value
} is not a valid unit for lost-waffle.`
`lost-unit: property ${declaration.value} is not a valid unit for lost-waffle.`
);
}
declaration.remove();
Expand Down
4 changes: 2 additions & 2 deletions lost.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ const defaultSettings = {
direction: 'ltr',
};

module.exports = postcss.plugin('lost', settings => {
module.exports = postcss.plugin('lost', (settings) => {
let runSettings = assign({}, defaultSettings, settings | {});
return (css, result) => {
libs.forEach(lib => {
libs.forEach((lib) => {
lib(css, runSettings, result);
});
};
Expand Down
Loading

0 comments on commit 36166d7

Please sign in to comment.