@springtree/coding
Advanced tools
Comparing version
@@ -6,4 +6,5 @@ { | ||
"max-len": [ "error", { "code": 160 } ], | ||
"no-console": "off" | ||
"no-console": "off", | ||
"array-bracket-spacing": [ "error", "always" ] | ||
} | ||
} |
40
index.js
@@ -39,3 +39,14 @@ #!/usr/bin/env node | ||
console.log( 'Installing linter dependencies...' ); | ||
childProcess.execSync( 'npm i -D eslint eslint-config-airbnb eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-import tslint tslint-config-airbnb' ); | ||
const packagesToInstall = [ | ||
'eslint', | ||
'eslint-config-airbnb', | ||
'eslint-plugin-import', | ||
'eslint-plugin-jsx-a11y', | ||
'eslint-plugin-react', | ||
'tslint', | ||
'tslint-config-airbnb', | ||
'tslint-eslint-rules', | ||
'typescript', | ||
]; | ||
childProcess.execSync( `npm i -D ${packagesToInstall.join( ' ' )}` ); | ||
@@ -47,2 +58,16 @@ console.log( 'Writing linter config files...' ); | ||
fs.writeFileSync( path.resolve( './tslint.json' ), templateTslintrc ); | ||
// Add npm run scripts for linting | ||
// | ||
// * tslint - run project linting | ||
// * tslint-fix - fix project issues | ||
// | ||
const packageJsonFile = path.resolve( './package.json' ); | ||
const packageJson = jsonfile.readFileSync( packageJsonFile ); | ||
if ( !packageJson.scripts ) { | ||
packageJson.scripts = {}; | ||
} | ||
packageJson.scripts.tslint = 'tslint -p tsconfig.json'; | ||
packageJson.scripts['tslint-fix'] = 'tslint -p tsconfig,json --fix'; | ||
jsonfile.writeFileSync( packageJsonFile, packageJson, { spaces: 2 } ); | ||
} | ||
@@ -59,9 +84,12 @@ | ||
const packageJson = jsonfile.readFileSync( packageJsonFile ); | ||
// Add husky hoop to package.json | ||
// | ||
if ( !packageJson.husky ) { | ||
packageJson.husky = { | ||
hooks: { | ||
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS', | ||
}, | ||
}; | ||
packageJson.husky = {}; | ||
} | ||
if ( !packageJson.husky.hooks ) { | ||
packageJson.husky.hooks = {}; | ||
} | ||
packageJson.husky.hooks['commit-msg'] = 'commitlint -E HUSKY_GIT_PARAMS'; | ||
jsonfile.writeFileSync( packageJsonFile, packageJson, { spaces: 2 } ); | ||
@@ -68,0 +96,0 @@ |
{ | ||
"name": "@springtree/coding", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"private": false, | ||
@@ -9,3 +9,5 @@ "description": "The SpringTree coding guidelines and helper scripts", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"tslint": "tslint -p tsconfig.json", | ||
"tslint-fix": "tslint -p tsconfig.json --fix" | ||
}, | ||
@@ -47,5 +49,7 @@ "repository": { | ||
"husky": "^1.3.1", | ||
"tslint": "^5.13.1", | ||
"tslint-config-airbnb": "^5.11.1" | ||
"tslint": "^5.14.0", | ||
"tslint-config-airbnb": "^5.11.1", | ||
"tslint-eslint-rules": "^5.4.0", | ||
"typescript": "^3.3.3333" | ||
} | ||
} |
@@ -21,2 +21,3 @@ # SpringTree coding guidelines | ||
* enforce spaces inside parenthesis | ||
* enforce array bracket spacing | ||
* allow console statements | ||
@@ -23,0 +24,0 @@ |
{ | ||
"extends": "tslint-config-airbnb", | ||
"rules": { | ||
"no-constant-condition": true, | ||
"max-line-length": [ true, 160 ], | ||
"space-within-parens": [ true, 1 ], | ||
"space-in-parens": [true, "always"], | ||
"array-bracket-spacing": [ true, "always" ], | ||
"no-console": false | ||
} | ||
}, | ||
"rulesDirectory": [ | ||
"node_modules/tslint-eslint-rules/dist/rules" | ||
] | ||
} |
13834
73.71%9
28.57%161
106.41%107
0.94%12
20%