Skip to content

Commit c3c2bc4

Browse files
committed
Fix: eslint fix
1 parent f7d2765 commit c3c2bc4

File tree

6 files changed

+33
-29
lines changed

6 files changed

+33
-29
lines changed

.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module.exports = {
22
env: {
33
commonjs: true,
4-
es6: true,
4+
es2020: true,
55
node: true,
66
},
77
extends: ["airbnb-base"],
88
parserOptions: {
9-
ecmaVersion: 6,
9+
ecmaVersion: 2020,
1010
},
1111
rules: {
1212
quotes: [2, "double", { avoidEscape: true }],

commands/basec/index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
/* eslint-disable no-use-before-define */
2+
/* eslint-disable global-require */
13
module.exports = (args, api) => {
24
const fs = require("fs");
3-
const { EOL } = require('os');
4-
const { RED } = require("./../../utils/colors");
5+
const { EOL } = require("os");
6+
const { RED } = require("../../utils/colors");
57
const componentName = args._[0];
6-
const scaffoldButton = args['scaffold-button'];
8+
const scaffoldButton = args["scaffold-button"];
79
const preffix = args.preffix ?? "Base";
810

911
if (componentName || scaffoldButton) {
@@ -16,21 +18,21 @@ module.exports = (args, api) => {
1618
}
1719
const strMatch = scaffoldButton ? /name: "BaseButton",/ : /name: "base",/;
1820
const content = replaceContent(`${__dirname}/templates/Base${scaffoldButton ? "Button" : ""}.vue`, strMatch, ` name: "${filename}",`);
19-
fs.writeFileSync(dirPath, content.join(EOL), { encoding: 'utf-8' });
21+
fs.writeFileSync(dirPath, content.join(EOL), { encoding: "utf-8" });
2022
console.log(`\n${filename} created succesfully`);
2123
} else {
2224
console.log(RED, "\nError: You must supply either a name or a scaffold option");
2325
}
2426

2527
function replaceContent(path, strMatch, strReplace) {
26-
const content = fs.readFileSync(path, { encoding: 'utf-8' });
28+
const content = fs.readFileSync(path, { encoding: "utf-8" });
2729
const lines = content.split(/\r?\n/g);
28-
const renderIndex = lines.findIndex(line => line.match(strMatch));
30+
const renderIndex = lines.findIndex((line) => line.match(strMatch));
2931
lines[renderIndex] = strReplace;
3032
return lines;
3133
}
3234

3335
function capitalize(str) {
3436
return str[0].toUpperCase() + str.substring(1);
3537
}
36-
}
38+
};

generator/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const fs = require("fs");
44
const path = require("path");
55
const optionals = require("../optionals/index");
6+
const colors = require("../utils/colors");
67

78
const { log } = console;
89

@@ -17,8 +18,8 @@ module.exports = (api, options) => {
1718
optionals.addBaseComponents(api);
1819
api.extendPackage({
1920
scripts: {
20-
basec: 'vue-cli-service basec'
21-
}
21+
basec: "vue-cli-service basec",
22+
},
2223
});
2324
}
2425

@@ -38,7 +39,6 @@ module.exports = (api, options) => {
3839
}
3940

4041
function showLogs() {
41-
const colors = require("./../utils/colors");
4242
log("\n");
4343
for (const file of deletedFiles) log(colors.RED, "Deleted file: ", file);
4444
for (const file of modifiedFiles) log(colors.YELLOW, "Modified file: ", file);

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const basec = require("./commands/basec/index")
1+
const basec = require("./commands/basec/index");
22

3-
module.exports = (api, options) => {
3+
module.exports = (api) => {
44
api.registerCommand("basec", {
55
description: "Generates a new base component",
66
usage: "vue-cli-service basec name [options]",
77
options: {
8-
"name": "The name of the component",
8+
name: "The name of the component",
99
"--scaffold-button": "Generates a predefined base component for a button",
10-
"--preffix": "The preffix for the name of the component. By default 'Base'"
11-
}
10+
"--preffix": "The preffix for the name of the component. By default 'Base'",
11+
},
1212
}, (args) => basec(args, api));
1313
};

ui.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
module.exports = api => {
1+
module.exports = (api) => {
22
api.describeTask({
33
match: /vue-cli-service basec/,
44
description: "Generates a new base component",
5-
link: 'https://github.com/DevTony101/vue-cli-plugin-clean#features-',
5+
link: "https://github.com/DevTony101/vue-cli-plugin-clean#features-",
66
icon: "description",
77
prompts: [
88
{
99
name: "name",
1010
type: "input",
1111
default: "button",
12-
description: "The name of the base component (without the preffix)"
12+
description: "The name of the base component (without the preffix)",
1313
},
1414
{
1515
name: "preffix",
1616
type: "input",
1717
default: "Base",
18-
description: "The preffix for the name of the component (it defaults to 'Base')"
18+
description: "The preffix for the name of the component (it defaults to 'Base')",
1919
},
2020
{
2121
name: "scaffold",
@@ -24,15 +24,15 @@ module.exports = api => {
2424
choices: [
2525
{
2626
name: "button",
27-
value: "button"
27+
value: "button",
2828
},
2929
{
3030
name: "none",
31-
value: "none"
32-
}
31+
value: "none",
32+
},
3333
],
34-
description: "If different of none, it will create a base component with a predefined template for the selected option"
35-
}
34+
description: "If different of none, it will create a base component with a predefined template for the selected option",
35+
},
3636
],
3737
onBeforeRun: async ({ answers, args }) => {
3838
if (answers.name && answers.name.trim()) args.push(answers.name);
@@ -41,7 +41,9 @@ module.exports = api => {
4141
case "button":
4242
args.push("--scaffold-button");
4343
break;
44+
default:
45+
break;
4446
}
45-
}
47+
},
4648
});
47-
}
49+
};

utils/colors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module.exports = {
22
GREEN: "\x1b[32m%s\x1b[0m",
33
RED: "\x1b[31m%s\x1b[0m",
44
YELLOW: "\x1b[33m%s\x1b[0m",
5-
};
5+
};

0 commit comments

Comments
 (0)