Skip to content

Commit fefc4cb

Browse files
authored
1.0.0 (#1)
* Add npmpackagejsonlintrc config * Add docs * Add package.json * Add tests
1 parent 42755d1 commit fefc4cb

File tree

8 files changed

+300
-0
lines changed

8 files changed

+300
-0
lines changed

.npmpackagejsonlintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./index.js"
3+
}

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Change Log
2+
All notable changes to this project will be documented in this file.
3+
This project adheres to [Semantic Versioning](http://semver.org/).
4+
5+
## [Unreleased]
6+
### Added
7+
8+
### Changed
9+
10+
### Fixed
11+
12+
### Removed
13+
14+
15+
## [1.0.0] - 2017-02-18
16+
- First release

CONTRIBUTING.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Contributing
2+
3+
## System Dependencies
4+
5+
### Node
6+
7+
* [Node.js](https://nodejs.org/) - v4.2.0+
8+
* [npm](https://www.npmjs.com/) - v2.14.7+
9+
10+
## Install project dependencies
11+
12+
### Code
13+
14+
* Fork and clone the npm-package-json-lint-config-tc repo
15+
16+
### Install project dependencies
17+
18+
`npm install`
19+
20+
This installs dependencies from `package.json`.
21+
22+
## Code guidelines
23+
24+
### JavaScript
25+
26+
npm-package-json-lint-config-tc utilizes both ESLint and JSCS to enforce JavaScript standards. Please see the `.eslintrc.json` file for ESLint config and `.jscsrc` for JSCS config.
27+
28+
* [eslint](https://github.com/eslint/eslint)
29+
* [jscs](https://github.com/jscs-dev/node-jscs)
30+
31+
#### JSON
32+
33+
npm-package-json-lint-config-tc utilizes JSON Lint to ensure JSON files are valid.
34+
35+
* [jsonlint](https://github.com/zaach/jsonlint)
36+
37+
#### package.json
38+
39+
npm-package-json-lint-config-tc utilizes npm-package-json-lint to ensure the package.json file is valid.
40+
41+
* [npm-package-json-lint](https://github.com/tclindner/npm-package-json-lint)
42+
43+
#### Checking coding style
44+
45+
Run `npm run lint` before committing to ensure your changes follow our coding standards.
46+
47+
## Versioning
48+
49+
Please use the following grunt commands to increment the package's version numbers
50+
EX: Assume current version is 0.0.1
51+
52+
`npm version patch`
53+
54+
If you run this command the version will increase the patch number (ie 0.0.2)
55+
56+
`npm version minor`
57+
58+
If you run this command the version will increase the minor number (ie 0.1.0)
59+
60+
`npm version major`
61+
62+
If you run this command the version will increase the major number (ie 1.0.0)
63+
64+
65+
## EditorConfig
66+
67+
EditorConfig helps maintain consistent file formatting between different editors and developers. Please [install the plugin for you editor of choice](https://editorconfig.org/#download). Please see the `.editorconfig` file at the root of this repo to see what settings are enforced.
68+
69+
## License
70+
71+
Contributions to npm-package-json-lint-config-tc are subject to the [MIT License](https://github.com/tclindner/npm-package-json-lint-config-tc/blob/master/LICENSE).

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# npm-package-json-lint-config-tc
2+
3+
> [npm-package-json-lint](https://github.com/tclindner/npm-package-json-lint) shareable config for TC's projects
4+
5+
6+
[![license](https://img.shields.io/github/license/tclindner/npm-package-json-lint-config-tc.svg?maxAge=2592000&style=flat-square)](https://github.com/tclindner/npm-package-json-lint-config-tc/blob/master/LICENSE)
7+
[![npm](https://img.shields.io/npm/v/npm-package-json-lint-config-tc.svg?maxAge=2592000?style=flat-square)](https://www.npmjs.com/package/npm-package-json-lint-config-tc)
8+
[![Travis](https://img.shields.io/travis/tclindner/npm-package-json-lint-config-tc.svg?maxAge=2592000?style=flat-square)](https://travis-ci.org/tclindner/npm-package-json-lint-config-tc)
9+
[![Dependency Status](https://david-dm.org/tclindner/npm-package-json-lint-config-tc.svg?style=flat-square)](https://david-dm.org/tclindner/npm-package-json-lint-config-tc)
10+
[![devDependency Status](https://david-dm.org/tclindner/npm-package-json-lint-config-tc/dev-status.svg?style=flat-square)](https://david-dm.org/tclindner/npm-package-json-lint-config-tc#info=devDependencies)
11+
12+
13+
## What is npm-package-json-lint-config-tc?
14+
15+
Shared configuration for npm-package-json-lint. Follow the instructions below to easily include this configuration in another project without having to duplicate the file.
16+
17+
## How do I install it?
18+
19+
First thing first, let's make sure you have the necessary pre-requisites.
20+
21+
### System Dependencies
22+
23+
#### Node
24+
25+
* [Node.js](https://nodejs.org/) - v4.2.0+
26+
* [npm](http://npmjs.com) - v2.14.7+
27+
28+
### Command
29+
30+
```bash
31+
npm install npm-package-json-lint-config-tc --save-dev
32+
```
33+
34+
## Usage
35+
36+
Add the following to your `.npmpackagejsonlintrc.json` file:
37+
38+
```json
39+
{
40+
"extends": "npm-package-json-lint-config-tc"
41+
}
42+
```
43+
44+
If you need to override a rule, your `.npmpackagejsonlintrc.json` file should look like the example below. All shared rules will be used, but `license-type` will be turned off.
45+
46+
```json
47+
{
48+
"extends": "npm-package-json-lint-config-tc",
49+
"rules": {
50+
"license-type": "off"
51+
}
52+
}
53+
```
54+
55+
## Contributing
56+
57+
Please see [CONTRIBUTING.md](CONTRIBUTING.md).
58+
59+
## Release History
60+
61+
Please see [CHANGELOG.md](CHANGELOG.md).
62+
63+
## License
64+
65+
Copyright (c) 2017 Thomas Lindner. Licensed under the MIT license.

index.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
'use strict';
2+
3+
const config = {
4+
rules: {
5+
'require-author': 'error',
6+
'require-bugs': 'error',
7+
'require-description': 'error',
8+
'require-devDependencies': 'error',
9+
'require-engines': 'error',
10+
'require-homepage': 'error',
11+
'require-keywords': 'error',
12+
'require-license': 'error',
13+
'require-main': 'error',
14+
'require-name': 'error',
15+
'require-peerDependencies': 'error',
16+
'require-repository': 'error',
17+
'require-scripts': 'error',
18+
'require-version': 'error',
19+
'config-type': 'error',
20+
'description-type': 'error',
21+
'devDependencies-type': 'error',
22+
'engines-type': 'error',
23+
'homepage-type': 'error',
24+
'keywords-type': 'error',
25+
'license-type': 'error',
26+
'main-type': 'error',
27+
'name-type': 'error',
28+
'peerDependencies-type': 'error',
29+
'repository-type': 'error',
30+
'scripts-type': 'error',
31+
'version-type': 'error',
32+
'valid-values-author': ['error', [
33+
'Thomas Lindner'
34+
]],
35+
'valid-values-private': ['error', [
36+
false
37+
]],
38+
'prefer-no-version-zero-dependencies': 'warning',
39+
'prefer-caret-version-dependencies': 'error',
40+
'prefer-no-version-zero-devDependencies': 'warning',
41+
'prefer-caret-version-devDependencies': 'error',
42+
'name-format': 'error',
43+
'version-format': 'error'
44+
}
45+
};
46+
47+
module.exports = config;

package.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "npm-package-json-lint-config-tc",
3+
"version": "1.0.0",
4+
"description": "npm-package-json-lint shareable config for TC's projects",
5+
"keywords": [
6+
"lint",
7+
"linter",
8+
"package.json",
9+
"audit",
10+
"auditor",
11+
"npm-package-json-lint",
12+
"npm-package-json-lintconfig",
13+
"npm-package-json-lint-config"
14+
],
15+
"homepage": "https://github.com/tclindner/npm-package-json-lint-config-tc#readme",
16+
"bugs": {
17+
"url": "https://github.com/tclindner/npm-package-json-lint-config-tc/issues"
18+
},
19+
"author": "Thomas Lindner",
20+
"repository": {
21+
"type": "git",
22+
"url": "git+https://github.com/tclindner/npm-package-json-lint-config-tc.git"
23+
},
24+
"main": "index.js",
25+
"scripts": {
26+
"eslint": "eslint *.js --format=node_modules/eslint-formatter-pretty",
27+
"jscs": "jscs *.js",
28+
"jsonlint": "jsonlint *.json",
29+
"lint": "npm run npmpackagejsonlint && npm run eslint && npm run jscs && npm run jsonlint",
30+
"npmpackagejsonlint": "pjl-cli -c .npmpackagejsonlintrc.json",
31+
"test": "mocha test"
32+
},
33+
"devDependencies": {
34+
"eslint": "^3.15.0",
35+
"eslint-config-tc": "^1.4.0",
36+
"eslint-formatter-pretty": "^1.1.0",
37+
"is-plain-obj": "^1.1.0",
38+
"jscs": "^3.0.7",
39+
"jsonlint": "^1.6.2",
40+
"mocha": "^3.2.0",
41+
"npm-package-json-lint": "^2.0.2",
42+
"should": "^11.2.0",
43+
"temp-write": "^3.1.0"
44+
},
45+
"peerDependencies": {
46+
"npm-package-json-lint": ">= 2"
47+
},
48+
"engines": {
49+
"node": ">=4.2.0",
50+
"npm": ">=2.14.7"
51+
},
52+
"license": "MIT"
53+
}

test/helper/testHelper.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
const NpmPackageJsonLint = require('npm-package-json-lint');
4+
5+
module.exports = function lint(packageJsonData, config) {
6+
const options = {
7+
ignoreWarnings: true
8+
};
9+
const npmPackageJsonLint = new NpmPackageJsonLint(packageJsonData, config, options);
10+
11+
return npmPackageJsonLint.lint();
12+
};

test/tests.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
3+
const should = require('should');
4+
const isPlainObj = require('is-plain-obj');
5+
const config = require('./../index.js');
6+
const lint = require('./helper/testHelper.js');
7+
8+
describe('npm-package-json-lint config tests', () => {
9+
context('npm-package-json-lint config object', () => {
10+
it('should be an object', () => {
11+
isPlainObj(config).should.equal(true);
12+
});
13+
});
14+
15+
context('rules', () => {
16+
it('should be an object', () => {
17+
isPlainObj(config.rules).should.equal(true);
18+
});
19+
});
20+
21+
context('run npm-package-json-lint and make sure it runs', () => {
22+
it('npm-package-json-lint should run without failing', () => {
23+
const packageJsonData = {
24+
author: 'Caitlin Snow'
25+
};
26+
const results = lint(packageJsonData, config);
27+
const expectedErrorCount = 14;
28+
29+
results.errors.length.should.equal(expectedErrorCount);
30+
results.hasOwnProperty('warnings').should.be.false();
31+
});
32+
});
33+
});

0 commit comments

Comments
 (0)