Skip to content
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
105 changes: 28 additions & 77 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,110 +1,61 @@
module.exports = {
"root": true,
"plugins": ["node"],
"extends": ["eslint:recommended", "plugin:node/recommended"],
"env": {
"node": true,
"es6": true,
"jest": true
extends: ["eslint:recommended"],
env: {
node: true,
es6: true,
jest: true
},
"parserOptions": { "ecmaVersion": 2017, "sourceType": "module"},
"rules": {
parserOptions: { ecmaVersion: 2017, sourceType: "module" },
rules: {
"no-useless-escape": "off",
"quote-props": ["error", "as-needed"],
"no-dupe-keys": "error",
"quotes": ["error", "double"],
quotes: ["error", "double"],
"no-undef": "error",
"no-extra-semi": "error",
"semi": "error",
semi: "error",
"no-template-curly-in-string": "error",
"no-caller": "error",
"yoda": "error",
"eqeqeq": "error",
yoda: "error",
eqeqeq: "error",
"global-require": "off",
"brace-style": "error",
"key-spacing": "error",
"space-in-parens": ["error", "never"],
"space-infix-ops": "error",
"indent": ["error", "tab", { "SwitchCase": 1 }],
indent: ["error", "tab", { SwitchCase: 1 }],
"no-extra-bind": "warn",
"no-empty": "off",
"no-multiple-empty-lines": "error",
"no-multi-spaces": "error",
"no-process-exit": "off",
"no-trailing-spaces": "error",
"no-use-before-define": "off",
"no-unused-vars": ["error", { "args": "none" }],
"no-unused-vars": ["error", { args: "none" }],
"no-unsafe-negation": "error",
"no-loop-func": "warn",
"space-before-function-paren": ["error", "never"],
"space-before-blocks": "error",
"object-curly-spacing": ["error", "always"],
"object-curly-newline": ["error", { "consistent": true }],
"keyword-spacing": ["error", {
"after": true,
"overrides": {
"const": { "after": true },
"try": { "after": true },
"throw": { "after": true },
"case": { "after": true },
"return": { "after": true },
"finally": { "after": true },
"do": { "after": true }
}
}],
"no-console": "off",
"valid-jsdoc": "error",
"node/no-unsupported-features": ["error", { "version": 6 }],
"node/no-deprecated-api": "error",
"node/no-missing-import": "error",
"node/no-missing-require": [
"error",
{
"resolvePaths": ["./packages"],
"allowModules": [
"webpack",
"@webpack-cli/generators",
"@webpack-cli/init",
"@webpack-cli/migrate",
"@webpack-cli/utils",
"@webpack-cli/generate-loader",
"@webpack-cli/generate-plugin",
"@webpack-cli/webpack-scaffold"
]
}
],
"node/no-unpublished-bin": "error",
"node/no-unpublished-require": [
"object-curly-newline": ["error", { consistent: true }],
"keyword-spacing": [
"error",
{
"allowModules": [
"webpack",
"webpack-dev-server",
"@webpack-cli/generators",
"@webpack-cli/init",
"@webpack-cli/migrate",
"@webpack-cli/utils",
"@webpack-cli/generate-loader",
"@webpack-cli/generate-plugin",
"@webpack-cli/webpack-scaffold"
]
}
],
"node/no-extraneous-require": [
"error",
{
"allowModules": [
"@webpack-cli/migrate",
"@webpack-cli/generators",
"@webpack-cli/utils",
"@webpack-cli/generate-loader",
"@webpack-cli/generate-plugin",
"@webpack-cli/webpack-scaffold"
]
after: true,
overrides: {
const: { after: true },
try: { after: true },
throw: { after: true },
case: { after: true },
return: { after: true },
finally: { after: true },
do: { after: true }
}
}
],
"no-console": "off",
"valid-jsdoc": "error",
"eol-last": ["error", "always"],
"newline-per-chained-call": "off",
"node/process-exit-as-throw": "error"
"newline-per-chained-call": "off"
}
};
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ In case you are suggesting a new feature, we will match your idea with our curre
* You can run the linters:

```bash
npm run lint && npm run tslint
npm run lint
```

### Using yarn
Expand Down Expand Up @@ -150,7 +150,7 @@ In case you are suggesting a new feature, we will match your idea with our curre
* You can run the linters:

```bash
yarn lint && yarn tslint
yarn lint
```

## Editor Config
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ yarn.lock

# source maps of docs
docs/**/*.map
junit.xml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

63 changes: 63 additions & 0 deletions bin/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
module.exports = {
root: true,
plugins: ["node"],
extends: ["../.eslintrc.js", "plugin:node/recommended"],
env: {
node: true,
es6: true,
jest: true
},
parserOptions: { ecmaVersion: 2017, sourceType: "module" },
rules: {
"node/no-unsupported-features": ["error", { version: 6 }],
"node/no-deprecated-api": "error",
"node/no-missing-import": "error",
"node/no-missing-require": [
"error",
{
resolvePaths: ["./packages"],
allowModules: [
"webpack",
"@webpack-cli/generators",
"@webpack-cli/init",
"@webpack-cli/migrate",
"@webpack-cli/utils",
"@webpack-cli/generate-loader",
"@webpack-cli/generate-plugin",
"@webpack-cli/webpack-scaffold"
]
}
],
"node/no-unpublished-bin": "error",
"node/no-unpublished-require": [
"error",
{
allowModules: [
"webpack",
"webpack-dev-server",
"@webpack-cli/generators",
"@webpack-cli/init",
"@webpack-cli/migrate",
"@webpack-cli/utils",
"@webpack-cli/generate-loader",
"@webpack-cli/generate-plugin",
"@webpack-cli/webpack-scaffold"
]
}
],
"node/no-extraneous-require": [
"error",
{
allowModules: [
"@webpack-cli/migrate",
"@webpack-cli/generators",
"@webpack-cli/utils",
"@webpack-cli/generate-loader",
"@webpack-cli/generate-plugin",
"@webpack-cli/webpack-scaffold"
]
}
],
"node/process-exit-as-throw": "error"
}
};
23 changes: 11 additions & 12 deletions bin/utils/prompt-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ const npmGlobalRoot = () => {
const cp = require("child_process");
return new Promise((resolve, reject) => {
const command = cp.spawn("npm", ["root", "-g"]);
command.on("error", (error) => reject(error));
command.stdout.on("data", (data) => resolve(data.toString()));
command.stderr.on("data", (data) => reject(data));
command.on("error", error => reject(error));
command.stdout.on("data", data => resolve(data.toString()));
command.stderr.on("data", data => reject(data));
});
};

const runWhenInstalled = (packages, pathForCmd, ...args) => {
const package = require(pathForCmd);
const func = package.default;
if (typeof func !== 'function') {
const currentPackage = require(pathForCmd);
const func = currentPackage.default;
if (typeof func !== "function") {
throw new Error(`@webpack-cli/${packages} failed to export a default function`);
}
return func(...args);
}
};

module.exports = function promptForInstallation(packages, ...args) {
const nameOfPackage = "@webpack-cli/" + packages;
Expand Down Expand Up @@ -102,19 +102,18 @@ module.exports = function promptForInstallation(packages, ...args) {
case "y":
case "yes":
case "1": {

runCommand(packageManager, options)
.then(_=> {
.then(_ => {
if (packages === "init") {
npmGlobalRoot()
.then((root) => {
.then(root => {
const pathtoInit = path.resolve(root.trim(), "@webpack-cli", "init");
return pathtoInit;
})
.then((pathForInit) => {
.then(pathForInit => {
return require(pathForInit).default(...args);
})
.catch((error) => {
.catch(error => {
console.error(error);
process.exitCode = 1;
});
Expand Down
Loading