diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d7f213e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# Full documentation can be found at editorconfig.org +# This requires a plugin to be installed in the editor of choice +# Link to info on plugins can be found here - http://editorconfig.org/#download +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..af9cebc --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "eslint-config-tc" +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..4934119 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,8 @@ +# Auto detect text files and perform LF normalization +* text=auto +* text eol=lf + +# Denote all files that are truly binary and should not be modified. +*.png binary +*.eot binary +*.woff binary diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9031895 --- /dev/null +++ b/.gitignore @@ -0,0 +1,70 @@ +#################################### +#################################### +### OS Files +#################################### +#################################### +Thumbs.db +.DS_Store + + + + +#################################### +#################################### +### Git +#################################### +#################################### +*.orig + + + + +#################################### +#################################### +### Sublime Text +#################################### +#################################### +# cache files for sublime text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# workspace files are user-specific +*.sublime-workspace + +# sublime project files +*.sublime-project + +# sftp configuration file +sftp-config.json + + + + +#################################### +#################################### +### Node +#################################### +#################################### +# Logs +logs +*.log + +# Coverage directory used by tools like istanbul +coverage + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +node_modules + + + + +#################################### +#################################### +### Mocha +#################################### +#################################### +mocha.json diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..edc2a8c --- /dev/null +++ b/.jscsrc @@ -0,0 +1,99 @@ +{ + "disallowEmptyBlocks": true, + "disallowKeywordsOnNewLine": ["else"], + "disallowMixedSpacesAndTabs": true, + "disallowMultipleLineStrings": true, + "disallowMultipleVarDecl": true, + "disallowNewlineBeforeBlockStatements": true, + "disallowQuotedKeysInObjects": "allButReserved", + "disallowSpaceAfterObjectKeys": true, + "disallowSpaceAfterPrefixUnaryOperators": true, + "disallowSpaceBeforePostfixUnaryOperators": true, + "disallowSpacesInAnonymousFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInCallExpression": true, + "disallowSpacesInFunction": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInFunctionDeclaration": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInNamedFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInsideArrayBrackets": "all", + "disallowSpacesInsideObjectBrackets": "all", + "disallowSpacesInsideParentheses": true, + "disallowTrailingComma": true, + "disallowYodaConditions": true, + "requireBlocksOnNewline": true, + "requireCapitalizedConstructors": true, + "requireCommaBeforeLineBreak": true, + "requireCurlyBraces": [ + "if", + "else", + "for", + "while", + "do", + "try", + "catch", + "case", + "default" + ], + "requireDotNotation": true, + "requireOperatorBeforeLineBreak": true, + "requirePaddingNewlinesBeforeKeywords": [ + "do", + "for", + "switch", + "case", + "try", + "void", + "while", + "with" + ], + "requireParenthesesAroundIIFE": true, + "requireSpaceAfterBinaryOperators": true, + "requireSpaceAfterKeywords": [ + "do", + "for", + "else", + "switch", + "case", + "try", + "catch", + "void", + "while", + "with", + "return", + "typeof" + ], + "requireSpaceBeforeBinaryOperators": true, + "requireSpaceBeforeBlockStatements": true, + "requireSpaceBeforeKeywords": [ + "else", + "while", + "catch" + ], + "requireSpaceBeforeObjectValues": true, + "requireSpaceBetweenArguments": true, + "requireSpacesInAnonymousFunctionExpression": { + "beforeOpeningCurlyBrace": true + }, + "requireSpacesInConditionalExpression": true, + "requireSpacesInForStatement": true, + "requireSpacesInFunction": { + "beforeOpeningCurlyBrace": true + }, + "requireSpacesInFunctionDeclaration": { + "beforeOpeningCurlyBrace": true + }, + "requireSpacesInNamedFunctionExpression": { + "beforeOpeningCurlyBrace": true + }, + "safeContextKeyword": [], + "validateIndentation": 2, + "validateParameterSeparator": ", ", + "validateQuoteMarks": { "mark": "'", "escape": true } +} diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..e69de29 diff --git a/.npmpackagejsonlintrc.json b/.npmpackagejsonlintrc.json new file mode 100644 index 0000000..d811f40 --- /dev/null +++ b/.npmpackagejsonlintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./index.js" +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..077610d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,27 @@ +git: + depth: 1 + +branches: + only: + - master + +sudo: false + +language: node_js + +node_js: + - "4" + - "5" + - "6" + - "7" + +cache: + directories: + - node_modules + +before_script: + - npm prune + +script: + - npm run lint + - npm test diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..09a4dcf --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,16 @@ +# Change Log +All notable changes to this project will be documented in this file. +This project adheres to [Semantic Versioning](http://semver.org/). + +## [Unreleased] +### Added + +### Changed + +### Fixed + +### Removed + + +## [1.0.0] - 2017-02-18 +- First release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..8f38d7f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,71 @@ +# Contributing + +## System Dependencies + +### Node + +* [Node.js](https://nodejs.org/) - v4.2.0+ +* [npm](https://www.npmjs.com/) - v2.14.7+ + +## Install project dependencies + +### Code + +* Fork and clone the npm-package-json-lint-config-default repo + +### Install project dependencies + +`npm install` + +This installs dependencies from `package.json`. + +## Code guidelines + +### JavaScript + +npm-package-json-lint-config-default utilizes both ESLint and JSCS to enforce JavaScript standards. Please see the `.eslintrc.json` file for ESLint config and `.jscsrc` for JSCS config. + +* [eslint](https://github.com/eslint/eslint) +* [jscs](https://github.com/jscs-dev/node-jscs) + +#### JSON + +npm-package-json-lint-config-default utilizes JSON Lint to ensure JSON files are valid. + +* [jsonlint](https://github.com/zaach/jsonlint) + +#### package.json + +npm-package-json-lint-config-default utilizes npm-package-json-lint to ensure the package.json file is valid. + +* [npm-package-json-lint](https://github.com/tclindner/npm-package-json-lint) + +#### Checking coding style + +Run `npm run lint` before committing to ensure your changes follow our coding standards. + +## Versioning + +Please use the following grunt commands to increment the package's version numbers +EX: Assume current version is 0.0.1 + +`npm version patch` + +If you run this command the version will increase the patch number (ie 0.0.2) + +`npm version minor` + +If you run this command the version will increase the minor number (ie 0.1.0) + +`npm version major` + +If you run this command the version will increase the major number (ie 1.0.0) + + +## EditorConfig + +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. + +## License + +Contributions to npm-package-json-lint-config-default are subject to the [MIT License](https://github.com/tclindner/npm-package-json-lint-config-default/blob/master/LICENSE). diff --git a/README.md b/README.md new file mode 100644 index 0000000..e4c35a8 --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# npm-package-json-lint-config-default + +> Default [npm-package-json-lint](https://github.com/tclindner/npm-package-json-lint) shareable config + + +[![license](https://img.shields.io/github/license/tclindner/npm-package-json-lint-config-default.svg?maxAge=2592000&style=flat-square)](https://github.com/tclindner/npm-package-json-lint-config-default/blob/master/LICENSE) +[![npm](https://img.shields.io/npm/v/npm-package-json-lint-config-default.svg?maxAge=2592000?style=flat-square)](https://www.npmjs.com/package/npm-package-json-lint-config-default) +[![Travis](https://img.shields.io/travis/tclindner/npm-package-json-lint-config-default.svg?maxAge=2592000?style=flat-square)](https://travis-ci.org/tclindner/npm-package-json-lint-config-default) +[![Dependency Status](https://david-dm.org/tclindner/npm-package-json-lint-config-default.svg?style=flat-square)](https://david-dm.org/tclindner/npm-package-json-lint-config-default) +[![devDependency Status](https://david-dm.org/tclindner/npm-package-json-lint-config-default/dev-status.svg?style=flat-square)](https://david-dm.org/tclindner/npm-package-json-lint-config-default#info=devDependencies) + + +## What is npm-package-json-lint-config-default? + +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. + +## How do I install it? + +First thing first, let's make sure you have the necessary pre-requisites. + +### System Dependencies + +#### Node + +* [Node.js](https://nodejs.org/) - v4.2.0+ +* [npm](http://npmjs.com) - v2.14.7+ + +### Command + +```bash +npm install npm-package-json-lint-config-default --save-dev +``` + +## Usage + +Add the following to your `.npmpackagejsonlintrc.json` file: + +```json +{ + "extends": "npm-package-json-lint-config-default" +} +``` + +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. + +```json +{ + "extends": "npm-package-json-lint-config-default", + "rules": { + "license-type": "off" + } +} +``` + +## Contributing + +Please see [CONTRIBUTING.md](CONTRIBUTING.md). + +## Release History + +Please see [CHANGELOG.md](CHANGELOG.md). + +## License + +Copyright (c) 2017 Thomas Lindner. Licensed under the MIT license. diff --git a/index.js b/index.js new file mode 100644 index 0000000..5a01b08 --- /dev/null +++ b/index.js @@ -0,0 +1,35 @@ +'use strict'; + +const defaultConfig = { + rules: { + 'require-name': 'error', + 'require-version': 'error', + 'name-format': 'error', + 'version-format': 'error', + 'bin-type': 'error', + 'config-type': 'error', + 'cpu-type': 'error', + 'dependencies-type': 'error', + 'description-type': 'error', + 'devDependencies-type': 'error', + 'directories-type': 'error', + 'engines-type': 'error', + 'files-type': 'error', + 'homepage-type': 'error', + 'keywords-type': 'error', + 'license-type': 'error', + 'main-type': 'error', + 'man-type': 'error', + 'name-type': 'error', + 'optionalDependencies-type': 'error', + 'os-type': 'error', + 'peerDependencies-type': 'error', + 'preferGlobal-type': 'error', + 'private-type': 'error', + 'repository-type': 'error', + 'scripts-type': 'error', + 'version-type': 'error' + } +}; + +module.exports = defaultConfig; diff --git a/package.json b/package.json new file mode 100644 index 0000000..8c7ecef --- /dev/null +++ b/package.json @@ -0,0 +1,53 @@ +{ + "name": "npm-package-json-lint-config-default", + "version": "1.0.0", + "description": "Default npm-package-json-lint shareable config", + "keywords": [ + "lint", + "linter", + "package.json", + "audit", + "auditor", + "npm-package-json-lint", + "npm-package-json-lintconfig", + "npm-package-json-lint-config" + ], + "homepage": "https://github.com/tclindner/npm-package-json-lint-config-default#readme", + "bugs": { + "url": "https://github.com/tclindner/npm-package-json-lint-config-default/issues" + }, + "author": "Thomas Lindner", + "repository": { + "type": "git", + "url": "git+https://github.com/tclindner/npm-package-json-lint-config-default.git" + }, + "main": "index.js", + "scripts": { + "eslint": "eslint *.js --format=node_modules/eslint-formatter-pretty", + "jscs": "jscs *.js", + "jsonlint": "jsonlint *.json", + "lint": "npm run npmpackagejsonlint && npm run eslint && npm run jscs && npm run jsonlint", + "npmpackagejsonlint": "pjl-cli -c .npmpackagejsonlintrc.json", + "test": "mocha test" + }, + "devDependencies": { + "eslint": "^3.15.0", + "eslint-config-tc": "^1.4.0", + "eslint-formatter-pretty": "^1.1.0", + "is-plain-obj": "^1.1.0", + "jscs": "^3.0.7", + "jsonlint": "^1.6.2", + "mocha": "^3.2.0", + "npm-package-json-lint": "^2.0.2", + "should": "^11.2.0", + "temp-write": "^3.1.0" + }, + "peerDependencies": { + "npm-package-json-lint": ">= 2" + }, + "engines": { + "node": ">=4.2.0", + "npm": ">=2.14.7" + }, + "license": "MIT" +} diff --git a/test/helper/testHelper.js b/test/helper/testHelper.js new file mode 100644 index 0000000..74377f4 --- /dev/null +++ b/test/helper/testHelper.js @@ -0,0 +1,12 @@ +'use strict'; + +const NpmPackageJsonLint = require('npm-package-json-lint'); + +module.exports = function lint(packageJsonData, config) { + const options = { + ignoreWarnings: true + }; + const npmPackageJsonLint = new NpmPackageJsonLint(packageJsonData, config, options); + + return npmPackageJsonLint.lint(); +}; diff --git a/test/tests.js b/test/tests.js new file mode 100644 index 0000000..f3bf499 --- /dev/null +++ b/test/tests.js @@ -0,0 +1,33 @@ +'use strict'; + +const should = require('should'); +const isPlainObj = require('is-plain-obj'); +const config = require('./../index.js'); +const lint = require('./helper/testHelper.js'); + +describe('npm-package-json-lint config tests', () => { + context('npm-package-json-lint config object', () => { + it('should be an object', () => { + isPlainObj(config).should.equal(true); + }); + }); + + context('rules', () => { + it('should be an object', () => { + isPlainObj(config.rules).should.equal(true); + }); + }); + + context('run npm-package-json-lint and make sure it runs', () => { + it('npm-package-json-lint should run without failing', () => { + const packageJsonData = { + author: 'Caitlin Snow' + }; + const results = lint(packageJsonData, config); + const expectedErrorCount = 2; + + results.errors.length.should.equal(expectedErrorCount); + results.hasOwnProperty('warnings').should.be.false(); + }); + }); +});