Skip to content
This repository has been archived by the owner on May 16, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master:
  chore(release): 1.3.0
  test: add tests for file negations
  chore: update devDeps (shellscape#18)
  docs: update README to match recent additions. fixes shellscape#16.
  fix: move the negations (!) to the bottom in files (shellscape#17)
  feat: add support for peerDependenciesMeta (shellscape#11)
  chore(release): 1.2.0
  feat: add support for exports (shellscape#15)
  chore: npm audit fix
  chore(release): 1.1.0
  feat: add support for `type` (shellscape#14)
  chore(release): 1.0.0
  fix: prettier v2 compat
  chore: npm audit fix
  • Loading branch information
maxmilton committed Apr 17, 2021
2 parents 0b79c63 + 1d17aa1 commit 1744634
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 10 deletions.
9 changes: 7 additions & 2 deletions README.md
Expand Up @@ -49,7 +49,7 @@ Keys in `engines` are ordered alphabetically.

### Files

Keys in `files` are ordered alphabetically, followed by `README.md` and `LICENSE` if they exist in the array.
Keys in `files` are ordered alphabetically (keeping the negations below), followed by `README.md` and `LICENSE` if they exist in the array.

### Scripts

Expand Down Expand Up @@ -99,9 +99,14 @@ Top-level keys are sorted according to a style commonly seen in the packages of
'bundledDependencies',
'optionalDependencies',
'peerDependencies',
'peerDependenciesMeta',
'dependencies',
'devDependencies',
'resolutions'
'resolutions',

// types
'types',
'typings'
]
```

Expand Down
7 changes: 6 additions & 1 deletion lib/rules/files.js
Expand Up @@ -35,7 +35,12 @@ const process = (props) => {

return true;
})
.sort((a, b) => (a.value > b.value ? 1 : a.value < b.value ? -1 : 0));
.sort((a, b) => {
const aValue = a.value.startsWith('!') ? a.value.substring(1) : a.value;
const bValue = b.value.startsWith('!') ? b.value.substring(1) : b.value;

return aValue.localeCompare(bValue);
});

if (readme) {
elements.push(readme);
Expand Down
1 change: 1 addition & 0 deletions lib/rules/sort.js
Expand Up @@ -47,6 +47,7 @@ const primary = [
'bundledDependencies',
'optionalDependencies',
'peerDependencies',
'peerDependenciesMeta',
'dependencies',
'devDependencies',
'resolutions'
Expand Down
22 changes: 15 additions & 7 deletions package.json
Expand Up @@ -7,7 +7,7 @@
"author": "Max Milton <max@wearegenki.com>",
"main": "lib/index.js",
"engines": {
"node": ">= 8.0.0"
"node": ">=10.13.0"
},
"scripts": {
"lint": "eslint lib test",
Expand All @@ -28,18 +28,26 @@
"prettier": "^2.0.0"
},
"devDependencies": {
"ava": "3.9.0",
"eslint-config-shellscape": "2.1.0",
"eslint-plugin-prettier": "3.1.4",
"execa": "4.0.2",
"nyc": "15.1.0",
"prettier": "2.0.5"
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"ava": "^3.13.0",
"eslint-config-shellscape": "^2.1.0",
"execa": "^4.0.3",
"lint-staged": "^10.4.0",
"nyc": "^15.1.0",
"pre-commit": "^1.2.2",
"prettier": "^2.1.2"
},
"ava": {
"files": [
"!**/fixtures/**"
]
},
"lint-staged": {
"*.js": [
"eslint --fix"
]
},
"nyc": {
"include": [
"lib/*.js"
Expand Down
30 changes: 30 additions & 0 deletions test/files.js
Expand Up @@ -16,3 +16,33 @@ test('default', (t) => {

t.snapshot(output);
});

test('negations', (t) => {
const options = {
filepath: 'package.json',
parser: 'json-stringify',
plugins: ['.']
};
const fixture = {
files: [
'/lit-html.js',
'/lit-html.js.map',
'/lit-html.d.ts',
'/lit-html.d.ts.map',
'/directives/',
'/parts.js',
'/parts.js.map',
'/parts.d.ts',
'/parts.d.ts.map',
'/src/',
'!/src/test/',
'/development/',
'!/development/test/'
]
};

const input = JSON.stringify(fixture, null, 2);
const output = prettier.format(input, options);

t.snapshot(output);
});
23 changes: 23 additions & 0 deletions test/snapshots/files.js.md
Expand Up @@ -16,3 +16,26 @@ Generated by [AVA](https://ava.li).
]␊
}␊
`

## negations

> Snapshot 1
`{␊
"files": [␊
"/development/",␊
"!/development/test/",␊
"/directives/",␊
"/lit-html.d.ts",␊
"/lit-html.d.ts.map",␊
"/lit-html.js",␊
"/lit-html.js.map",␊
"/parts.d.ts",␊
"/parts.d.ts.map",␊
"/parts.js",␊
"/parts.js.map",␊
"/src/",␊
"!/src/test/"␊
]␊
}␊
`
Binary file modified test/snapshots/files.js.snap
Binary file not shown.

0 comments on commit 1744634

Please sign in to comment.