Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Prettier 💅 #393

Merged
merged 8 commits into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "interactivethings",
"extends": ["interactivethings", "prettier", "prettier/react"],
"parser": "babel-eslint",
"globals": {
"expect": true,
Expand Down
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package.json
dist
docs/build
flow-typed
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
}
2 changes: 1 addition & 1 deletion babel.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/babel/preset');
module.exports = require("./dist/babel/preset");
33 changes: 18 additions & 15 deletions cli/src/actions/detectFramework.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
// @flow
import {resolveAppPath} from '../utils/paths';
import {exists} from 'sander';
import { resolveAppPath } from "../utils/paths";
import { exists } from "sander";

// Framework types Catalog supports
type UNKNOWN = 'UNKNOWN';
type CREATE_REACT_APP = 'CREATE_REACT_APP';
type NEXT = 'NEXT';
type UNKNOWN = "UNKNOWN";
type CREATE_REACT_APP = "CREATE_REACT_APP";
type NEXT = "NEXT";

export type Framework = UNKNOWN | CREATE_REACT_APP | NEXT;

export default async (): Promise<Framework> => {
const appPackagePath = resolveAppPath('package.json');
const appPackagePath = resolveAppPath("package.json");
const appPackageExists = await exists(appPackagePath);

if (!appPackageExists) {
return 'UNKNOWN';
return "UNKNOWN";
}

const appPackage = require(appPackagePath);
if (
(appPackage.dependencies && appPackage.dependencies.hasOwnProperty('react-scripts')) ||
(appPackage.devDependencies && appPackage.devDependencies.hasOwnProperty('react-scripts'))
(appPackage.dependencies &&
appPackage.dependencies.hasOwnProperty("react-scripts")) ||
(appPackage.devDependencies &&
appPackage.devDependencies.hasOwnProperty("react-scripts"))
) {
return 'CREATE_REACT_APP';
return "CREATE_REACT_APP";
}

if (
(appPackage.dependencies && appPackage.dependencies.hasOwnProperty('next')) ||
(appPackage.devDependencies && appPackage.devDependencies.hasOwnProperty('next'))
(appPackage.dependencies &&
appPackage.dependencies.hasOwnProperty("next")) ||
(appPackage.devDependencies &&
appPackage.devDependencies.hasOwnProperty("next"))
) {
return 'NEXT';
return "NEXT";
}

return 'UNKNOWN';
return "UNKNOWN";
};

6 changes: 3 additions & 3 deletions cli/src/actions/loadConfigFile.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// @flow
import {resolveAppPath} from '../utils/paths';
import {exists} from 'sander';
import { resolveAppPath } from "../utils/paths";
import { exists } from "sander";

type ConfigFile = {
webpack?: Function,
useBabelrc?: boolean
} | null;

export default async (): Promise<ConfigFile> => {
const configFilePath = resolveAppPath('catalog.config.js');
const configFilePath = resolveAppPath("catalog.config.js");
const configFileExists = await exists(configFilePath);
return configFileExists ? require(configFilePath) : null;
};
45 changes: 29 additions & 16 deletions cli/src/actions/loadPaths.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
// @flow
import {resolveAppPath, resolveOwnPath, nodePaths, ensureSlash} from '../utils/paths';

export default async (catalogSrcDir: string, catalogBuildDir: string, framework: string, publicUrl: string) => ({
import {
resolveAppPath,
resolveOwnPath,
nodePaths,
ensureSlash
} from "../utils/paths";

export default async (
catalogSrcDir: string,
catalogBuildDir: string,
framework: string,
publicUrl: string
) => ({
unresolvedCatalogSrcDir: catalogSrcDir,
unresolvedCatalogBuildDir: catalogBuildDir,
catalogSrcDir: resolveAppPath(catalogSrcDir),
catalogBuildDir: resolveAppPath(catalogBuildDir),
catalogIndexJs: resolveAppPath(catalogSrcDir, 'index.js'),
catalogIndexHtml: resolveAppPath(catalogSrcDir, 'index.html'),
catalogStaticSrcDir: resolveAppPath(catalogSrcDir, 'static'),
catalogIndexJs: resolveAppPath(catalogSrcDir, "index.js"),
catalogIndexHtml: resolveAppPath(catalogSrcDir, "index.html"),
catalogStaticSrcDir: resolveAppPath(catalogSrcDir, "static"),
catalogStaticBuildDir: resolveAppPath(catalogBuildDir),

catalogSrcTemplateDir: resolveOwnPath('..', 'setup-template'),
catalogSrcTemplateDir: resolveOwnPath("..", "setup-template"),

appRoot: resolveAppPath('.'),
appStaticSrcDir: framework === 'NEXT' ? resolveAppPath('static') : resolveAppPath('public'),
appStaticBuildDir: framework === 'NEXT' ? resolveAppPath(catalogBuildDir, 'static') : resolveAppPath(catalogBuildDir),
appRoot: resolveAppPath("."),
appStaticSrcDir:
framework === "NEXT" ? resolveAppPath("static") : resolveAppPath("public"),
appStaticBuildDir:
framework === "NEXT"
? resolveAppPath(catalogBuildDir, "static")
: resolveAppPath(catalogBuildDir),

appPackageJson: resolveAppPath('package.json'),
appSrc: resolveAppPath('src'),
yarnLockFile: resolveAppPath('yarn.lock'),
babelrc: resolveAppPath('.babelrc'),
appNodeModules: resolveAppPath('node_modules'),
ownNodeModules: resolveOwnPath('..', '..', 'node_modules'),
appPackageJson: resolveAppPath("package.json"),
appSrc: resolveAppPath("src"),
yarnLockFile: resolveAppPath("yarn.lock"),
babelrc: resolveAppPath(".babelrc"),
appNodeModules: resolveAppPath("node_modules"),
ownNodeModules: resolveOwnPath("..", "..", "node_modules"),
nodePaths: nodePaths,

publicUrl: ensureSlash(publicUrl, true)
Expand Down
Loading