diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ebb3e401..af500694 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,14 +8,14 @@ jobs: fail-fast: false matrix: os: - - "ubuntu-latest" - # - "macos-latest" - # - "windows-latest" + - 'ubuntu-latest' + # - 'macos-latest' + # - 'windows-latest' node_version: - - "18" - - "16" - - "14" - - "12" + - '18' + - '16' + - '14' + - '12' name: Node.js ${{ matrix.node_version }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} steps: @@ -34,12 +34,9 @@ jobs: - name: Install Dependencies run: npm ci - - name: Run ESLint + - name: Lint if: matrix.node_version == '18' run: npm run lint - - name: Check package.json - run: npm run sort-package-json - - name: Run Tests run: npm run test-coverage diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..23abab46 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +.nyc_output/ +tests/snapshots/ diff --git a/README.md b/README.md index 2d6e460f..225dc958 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,7 @@ If an array, sort keys in ordering of `options.sortOrder`. ```js const sorted = sortPackageJson(packageJsonObject, { - sortOrder: ['version'] + sortOrder: ['version'], }) console.log(Object.keys(sorted)) @@ -173,7 +173,7 @@ If a function, sort fields by [Array#sort(options.sortOrder)](https://developer. const sorted = sortPackageJson(packageJsonObject, { sortOrder(left, right) { return left.localeCompare(right) - } + }, }) console.log(Object.keys(sorted)) diff --git a/package.json b/package.json index f0c37a0f..fe9952e0 100644 --- a/package.json +++ b/package.json @@ -28,13 +28,13 @@ "reporter.js" ], "scripts": { - "lint": "eslint .", + "fix": "eslint . --fix && prettier . \"!**/*.js\" --write && node cli.js \"package.json\"", + "lint": "eslint . && prettier . \"!**/*.js\" --check && node cli.js \"package.json\" --check", "prepare": "husky install", "semantic-release": "semantic-release", - "sort-package-json": "node cli.js package.json --check", "test": "ava && dtslint --localTs node_modules/typescript/lib", "test-coverage": "nyc ava", - "update-snapshot": "ava -u && node cli.js package.json" + "update-snapshots": "ava --update-snapshots" }, "commitlint": { "extends": [ @@ -42,14 +42,14 @@ ] }, "lint-staged": { + "package.json": [ + "node cli.js" + ], "*.js": [ "eslint --fix" ], - "*.ts": [ - "prettier --write" - ], - "package.json": [ - "node cli.js" + "**/*,!*.js": [ + "prettier --write --ignore-unkown" ] }, "prettier": { diff --git a/tsconfig.json b/tsconfig.json index 7cc436f7..5e9d07a8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,16 @@ { - "compilerOptions": { - "module": "commonjs", - "lib": ["es6"], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "noEmit": true, + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, - // If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index". - // If the library is global (cannot be imported via `import` or `require`), leave this out. - "baseUrl": ".", - "paths": { "sort-package-json": ["."] } - } -} \ No newline at end of file + // If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index". + // If the library is global (cannot be imported via `import` or `require`), leave this out. + "baseUrl": ".", + "paths": { "sort-package-json": ["."] } + } +} diff --git a/tslint.json b/tslint.json index 29fa58a9..8cd631ee 100644 --- a/tslint.json +++ b/tslint.json @@ -1,6 +1,6 @@ { - "extends": "dtslint/dtslint.json", // Or "dtslint/dt.json" if on DefinitelyTyped - "rules": { - "semicolon": false - } -} \ No newline at end of file + "extends": "dtslint/dtslint.json", // Or "dtslint/dt.json" if on DefinitelyTyped + "rules": { + "semicolon": false + } +}