Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
preparations for npm publish
Browse files Browse the repository at this point in the history
  • Loading branch information
BendingBender committed Oct 15, 2016
1 parent 298563f commit 71db1f6
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 22 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm
Expand All @@ -41,5 +40,4 @@ jspm_packages
*.iml

# built atrifacts
build
dist
2 changes: 0 additions & 2 deletions .istanbul.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
verbose: false
instrumentation:
root: ./build
extensions:
- .js
default-excludes: true
Expand All @@ -10,4 +9,3 @@ reporting:
print: summary
reports:
- lcov
dir: ./coverage
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.idea/
src/
.travis.yml
.npmignore
.istanbul.yml
.editorconfig
runTests.js
tsconfig.json
38 changes: 34 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
[![Build Status][build-image]][build-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][deps-image]][deps-url] [![dev-dependencies][dev-deps-image]][dev-deps-url]

[![NPM][npm-image]][npm-url]

# tslint-rules

A set of custom [TSLint](https://github.com/palantir/tslint) rules.

## Available Rules

### `import-barrels`
# Usage

Install from npm to your devDependencies:
```
npm install --save-dev custom-tslint-rules
```

Configure tslint to use the custom-tslint-rules folder:

Add the following path to the `rulesDirectory` setting in your `tslint.json` file:

```json
{
"rulesDirectory": [
"node_modules/custom-tslint-rules/dist"
],
"rules": {
...
}
}
```

Now configure some of the new rules.


# Available Rules

## `import-barrels`

Enforces usage of barrels (`index.ts`) when importing from a directory that has a barrel file.

Expand All @@ -33,7 +61,7 @@ An argument object may be optionally provided, with the following properties:
* `fileExtensions = ['ts', 'js']`: uses the provided file extensions for module and barrel file lookup


### `jasmine-no-lambda-expression-callbacks`
## `jasmine-no-lambda-expression-callbacks`

Disallows usage of ES6-style lambda expressions as callbacks to Jasmine BDD functions.

Expand Down Expand Up @@ -74,4 +102,6 @@ Not configurable.
[deps-image]: https://img.shields.io/david/BendingBender/tslint-rules.svg?style=flat-square
[deps-url]: https://david-dm.org/BendingBender/tslint-rules
[dev-deps-image]: https://img.shields.io/david/dev/BendingBender/tslint-rules.svg?style=flat-square
[dev-deps-url]: https://david-dm.org/BendingBender/tslint-rules?type=dev
[dev-deps-url]: https://david-dm.org/BendingBender/tslint-rules?type=dev
[npm-image]: https://nodei.co/npm/custom-tslint-rules.png
[npm-url]: https://npmjs.org/package/custom-tslint-rules
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
"description": "Custom rules for tslint",
"main": "tslint.json",
"scripts": {
"build": "tsc -p tsconfig.json --outDir ./dist",
"build:clean": "npm run clean && npm run build",
"ci": "npm run cover && npm run coveralls && npm run lint",
"clean": "rimraf build coverage",
"clean": "rimraf dist coverage",
"coveralls": "cat coverage/lcov.info | coveralls",
"precover": "npm run build:clean",
"cover": "istanbul cover runTests.js -- --coverage && istanbul report",
"build": "tsc -p tsconfig.json",
"build:clean": "npm run clean && npm run build",
"cover": "istanbul cover --root ./dist --dir ./coverage runTests.js -- -b ./dist -c ./coverage && istanbul report --dir ./coverage",
"dist": "npm run clean && npm test && npm run lint && rimraf dist/tests",
"lint": "tslint 'src/**/*.ts'",
"pretest": "npm run build:clean",
"test": "node runTests.js"
"prepublish": "npm run dist",
"pretest": "npm run build",
"test": "node runTests.js -b ./dist"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -43,5 +45,8 @@
},
"dependencies": {
"lodash": "^4.16.4"
},
"engines": {
"node": ">=4"
}
}
18 changes: 15 additions & 3 deletions runTests.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
'use strict';

const argv = require('yargs')
.usage('Usage: $0 --buildDir [path] --coverage [path]')
.alias({
'b': 'buildDir',
'c': 'coverage'
})
.nargs({
'b': 1,
'c': 1
})
.demand(['b'])
.argv;

const glob = require('glob');
const path = require('path');
const child_process = require('child_process');
const argv = require('yargs').argv;

const tslintCommand = path.resolve('./node_modules/.bin/tslint');
const istanbulCommand = path.resolve('./node_modules/.bin/istanbul');
const buildDir = path.resolve('./build');
const coverageDir = path.resolve('./coverage');
const buildDir = path.resolve(argv.buildDir);
const coverageDir = path.resolve(argv.coverage || '');

glob('src/tests/**/*.ts.lint', (error, files) => {
if (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/importBarrels/default/tslint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"rulesDirectory": [
"../../../../build"
"../../../../dist"
],
"rules": {
"import-barrels": true
Expand Down
2 changes: 1 addition & 1 deletion src/tests/importBarrels/no-explicit-barrels/tslint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"rulesDirectory": [
"../../../../build"
"../../../../dist"
],
"rules": {
"import-barrels": [
Expand Down
2 changes: 1 addition & 1 deletion src/tests/importBarrels/with-extension-list/tslint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"rulesDirectory": [
"../../../../build"
"../../../../dist"
],
"rules": {
"import-barrels": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"rulesDirectory": [
"../../../../build"
"../../../../dist"
],
"rules": {
"jasmine-no-lambda-expression-callbacks": true
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"baseUrl": "./src",
"outDir": "./build",
"paths": {},
"lib": [
"es6"
Expand Down

0 comments on commit 71db1f6

Please sign in to comment.