Skip to content

Commit

Permalink
feat(build): add eslint scripts and default configs
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed Mar 12, 2019
1 parent 6e0eeb6 commit b56849a
Show file tree
Hide file tree
Showing 12 changed files with 707 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -27,7 +27,7 @@ matrix:
env: TASK=code-lint
# Running Code Linter -- Requires @loopback/build so it's bootstrapped
script:
- lerna bootstrap --scope @loopback/build --scope @loopback/tslint-config
- lerna bootstrap --scope @loopback/build --scope @loopback/tslint-config --scope @loopback/eslint-config
- npm run lint
- node_js: "8"
os: linux
Expand Down
4 changes: 2 additions & 2 deletions greenkeeper.json
Expand Up @@ -18,6 +18,7 @@
"packages/cli/package.json",
"packages/context/package.json",
"packages/core/package.json",
"packages/eslint-config/package.json",
"packages/http-caching-proxy/package.json",
"packages/http-server/package.json",
"packages/metadata/package.json",
Expand All @@ -34,6 +35,5 @@
"sandbox/example/package.json"
]
}
},
"ignore": ["@types/node"]
}
}
49 changes: 49 additions & 0 deletions packages/build/bin/run-eslint.js
@@ -0,0 +1,49 @@
#!/usr/bin/env node
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
// Node module: @loopback/build
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

/*
========
Usage:
node ./bin/run-eslint
========
*/

'use strict';

function run(argv, options) {
const utils = require('./utils');

const eslintOpts = argv.slice(2);

const isConfigSet = utils.isOptionSet(eslintOpts, '-c', '--config');
const isExtSet = utils.isOptionSet(eslintOpts, '--ext');

const eslintConfigFile = isConfigSet
? null
: utils.getConfigFile('.eslintrc.js', '.eslintrc.json');

const eslintIgnoreFile = utils.getConfigFile('.eslintignore');

const args = [];
if (eslintConfigFile) {
args.push('-c', eslintConfigFile);
}
if (eslintIgnoreFile) {
args.push('--ignore-path', eslintIgnoreFile);
}

if (!isExtSet) {
args.push('--ext', '.js,.ts');
}
args.push(...eslintOpts);

return utils.runCLI('eslint/bin/eslint', args, options);
}

module.exports = run;
if (require.main === module) run(process.argv);
4 changes: 4 additions & 0 deletions packages/build/config/.eslintignore
@@ -0,0 +1,4 @@
node_modules/
dist/
coverage/
api-docs/
3 changes: 3 additions & 0 deletions packages/build/config/.eslintrc.js
@@ -0,0 +1,3 @@
module.exports = {
extends: '@loopback/eslint-config',
};

0 comments on commit b56849a

Please sign in to comment.