Skip to content

Commit c9189e1

Browse files
committed
chore: Add ESLint
1 parent 77fc62e commit c9189e1

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

.eslintrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": [
3+
"airbnb"
4+
],
5+
"rules": {
6+
"indent": ["error", 4],
7+
"no-var": "error",
8+
"comma-dangle": ["error", "never"],
9+
"no-console": 0
10+
},
11+
"env": {
12+
"node": true
13+
}
14+
}

index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
#!/usr/bin/env node
2-
32
const { execSync } = require('child_process');
4-
const path = require('path');
3+
54
const variablePrefix = 'npm_package_config_deployToGit_';
65
const fields = ['repository', 'branch', 'folder', 'commit', 'script', 'user_name', 'user_email'];
76
const cwd = process.cwd();
87
const config = {};
98

10-
for(const field of fields) {
9+
for (const field of fields) {
1110
const configVar = process.env[`${variablePrefix}${field}`];
1211

13-
if(!configVar) {
12+
if (!configVar) {
1413
throw Error(`deployOnGit requires "${field}" field in package config`);
1514
}
1615

1716
config[field] = configVar.replace(/\$([a-zA-Z0-9_]+)/g, (match, envVarName) => {
1817
const envVar = process.env[envVarName];
1918

20-
if(!envVar) {
21-
throw Error(`Environment variable "${envVarName}" presented at string "${configVar}" is missing`)
19+
if (!envVar) {
20+
throw Error(`Environment variable "${envVarName}" presented at string "${configVar}" is missing`);
2221
}
2322

2423
return envVar;
@@ -32,7 +31,7 @@ execSync(`git clone -b ${config.branch} ${config.repository} ${config.folder} 2>
3231
console.log(`Starting script ${config.script}...`);
3332
console.log(execSync(`${config.script}`, { cwd }).toString('utf-8'));
3433

35-
console.log(`Configuring and committing...`);
34+
console.log('Configuring and committing...');
3635
execSync(`
3736
cd ${config.folder} &&
3837
git config user.email "${config.user_email}" &&
@@ -41,7 +40,7 @@ execSync(`
4140
git commit --allow-empty -m "${config.commit}" 2>&1
4241
`, { cwd });
4342

44-
console.log(`Pushing...`);
43+
console.log('Pushing...');
4544
execSync(`git push ${config.repository} ${config.branch}`, { cwd });
4645

4746
console.log('Deploying to git is finished.');

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Automatically deploy build artifacts to a Git repository",
55
"bin": "index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1",
7+
"test": "eslint .",
88
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
99
},
1010
"config": {
@@ -43,6 +43,11 @@
4343
},
4444
"homepage": "https://github.com/finom/deploy-to-git#readme",
4545
"devDependencies": {
46+
"eslint": "^3.5.0",
47+
"eslint-config-airbnb": "^11.1.0",
48+
"eslint-plugin-import": "^1.14.0",
49+
"eslint-plugin-jsx-a11y": "^2.2.2",
50+
"eslint-plugin-react": "^6.2.1",
4651
"ghooks": "^1.3.2",
4752
"semantic-release": "^4.3.5",
4853
"validate-commit-msg": "^2.8.0"

0 commit comments

Comments
 (0)