Skip to content

Commit

Permalink
use prettier defaults other than tabWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Feb 22, 2023
1 parent 6e3484b commit 4c80df2
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 121 deletions.
5 changes: 1 addition & 4 deletions packages/rollup-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@
},
"prettier": {
"filepath": "input.js",
"trailingComma": "none",
"arrowParens": "avoid",
"tabWidth": 4,
"singleQuote": true
"tabWidth": 4
},
"babel": {
"presets": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { usePluginState } from '@wq/react';
import { List, ListItem } from '@wq/material';
import React from "react";
import { usePluginState } from "@wq/react";
import { List, ListItem } from "@wq/material";

export default function Test() {
const state = usePluginState('myPlugin');
const state = usePluginState("myPlugin");
return (
<List>
{state.values.map(value => (
{state.values.map((value) => (
<ListItem key={value.id}>{value.label}</ListItem>
))}
</List>
Expand Down
16 changes: 8 additions & 8 deletions packages/rollup-plugin/src/__tests__/fixtures/plugin/input.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import Test from './Component';
import Test from "./Component";

export default {
name: 'myPlugin',
name: "myPlugin",
actions: {
setValues(payload) {
return {
type: 'MYPLUGIN_SET_VALUES',
payload
type: "MYPLUGIN_SET_VALUES",
payload,
};
}
},
},
reducer(state, action) {
switch (action.type) {
case 'MYPLUGIN_SET_VALUES':
case "MYPLUGIN_SET_VALUES":
return { values: action.payload };
default:
return state || { values: [] };
}
},
components: {
Test
}
Test,
},
};
30 changes: 15 additions & 15 deletions packages/rollup-plugin/src/__tests__/fixtures/plugin/output.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { modules } from './wq.js';
import { modules } from "./wq.js";

const { react: React } = modules;

const { '@wq/react': react } = modules;
const { "@wq/react": react } = modules;

const { '@wq/material': material } = modules;
const { "@wq/material": material } = modules;

function Test() {
const state = react.usePluginState('myPlugin');
const state = react.usePluginState("myPlugin");
return /*#__PURE__*/ React.createElement(
material.List,
null,
state.values.map(value =>
state.values.map((value) =>
/*#__PURE__*/ React.createElement(
material.ListItem,
{
key: value.id
key: value.id,
},
value.label
)
Expand All @@ -24,35 +24,35 @@ function Test() {
}

var input = {
name: 'myPlugin',
name: "myPlugin",
actions: {
setValues(payload) {
return {
type: 'MYPLUGIN_SET_VALUES',
payload
type: "MYPLUGIN_SET_VALUES",
payload,
};
}
},
},

reducer(state, action) {
switch (action.type) {
case 'MYPLUGIN_SET_VALUES':
case "MYPLUGIN_SET_VALUES":
return {
values: action.payload
values: action.payload,
};

default:
return (
state || {
values: []
values: [],
}
);
}
},

components: {
Test
}
Test,
},
};

export default input;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import app from '@wq/app';
import material from '@wq/material';
import mapgl from '@wq/map-gl';
import myPlugin from './plugin.js';
import app from "@wq/app";
import material from "@wq/material";
import mapgl from "@wq/map-gl";
import myPlugin from "./plugin.js";

app.use([material, mapgl, myPlugin]);
10 changes: 5 additions & 5 deletions packages/rollup-plugin/src/__tests__/fixtures/project/output.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { modules } from './wq.js';
import myPlugin from './plugin.js';
import { modules } from "./wq.js";
import myPlugin from "./plugin.js";

const { '@wq/app': app } = modules;
const { "@wq/app": app } = modules;

const { '@wq/material': material } = modules;
const { "@wq/material": material } = modules;
const materialPlugin = material.default;

const { '@wq/map-gl': mapgl } = modules;
const { "@wq/map-gl": mapgl } = modules;
const mapglPlugin = mapgl.default;

app.use([materialPlugin, mapglPlugin, myPlugin]);
54 changes: 27 additions & 27 deletions packages/rollup-plugin/src/__tests__/index.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
import { rollup } from 'rollup';
import wqBundle from '../index.js';
import babel from '@rollup/plugin-babel';
import prettier from 'rollup-plugin-prettier';
import util from 'util';
import fs from 'fs';
import { rollup } from "rollup";
import wqBundle from "../index.js";
import babel from "@rollup/plugin-babel";
import prettier from "rollup-plugin-prettier";
import util from "util";
import fs from "fs";

const readFile = util.promisify(fs.readFile);

process.chdir(__dirname);

test('plugin', async () => {
test("plugin", async () => {
const bundle = await rollup({
input: 'fixtures/plugin/input.js',
input: "fixtures/plugin/input.js",
treeshake: {
propertyReadSideEffects: false
propertyReadSideEffects: false,
},
plugins: [
wqBundle(),
babel({
plugins: ['@babel/transform-react-jsx'],
babelHelpers: 'inline'
plugins: ["@babel/transform-react-jsx"],
babelHelpers: "inline",
}),
prettier()
]
prettier(),
],
}),
output = await bundle.generate({
file: 'output.js',
format: 'esm'
file: "output.js",
format: "esm",
}),
expected = await readFile('fixtures/plugin/output.js', 'utf8');
expected = await readFile("fixtures/plugin/output.js", "utf8");

expect(output.output[0].code).toBe(expected);
});

test('project', async () => {
test("project", async () => {
const bundle = await rollup({
input: 'fixtures/project/input.js',
input: "fixtures/project/input.js",
treeshake: {
propertyReadSideEffects: false
propertyReadSideEffects: false,
},
external: ['./plugin.js'],
external: ["./plugin.js"],
plugins: [
wqBundle(),
babel({
plugins: ['@babel/transform-react-jsx'],
babelHelpers: 'inline'
plugins: ["@babel/transform-react-jsx"],
babelHelpers: "inline",
}),
prettier()
]
prettier(),
],
}),
output = await bundle.generate({
file: 'output.js',
format: 'esm'
file: "output.js",
format: "esm",
}),
expected = await readFile('fixtures/project/output.js', 'utf8');
expected = await readFile("fixtures/project/output.js", "utf8");

expect(output.output[0].code).toBe(expected);
});
Loading

0 comments on commit 4c80df2

Please sign in to comment.