Skip to content
This repository was archived by the owner on Mar 10, 2023. It is now read-only.

Commit 51df188

Browse files
author
Lucas
committed
style: lint all packages and modifying eslint rules
1 parent 21daadc commit 51df188

File tree

13 files changed

+59
-54
lines changed

13 files changed

+59
-54
lines changed

.eslintrc.json

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,18 @@
3232
// PropType.Shape seems buggy
3333
"react/no-unused-prop-types": [2, { "skipShapeProps": true }],
3434
"import/extensions" : 0,
35-
"import/no-unresolved": [2, {
36-
"ignore": [
37-
// App dependancies, as global modules
38-
"__app_modules__",
39-
// Peer dependancies
40-
"react",
41-
"react-dom"
42-
]
43-
} ]
35+
"import/no-extraneous-dependencies": 0,
36+
"import/no-unresolved": 0,
37+
"function-paren-newline": [2, "consistent"],
38+
"object-curly-newline": [2, {
39+
"consistent": true
40+
}],
41+
"comma-dangle": [2, {
42+
"arrays": "always-multiline",
43+
"objects": "always-multiline",
44+
"imports": "always-multiline",
45+
"exports": "always-multiline",
46+
"functions": "never"
47+
}]
4448
}
4549
}

packages/vitaminjs-build/bin/vitamin.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const build = (options, hotCallback, restartServer) => (options.hot ?
134134
hotCallback,
135135
restartServer,
136136
)
137-
:
137+
:
138138
commonBuild(webpackConfigClient, 'client bundle(s)', options)
139139
.then(({ buildStats }) => commonBuild(
140140
webpackConfigServer, 'server bundle...',
@@ -263,8 +263,7 @@ program
263263
}
264264
process.exit(1);
265265
});
266-
}
267-
);
266+
});
268267

269268
program
270269
.command('clean')
@@ -286,8 +285,7 @@ program
286285
console.log(err.stack || err);
287286
}
288287
process.exit(1);
289-
}),
290-
);
288+
}));
291289

292290
program
293291
.command('serve')

packages/vitaminjs-build/config/build/webpack.config.client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = function clientConfig(options) {
3232
options.hot && new webpack.NoEmitOnErrorsPlugin(),
3333
!options.dev && new webpack.optimize.UglifyJsPlugin({
3434
sourceMap: options.withSourceMaps,
35-
minimize: true
35+
minimize: true,
3636
}),
3737
options.client.serviceWorker && new ServiceWorkerWebpackPlugin({
3838
// FIXME Move resolving with other config props
@@ -47,4 +47,4 @@ module.exports = function clientConfig(options) {
4747
module: 'empty',
4848
},
4949
}, concat);
50-
}
50+
};

packages/vitaminjs-build/config/build/webpack.config.common.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ function createBabelLoader(env, options) {
1818
return {
1919
test: /\.js(x?)$/,
2020
loader: 'babel-loader',
21-
include: path => {
21+
include: path =>
2222
// We only want to transpile user land application code and our own runtime
23-
return (
23+
(
2424
!isExternalModulePath(path) ||
2525
__isVitaminFacadeModulePath(path) ||
2626
isRuntimeModulePath(path) ||
27-
// FIXME This is only required for parts of the runtime that require the build system
27+
// FIXME This is only required for parts of the runtime
28+
// that require the build system
2829
isBuildModulePath(path)
29-
);
30-
},
30+
),
3131
query: babelrc(env, options),
3232
};
3333
}
@@ -112,7 +112,7 @@ function config(options) {
112112
resolve: {
113113
alias: {
114114
...options.moduleMap,
115-
'__vitamin_runtime_config__': require.resolve('../runtimeConfig'),
115+
__vitamin_runtime_config__: require.resolve('../runtimeConfig'),
116116
},
117117
// Commmented out beause absolute paths were opting out of node resolve algorithm
118118
// modules: MODULES_DIRECTORIES,

packages/vitaminjs-build/config/build/webpack.config.server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function externals(context, request, callback) {
2525
!__hasWebpackLoader(request)
2626
) {
2727
// FIXME Why commonjs2 over commonjs
28-
callback(null, 'commonjs2 ' + request);
28+
callback(null, `commonjs2 + ${request}`);
2929
return;
3030
}
3131

@@ -77,4 +77,4 @@ module.exports = function serverConfig(options) {
7777
}),
7878
].filter(Boolean),
7979
}, concat);
80-
}
80+
};

packages/vitaminjs-build/config/build/webpack.config.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ module.exports = function testConfig(options) {
2424
'react/lib/ReactContext': true,
2525
},
2626
}, concat);
27-
}
27+
};

packages/vitaminjs-build/config/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ function loadExtendedConfig(config, configPath) {
8585
}
8686

8787

88-
const rcPath = exports.rcPath = resolveRcPath();
88+
const rcPath = resolveRcPath();
89+
exports.rcPath = rcPath;
8990

