Skip to content

Commit

Permalink
[dev] - Use yarn and jest for package management and testing, respect…
Browse files Browse the repository at this point in the history
…ively. Update all devDependencies and integrate.
  • Loading branch information
beefancohen committed Oct 12, 2016
1 parent a7696a7 commit efff839
Show file tree
Hide file tree
Showing 21 changed files with 3,402 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ reports
npm-debug.log
coverage
lib
.DS_Store
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ reports
npm-debug.log
coverage
.gitignore
.DS_Store
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
language: node_js
node_js:
- 0.10
- 0.12
- iojs
- 4
- 5
- 6
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env mocha */
/* eslint no-template-curly-in-string: 0 */
import assert from 'assert';
import { extractProp } from '../helper';
import { getLiteralPropValue } from '../../src/getPropValue';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-env mocha */
/* eslint no-template-curly-in-string: 0 */
import assert from 'assert';
import { extractProp } from '../helper';
import getPropValue from '../../src/getPropValue';
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions tests/src/index.js → __tests__/src/index-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-env mocha */
import assert from 'assert';
import core from '../../src/index';
import fs from 'fs';
import path from 'path';
import assert from 'assert';
import core from '../../src/index';

const src = fs.readdirSync(path.resolve(__dirname, '../../src'))
.filter(f => f.indexOf('.js') >= 0)
Expand All @@ -16,18 +16,18 @@ describe('main export', () => {
assert.equal(expected, actual);
});

