├── .eslintrc.json ├── .npmpackagejsonlintrc.json ├── .gitattributes ├── CHANGELOG.md ├── .github ├── dependabot.yml ├── workflows │ ├── prerelease.yml │ ├── release.yml │ ├── ci.yml │ └── codeql-analysis.yml └── release.yml ├── .editorconfig ├── index.js ├── LICENSE ├── test └── tests.test.js ├── .gitignore ├── package.json ├── CONTRIBUTING.md └── README.md /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint-config-tc" 3 | } 4 | -------------------------------------------------------------------------------- /.npmpackagejsonlintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./index.js" 3 | } 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | * text eol=lf 4 | 5 | # Denote all files that are truly binary and should not be modified. 6 | *.png binary 7 | *.eot binary 8 | *.woff binary 9 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 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 | Please see [GitHub releases](https://github.com/tclindner/npm-package-json-lint-config-default/releases) for details. 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | assignees: 9 | - tclindner 10 | labels: 11 | - 'dependencies :package:' 12 | versioning-strategy: increase 13 | - package-ecosystem: "github-actions" 14 | directory: "/" 15 | schedule: 16 | interval: "daily" 17 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Full documentation can be found at editorconfig.org 2 | # This requires a plugin to be installed in the editor of choice 3 | # Link to info on plugins can be found here - http://editorconfig.org/#download 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | end_of_line = lf 9 | indent_size = 2 10 | indent_style = space 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | -------------------------------------------------------------------------------- /.github/workflows/prerelease.yml: -------------------------------------------------------------------------------- 1 | name: "Publish next version to npm" 2 | 3 | on: 4 | release: 5 | types: [prereleased] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v5 12 | - uses: actions/setup-node@v5.0.0 13 | with: 14 | node-version: '20' 15 | registry-url: 'https://registry.npmjs.org' 16 | - run: npm ci --no-progress --production 17 | - run: npm version --no-push --no-git-tag-version --yes ${{ github.event.release.tag_name }} 18 | - run: npm publish --tag next 19 | env: 20 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 21 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: "Publish latest version to npm" 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v5 12 | - uses: actions/setup-node@v5.0.0 13 | with: 14 | node-version: '20' 15 | registry-url: 'https://registry.npmjs.org' 16 | - run: npm ci --no-progress --production 17 | - run: npm version --no-push --no-git-tag-version --yes ${{ github.event.release.tag_name }} 18 | - run: npm publish --tag latest 19 | env: 20 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 21 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | exclude: 3 | labels: 4 | - "ignore-for-release :zipper_mouth_face:" 5 | categories: 6 | - title: 💥 Breaking Changes 7 | labels: 8 | - "breaking change :boom:" 9 | - title: 🔒 Security 10 | labels: 11 | - "security :lock:" 12 | - title: 👑 Changed 13 | labels: 14 | - "enhancement :crown:" 15 | - title: 🙈 Fixed 16 | labels: 17 | - "bug :beetle:" 18 | - title: 🗑️ Removed 19 | labels: 20 | - "removed :wastebasket:" 21 | - title: 📖 Docs 22 | labels: 23 | - "documentation :book:" 24 | - title: 🧹 Chores 25 | labels: 26 | - "maintenance :construction:" 27 | - "dependencies :package:" 28 | - title: 🎁 Other 29 | labels: 30 | - "*" 31 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: "ci" 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | 9 | jobs: 10 | lint: 11 | name: Lint 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v5 17 | - uses: actions/setup-node@v5.0.0 18 | with: 19 | node-version: '20' 20 | - run: npm ci --no-progress 21 | - run: npm run lint 22 | 23 | test: 24 | name: Test using Node.js ${{ matrix.node }} running on ${{ matrix.os }} 25 | 26 | runs-on: ${{ matrix.os }} 27 | 28 | strategy: 29 | matrix: 30 | node: [20, 22, 24] 31 | os: [ubuntu-latest, windows-latest] 32 | 33 | steps: 34 | - uses: actions/checkout@v5 35 | - name: Use Node.js ${{ matrix.node }} 36 | uses: actions/setup-node@v5.0.0 37 | with: 38 | node-version: ${{ matrix.node }} 39 | - run: npm ci --no-progress 40 | - run: npm run test:ci 41 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const defaultConfig = { 2 | rules: { 3 | 'require-name': 'error', 4 | 'require-version': 'error', 5 | 'name-format': 'error', 6 | 'version-format': 'error', 7 | 'bin-type': 'error', 8 | 'config-type': 'error', 9 | 'cpu-type': 'error', 10 | 'dependencies-type': 'error', 11 | 'description-type': 'error', 12 | 'devDependencies-type': 'error', 13 | 'directories-type': 'error', 14 | 'engines-type': 'error', 15 | 'files-type': 'error', 16 | 'homepage-type': 'error', 17 | 'keywords-type': 'error', 18 | 'license-type': 'error', 19 | 'main-type': 'error', 20 | 'man-type': 'error', 21 | 'name-type': 'error', 22 | 'optionalDependencies-type': 'error', 23 | 'os-type': 'error', 24 | 'peerDependencies-type': 'error', 25 | 'preferGlobal-type': 'error', 26 | 'private-type': 'error', 27 | 'repository-type': 'error', 28 | 'scripts-type': 'error', 29 | 'version-type': 'error', 30 | }, 31 | }; 32 | 33 | module.exports = defaultConfig; 34 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: "Code scanning" 2 | 3 | on: 4 | pull_request: 5 | schedule: 6 | - cron: '0 21 * * 4' 7 | 8 | jobs: 9 | CodeQL-Build: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Checkout repository 15 | uses: actions/checkout@v5 16 | with: 17 | # We must fetch at least the immediate parents so that if this is 18 | # a pull request then we can checkout the head. 19 | fetch-depth: 2 20 | 21 | # If this run was triggered by a pull request event, then checkout 22 | # the head of the pull request instead of the merge commit. 23 | - run: git checkout HEAD^2 24 | if: ${{ github.event_name == 'pull_request' }} 25 | 26 | # Initializes the CodeQL tools for scanning. 27 | - name: Initialize CodeQL 28 | uses: github/codeql-action/init@v3 29 | # Override language selection by uncommenting this and choosing your languages 30 | # with: 31 | # languages: go, javascript, csharp, python, cpp, java 32 | 33 | - name: Perform CodeQL Analysis 34 | uses: github/codeql-action/analyze@v3 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2023 tclindner 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /test/tests.test.js: -------------------------------------------------------------------------------- 1 | const isPlainObj = require('is-plain-obj'); 2 | const {NpmPackageJsonLint} = require('npm-package-json-lint'); 3 | const config = require('../index.js'); 4 | 5 | describe('npm-package-json-lint config tests', () => { 6 | describe('npm-package-json-lint config object', () => { 7 | test('should be an object', () => { 8 | expect(isPlainObj(config)).toBe(true); 9 | }); 10 | }); 11 | 12 | describe('rules', () => { 13 | test('should be an object', () => { 14 | expect(isPlainObj(config.rules)).toBe(true); 15 | }); 16 | }); 17 | 18 | describe('run npm-package-json-lint and make sure it runs', () => { 19 | test('npm-package-json-lint should run without failing', () => { 20 | const packageJsonData = { 21 | author: 'Caitlin Snow', 22 | }; 23 | const npmPackageJsonLint = new NpmPackageJsonLint({ 24 | packageJsonObject: packageJsonData, 25 | config, 26 | packageJsonFilePath: 'npm-package-json-lint-config-tc', 27 | }); 28 | 29 | const output = npmPackageJsonLint.lint(); 30 | const expectedErrorCount = 2; 31 | 32 | expect(output.results).toHaveLength(1); 33 | expect(output.results[0].issues).toHaveLength(expectedErrorCount); 34 | expect(output.ignoreCount).toStrictEqual(0); 35 | expect(output.errorCount).toStrictEqual(expectedErrorCount); 36 | expect(output.warningCount).toStrictEqual(0); 37 | }); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #################################### 2 | #################################### 3 | ### OS Files 4 | #################################### 5 | #################################### 6 | Thumbs.db 7 | .DS_Store 8 | 9 | 10 | 11 | 12 | #################################### 13 | #################################### 14 | ### Git 15 | #################################### 16 | #################################### 17 | *.orig 18 | 19 | 20 | 21 | 22 | #################################### 23 | #################################### 24 | ### Sublime Text 25 | #################################### 26 | #################################### 27 | # cache files for sublime text 28 | *.tmlanguage.cache 29 | *.tmPreferences.cache 30 | *.stTheme.cache 31 | 32 | # workspace files are user-specific 33 | *.sublime-workspace 34 | 35 | # sublime project files 36 | *.sublime-project 37 | 38 | # sftp configuration file 39 | sftp-config.json 40 | 41 | 42 | 43 | 44 | #################################### 45 | #################################### 46 | ### Node 47 | #################################### 48 | #################################### 49 | # Logs 50 | logs 51 | *.log 52 | 53 | # Coverage directory used by tools like istanbul 54 | coverage 55 | 56 | # Compiled binary addons (http://nodejs.org/api/addons.html) 57 | build/Release 58 | 59 | # Dependency directory 60 | node_modules 61 | 62 | 63 | 64 | 65 | #################################### 66 | #################################### 67 | ### Mocha 68 | #################################### 69 | #################################### 70 | mocha.json 71 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "npm-package-json-lint-config-default", 3 | "version": "0.0.0", 4 | "description": "Default npm-package-json-lint shareable config", 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-default#readme", 16 | "bugs": { 17 | "url": "https://github.com/tclindner/npm-package-json-lint-config-default/issues" 18 | }, 19 | "author": "Thomas Lindner", 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/tclindner/npm-package-json-lint-config-default.git" 23 | }, 24 | "files": [ 25 | "index.js", 26 | "CONTRIBUTING.md" 27 | ], 28 | "main": "index.js", 29 | "scripts": { 30 | "eslint": "eslint *.js", 31 | "lint": "npm run npmpackagejsonlint && npm run eslint", 32 | "npmpackagejsonlint": "npmPkgJsonLint .", 33 | "test": "jest", 34 | "test:ci": "jest --runInBand" 35 | }, 36 | "devDependencies": { 37 | "eslint": "^8.57.1", 38 | "eslint-config-tc": "^27.1.0", 39 | "eslint-plugin-eslint-comments": "^3.2.0", 40 | "eslint-plugin-import": "^2.32.0", 41 | "eslint-plugin-jest": "^29.0.1", 42 | "eslint-plugin-prettier": "^5.5.4", 43 | "eslint-plugin-unicorn": "^56.0.1", 44 | "is-plain-obj": "^3.0.0", 45 | "jest": "^30.2.0", 46 | "npm-package-json-lint": "^9.0.0", 47 | "prettier": "^3.6.2" 48 | }, 49 | "peerDependencies": { 50 | "npm-package-json-lint": "^9.0.0" 51 | }, 52 | "engines": { 53 | "node": ">=20.0.0", 54 | "npm": ">=10.0.0" 55 | }, 56 | "license": "MIT" 57 | } 58 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## System Dependencies 4 | 5 | ### Node 6 | 7 | * [Node.js](https://nodejs.org/) - v20.0.0+ 8 | * [npm](https://www.npmjs.com/) - v10.0.0+ 9 | 10 | ## Install project dependencies 11 | 12 | ### Code 13 | 14 | * Fork and clone the npm-package-json-lint-config-default 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-default utilizes ESLint to enforce JavaScript standards. Please see the `.eslintrc.json` file for more details. 27 | 28 | * [eslint](https://github.com/eslint/eslint) 29 | 30 | #### package.json 31 | 32 | npm-package-json-lint-config-default utilizes npm-package-json-lint to ensure the package.json file is valid. 33 | 34 | * [npm-package-json-lint](https://github.com/tclindner/npm-package-json-lint) 35 | 36 | #### Checking coding style 37 | 38 | Run `npm run lint` before committing to ensure your changes follow our coding standards. 39 | 40 | ## Versioning 41 | 42 | Please use the following grunt commands to increment the package's version numbers 43 | EX: Assume current version is 0.0.1 44 | 45 | `npm version patch` 46 | 47 | If you run this command the version will increase the patch number (ie 0.0.2) 48 | 49 | `npm version minor` 50 | 51 | If you run this command the version will increase the minor number (ie 0.1.0) 52 | 53 | `npm version major` 54 | 55 | If you run this command the version will increase the major number (ie 1.0.0) 56 | 57 | 58 | ## EditorConfig 59 | 60 | 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. 61 | 62 | ## License 63 | 64 | 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). 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # npm-package-json-lint-config-default 2 | 3 | > Default [npm-package-json-lint](https://github.com/tclindner/npm-package-json-lint) shareable config 4 | 5 | 6 | [![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) 7 | [![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) 8 | ![ci](https://github.com/tclindner/npm-package-json-lint-config-default/workflows/ci/badge.svg?branch=master) 9 | [![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) 10 | [![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) 11 | 12 | 13 | ## What is npm-package-json-lint-config-default? 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/) - v20.0.0+ 26 | * [npm](http://npmjs.com) - v10.0.0+ 27 | 28 | ### Command 29 | 30 | ```bash 31 | npm install npm-package-json-lint-config-default --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-default" 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-default", 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-2023 Thomas Lindner. Licensed under the MIT license. 66 | --------------------------------------------------------------------------------