9091
exports.default = () => {
9192
let config = loadConfigFile(rcPath);
@@ -119,16 +120,16 @@ exports.default = () => {
119120
const moduleMap = getModuleMap(modulePaths);
120121

121122
// Cleanify config export by removing module paths
122-
modulePaths.forEach(path =>
123-
deletePath(path, config),
123+
modulePaths.forEach(
124+
path => deletePath(path, config)
124125
);
125126

126127
// Resolve app path to absolute paths
127128
[
128129
['server', 'buildPath'],
129130
['client', 'buildPath'],
130-
].forEach(path =>
131-
updatePath(path, resolveConfigPath, config),
131+
].forEach(
132+
path => updatePath(path, resolveConfigPath, config),
132133
);
133134

134135
// Prepend / to publicPath and basePath if necessary

packages/vitaminjs-build/config/resolve.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,6 @@ function resolveModule(id, basedir) {
1414
return resolve.sync(id, { basedir, extensions: ['.js', '.jsx'] });
1515
}
1616

17-
function resolveConfigModule(id) {
18-
// This is used in a context with the following dependency graph:
19-
// app -> vitaminjs
20-
// vitaminjs -> vitaminjs-build
21-
// vitaminjs -> vitaminjs-runtime -> vitaminjs-build
22-
// So runtime package resolving will not always be relative to the app
23-
// (where the .vitaminrc file is located). We try resolve the runtime
24-
// package by walking up the dependency tree.
25-
if (id.startsWith('__vitamin_runtime__/')) {
26-
return resolveParentModule(id.replace('__vitamin_runtime__', 'vitaminjs-runtime'));
27-
}
28-
// .vitaminrc relative resolution
29-
return resolveModule(id, dirname(resolveRcPath()));
30-
}
31-
3217
// FIXME Consider not exporting this function anymore but use webpack's "context" config
3318
function resolveParentModule(id) {
3419
// Sample node modules paths for 'vitaminjs-runtime/src/server/components/HTMLLayout',
@@ -56,6 +41,21 @@ function resolveParentModule(id) {
5641
return resolveModule(id, basedir);
5742
}
5843

44+
function resolveConfigModule(id) {
45+
// This is used in a context with the following dependency graph:
46+
// app -> vitaminjs
47+
// vitaminjs -> vitaminjs-build
48+
// vitaminjs -> vitaminjs-runtime -> vitaminjs-build
49+
// So runtime package resolving will not always be relative to the app
50+
// (where the .vitaminrc file is located). We try resolve the runtime
51+
// package by walking up the dependency tree.
52+
if (id.startsWith('__vitamin_runtime__/')) {
53+
return resolveParentModule(id.replace('__vitamin_runtime__', 'vitaminjs-runtime'));
54+
}
55+
// .vitaminrc relative resolution
56+
return resolveModule(id, dirname(resolveRcPath()));
57+
}
58+
5959
function isExternalModulePath(path) {
6060
// There is a theoretical edge case when the application is contained in a
6161
// parent directory called "node_modules". In that case any internal
@@ -74,6 +74,7 @@ function isExternalModule(id) {
7474
return !INTERNAL_REGEXP.test(id);
7575
}
7676

77+
// eslint-disable-next-line no-unused-vars
7778
function isRuntimeModule(id, basedir) {
7879
// FIXME
7980
return /vitaminjs-runtime/.test(id);

packages/vitaminjs-runtime/src/server/middlewares/router.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import routes from '__app_modules__routes__';
55
const routesWithStore = typeof routes === 'function' ? store => routes(store) : () => routes;
66

77
export default () => async (ctx, next) => {
8-
const url = ctx.req.url;
9-
const history = ctx.state.history;
8+
const { url } = ctx.req;
9+
const { history } = ctx.state;
1010

1111
const appRoutes = await routesWithStore(ctx.state.store);
1212

1313
await new Promise((resolve, reject) => {
14-
match({ routes: appRoutes, location: url, history },
14+
match(
15+
{ routes: appRoutes, location: url, history },
1516
(error, redirectLocation, renderProps) => {
1617
if (error) {
1718
reject(error);

packages/vitaminjs-runtime/src/server/server.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable global-require, no-console */
1+
/* eslint-disable indent,global-require,no-console */
22

33
import { parse as parseUrl } from 'url';
44
import Koa from 'koa';
@@ -8,8 +8,8 @@ import fetch from 'node-fetch';
88
import readline from 'readline';
99
import httpGracefulShutdown from 'http-graceful-shutdown';
1010

11-
import appMiddleware from './appMiddleware';
1211
import config from '__vitamin_runtime_config__';
12+
import appMiddleware from './appMiddleware';
1313

1414
global.fetch = fetch;
1515

@@ -49,7 +49,8 @@ if (process.env.NODE_ENV !== 'production' && module.hot) {
4949
return;
5050
}
5151
clientBuilt = true;
52-
process.stdout.write(`\x1b[0G${chalk.green('\u2713')
52+
process.stdout.write(
53+
`\x1b[0G${chalk.green('\u2713')
5354
} Client bundle(s) successfully ${chalk.bold('built in memory')}\n\n`,
5455
);
5556
},

0 commit comments

Comments
 (0)