src.filter(f => f !== 'index').forEach(f => {
src.filter(f => f !== 'index').forEach((f) => {
it(`should export ${f}`, () => {
assert.equal(
core[f],
require(path.join('../../src/', f)).default // eslint-disable-line global-require
require(path.join('../../src/', f)).default // eslint-disable-line
);
});

it(`should export ${f} from root`, () => {
const file = `${f}.js`;
const expected = true;
const actual = fs.statSync(path.join(__dirname, file)).isFile();
const actual = fs.statSync(path.join(path.resolve('.'), file)).isFile();

assert.equal(expected, actual);
});
Expand Down
File renamed without changes.
35 changes: 22 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@
"scripts": {
"build": "rimraf lib && babel src --out-dir lib",
"prepublish": "npm run lint && npm run test && npm run build",
"coveralls": "cat ./reports/coverage/lcov.info | coveralls",
"coveralls": "cat ./reports/lcov.info | coveralls",
"lint": "eslint --config .eslintrc .",
"lint:fix": "npm run lint -- --fix",
"pretest": "npm run lint",
"test": "istanbul cover -x '**/lib/**' --dir reports/coverage node_modules/mocha/bin/_mocha tests/**/*.js -- --compilers js:babel-core/register --reporter dot"
"test": "jest --coverage"
},
"devDependencies": {
"acorn-jsx": "^3.0.1",
"babel-cli": "^6.6.0",
"babel-core": "^6.6.0",
"babel-eslint": "^6.0.0",
"babel-preset-es2015": "^6.6.0",
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-eslint": "^7.0.0",
"babel-jest": "^16.0.0",
"babel-polyfill": "^6.16.0",
"babel-preset-es2015": "^6.14.0",
"coveralls": "^2.11.8",
"eslint": "^2.11.1",
"eslint-config-airbnb-base": "^3.0.1",
"eslint-plugin-import": "^1.8.1",
"istanbul": "^1.0.0-alpha.2",
"mocha": "^2.4.5",
"eslint": "^3.0.0",
"eslint-config-airbnb-base": "^8.0.0",
"eslint-plugin-import": "^1.16.0",
"jest": "^16.0.1",
"rimraf": "^2.5.2"
},
"engines": {
"node": ">=0.10.0"
"node": ">=4.0"
},
"keywords": [
"jsx",
Expand All @@ -41,6 +42,14 @@
},
"license": "MIT",
"dependencies": {
"acorn-jsx": "^3.0.1",
"object-assign": "^4.1.0"
},
"jest": {
"coverageReporters": [
"lcov"
],
"coverageDirectory": "reports",
"testPathIgnorePatterns": ["/node_modules/", "helper.js"]
}
}
4 changes: 2 additions & 2 deletions src/getProp.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const DEFAULT_OPTIONS = {
*
*/
export default function getProp(props = [], prop = '', options = DEFAULT_OPTIONS) {
let nodeProp = undefined;
let nodeProp;
const propToFind = options.ignoreCase ? prop.toUpperCase() : prop;

const hasProp = props.some(attribute => {
const hasProp = props.some((attribute) => {
// If the props contain a spread prop, then skip.
if (attribute.type === 'JSXSpreadAttribute') {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/hasProp.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const DEFAULT_OPTIONS = {
export default function hasProp(props = [], prop = '', options = DEFAULT_OPTIONS) {
const propToCheck = options.ignoreCase ? prop.toUpperCase() : prop;

return props.some(attribute => {
return props.some((attribute) => {
// If the props contain a spread prop, then refer to strict param.
if (attribute.type === 'JSXSpreadAttribute') {
return !options.spreadStrict;
Expand Down
12 changes: 6 additions & 6 deletions src/values/expressions/BinaryExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export default function extractValueFromBinaryExpression(value) {
case '>=':
return leftVal >= rightVal;
case '<<':
return leftVal << rightVal;
return leftVal << rightVal; // eslint-disable-line no-bitwise
case '>>':
return leftVal >> rightVal;
return leftVal >> rightVal; // eslint-disable-line no-bitwise
case '>>>':
return leftVal >>> rightVal;
return leftVal >>> rightVal; // eslint-disable-line no-bitwise
case '+':
return leftVal + rightVal;
case '-':
Expand All @@ -48,11 +48,11 @@ export default function extractValueFromBinaryExpression(value) {
case '%':
return leftVal % rightVal;
case '|':
return leftVal | rightVal;
return leftVal | rightVal; // eslint-disable-line no-bitwise
case '^':
return leftVal ^ rightVal;
return leftVal ^ rightVal; // eslint-disable-line no-bitwise
case '&':
return leftVal & rightVal;
return leftVal & rightVal; // eslint-disable-line no-bitwise
case 'in':
try {
return leftVal in rightVal;
Expand Down
2 changes: 1 addition & 1 deletion src/values/expressions/Identifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const JS_RESERVED = {
export default function extractValueFromIdentifier(value) {
const { name } = value;

if (JS_RESERVED.hasOwnProperty(name)) {
if (Object.hasOwnProperty.call(JS_RESERVED, name)) {
return JS_RESERVED[name];
}

Expand Down
2 changes: 1 addition & 1 deletion src/values/expressions/ObjectExpression.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import getValue from './index';
import assign from 'object-assign';
import getValue from './index';

/**
* Extractor function for an ObjectExpression type value node.
Expand Down
2 changes: 1 addition & 1 deletion src/values/expressions/UnaryExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function extractValueFromUnaryExpression(value) {
case '!':
return !getValue(argument);
case '~':
return ~getValue(argument);
return ~getValue(argument); // eslint-disable-line no-bitwise
case 'delete':
// I believe delete statements evaluate to true.
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/values/expressions/UpdateExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export default function extractValueFromUpdateExpression(value) {

switch (operator) {
case '++':
return prefix ? ++val : val++;
return prefix ? ++val : val++; // eslint-disable-line no-plusplus
case '--':
return prefix ? --val : val--;
return prefix ? --val : val--; // eslint-disable-line no-plusplus
default:
return undefined;
}
Expand Down
8 changes: 4 additions & 4 deletions src/values/expressions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ const noop = () => null;

// Composition map of types to their extractor functions to handle literals.
const LITERAL_TYPES = assign({}, TYPES, {
Literal: value => {
Literal: (value) => {
const extractedVal = TYPES.Literal.call(undefined, value);
const isNull = extractedVal === null;
// This will be convention for attributes that have null
// value explicitly defined (<div prop={null} /> maps to 'null').
return isNull ? 'null' : extractedVal;
},
Identifier: value => {
Identifier: (value) => {
const isUndefined = TYPES.Identifier.call(undefined, value) === undefined;
return isUndefined ? undefined : null;
},
Expand All @@ -58,11 +58,11 @@ const LITERAL_TYPES = assign({}, TYPES, {
LogicalExpression: noop,
MemberExpression: noop,
CallExpression: noop,
UnaryExpression: value => {
UnaryExpression: (value) => {
const extractedVal = TYPES.UnaryExpression.call(undefined, value);
return extractedVal === undefined ? null : extractedVal;
},
UpdateExpression: value => {
UpdateExpression: (value) => {
const extractedVal = TYPES.UpdateExpression.call(undefined, value);
return extractedVal === undefined ? null : extractedVal;
},
Expand Down
Loading

0 comments on commit efff839

Please sign in to comment.