diff --git a/docs/rules/order-properties.md b/docs/rules/order-properties.md index 6d196e65..99e0e80e 100644 --- a/docs/rules/order-properties.md +++ b/docs/rules/order-properties.md @@ -69,39 +69,9 @@ interface { } ``` -Default: `legacy` +Default: `"sort-package-json"` -```json -[ - "name", - "version", - "private", - "publishConfig", - "description", - "main", - "browser", - "files", - "bin", - "directories", - "man", - "scripts", - "repository", - "keywords", - "author", - "license", - "bugs", - "homepage", - "config", - "dependencies", - "devDependencies", - "peerDependencies", - "optionalDependencies", - "bundledDependencies", - "engines", - "os", - "cpu" -] -``` +> ⚠️ The default value for `order` changed from `"legacy"` to `"sort-package-json"` in v0.6.0. This rule is **autofixable**; run `eslint` with the `--fix` option to sort top-level properties in place. Any properties not present in the array of ordered properties will be left in their original positions. diff --git a/src/rules/order-properties.ts b/src/rules/order-properties.ts index 01a024a6..aaf51875 100644 --- a/src/rules/order-properties.ts +++ b/src/rules/order-properties.ts @@ -43,7 +43,11 @@ export default createRule({ "Program:exit"() { const { ast, text } = context.sourceCode; - const options = context.options[0] ?? { order: "legacy" }; + const options = { + order: "sort-package-json", + ...context.options[0], + } satisfies Options[0]; + const requiredOrder = options.order === "legacy" ? standardOrderLegacy diff --git a/src/tests/rules/order-properties.test.ts b/src/tests/rules/order-properties.test.ts index 0b813282..846b62e8 100644 --- a/src/tests/rules/order-properties.test.ts +++ b/src/tests/rules/order-properties.test.ts @@ -29,13 +29,13 @@ ruleTester.run("order-properties", rule, { "name": "invalid-top-level-property-order", "version": "1.0.0", "description": "npm made me this way", - "main": "index.js", - "scripts": { - "test": "tape" - }, "repository": { "type": "git", "url": "git+https://github.com/fake/github.git" + }, + "main": "index.js", + "scripts": { + "test": "tape" } } `,