Skip to content

Commit

Permalink
Update all build, test, lint things
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalduez committed Jan 26, 2019
1 parent 00a0060 commit ebfea41
Show file tree
Hide file tree
Showing 11 changed files with 2,545 additions and 2,177 deletions.
11 changes: 5 additions & 6 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
{
"presets": [
[
"env",
"@babel/preset-env",
{
"targets": {
"node": 6
"node": 8
}
}
],
"flow"
"@babel/preset-flow"
],
"plugins": [
"transform-class-properties",
"transform-object-rest-spread",
"transform-object-entries"
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-do-expressions"
]
}
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ env:
jest: true

rules:
one-var: off
prefer-const: off
no-use-before-define:
- error
- functions: false
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
dist
coverage
flow-coverage
.jest-cache
7 changes: 4 additions & 3 deletions develop/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import postcss from 'postcss';
import reporter from 'postcss-reporter';
import plugin from '../src';

const read = name =>
let from, to;
let read = name =>
fs.readFileSync(path.join(process.cwd(), 'test', 'fixture', name), 'utf8');

const input = read('apply/input.css');
let input = read('apply/input.css');

postcss()
.use(plugin)
.use(reporter)
.process(input)
.process(input, { from, to })
.then(result => {
console.log(result.css);
})
Expand Down
3 changes: 0 additions & 3 deletions index.js

This file was deleted.

15 changes: 15 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const isCI = require('is-ci');

const config = {
testEnvironment: 'node',
cacheDirectory: '.jest-cache',
collectCoverageFrom: ['src/*.js'],
};

if (isCI) {
Object.assign(config, {
collectCoverage: true,
});
}

module.exports = config;
76 changes: 34 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,57 +26,49 @@
"README.md",
"UNLICENSE"
],
"engines": {
"node": ">=6.0.0"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"scripts": {
"lint": "eslint src/ test/",
"typecheck": "flow check src/",
"typecheck:coverage": "flow-coverage-report -t text -t html -i 'src/**/*.js'",
"validate": "run-s lint typecheck",
"validate": "run-s lint",
"test": "jest",
"test:cover": "run-s 'test --coverage'",
"test:cover:browse": "run-s test:cover && opn coverage/lcov-report/index.html",
"test:ci": "run-s lint test:cover",
"test:ci": "run-s validate test",
"develop": "babel-node develop/",
"clean": "rm -rf dist/",
"build:js": "babel src/ -d dist/",
"build": "run-s clean build:*",
"prepublishOnly": "run-s validate test:cover",
"prepare": "run-s build"
},
"jest": {
"testEnvironment": "node",
"collectCoverageFrom": [
"src/*.js"
]
"prebuild": "rm -rf dist/",
"build": "rollup -c",
"prepare": "run-s build",
"prepublishOnly": "run-s validate test"
},
"dependencies": {
"babel-runtime": "^6.26.0",
"balanced-match": "^1.0.0",
"postcss": "^7.0.2"
"postcss": "^7.0.14"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-eslint": "^8.2.6",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-entries": "^1.0.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-flow": "^6.23.0",
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.3.0",
"@babel/plugin-proposal-do-expressions": "^7.2.0",
"@babel/preset-env": "^7.3.1",
"@babel/preset-flow": "^7.0.0",
"babel-eslint": "^10.0.1",
"common-tags": "^1.8.0",
"eslint": "^5.3.0",
"eslint-config-airbnb-base": "^13.0.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-flowtype": "^2.50.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-jest": "^21.20.2",
"flow-bin": "^0.78.0",
"flow-coverage-report": "^0.5.0",
"jest-cli": "^23.5.0",
"npm-run-all": "^4.1.3",
"opn-cli": "^3.1.0",
"postcss-custom-properties": "^7.0.0",
"postcss-reporter": "^5.0.0"
"eslint": "^5.12.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-prettier": "^4.0.0",
"eslint-plugin-flowtype": "^3.2.1",
"eslint-plugin-import": "^2.15.0",
"eslint-plugin-jest": "^22.1.3",
"flow-bin": "^0.91.0",
"flow-coverage-report": "^0.6.1",
"jest": "^24.0.0",
"npm-run-all": "^4.1.5",
"opn-cli": "^4.0.0",
"postcss-custom-properties": "^8.0.9",
"postcss-reporter": "^6.0.1",
"rollup": "^1.1.2",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^4.0.0"
}
}
28 changes: 28 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import json from 'rollup-plugin-json';
import pkg from './package.json';

export default {
plugins: [
babel({
exclude: ['node_modules/**'],
}),
json(),
resolve(),
commonjs(),
],
external: ['postcss', 'balanced-match'],
input: 'src/index.js',
output: [
{
file: pkg.main,
format: 'cjs',
},
{
file: pkg.module,
format: 'esm',
},
],
};
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// @flow
import { plugin } from 'postcss';
import Visitor, { type Options } from './visitor';
import { name } from '../package.json';

export default plugin(
'postcss-apply',
name,
(options: Options) => (css: Object, result: Object) => {
const visitor = new Visitor(options);
visitor.result = result;
Expand Down
2 changes: 1 addition & 1 deletion test/prepend.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('prepend', () => {
postcss() // eslint-disable-line no-unused-expressions
.use(plugin({ sets }))
.process(input, { from: undefined }).css;
}).toThrowError(
}).toThrow(
'Unrecognized set type `function`, must be an object or string.'
);
});
Expand Down
Loading

0 comments on commit ebfea41

Please sign in to comment.