@nr1e/commons 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +19 -0
- package/.eslintignore +3 -0
- package/.eslintrc.json +4 -0
- package/.git/COMMIT_EDITMSG +5 -0
- package/.git/FETCH_HEAD +1 -0
- package/.git/HEAD +1 -0
- package/.git/config +18 -0
- package/.git/config.worktree +5 -0
- package/.git/description +1 -0
- package/.git/hooks/applypatch-msg.sample +15 -0
- package/.git/hooks/commit-msg.sample +24 -0
- package/.git/hooks/fsmonitor-watchman.sample +174 -0
- package/.git/hooks/post-update.sample +8 -0
- package/.git/hooks/pre-applypatch.sample +14 -0
- package/.git/hooks/pre-commit.sample +49 -0
- package/.git/hooks/pre-merge-commit.sample +13 -0
- package/.git/hooks/pre-push.sample +53 -0
- package/.git/hooks/pre-rebase.sample +169 -0
- package/.git/hooks/pre-receive.sample +24 -0
- package/.git/hooks/prepare-commit-msg.sample +42 -0
- package/.git/hooks/push-to-checkout.sample +78 -0
- package/.git/hooks/sendemail-validate.sample +77 -0
- package/.git/hooks/update.sample +128 -0
- package/.git/index +0 -0
- package/.git/info/exclude +6 -0
- package/.git/logs/HEAD +2 -0
- package/.git/logs/refs/heads/main +2 -0
- package/.git/logs/refs/remotes/origin/main +2 -0
- package/.git/objects/07/c0af7cd711cab6a55ad3dc349ac8c70775623c +0 -0
- package/.git/objects/0d/698432e2c44311c17b845cc63093a898972b95 +0 -0
- package/.git/objects/10/ba4a7d64968326293182d571a9c73f5e041fb6 +3 -0
- package/.git/objects/12/069a5aa45479564e00749f730582627a276a55 +3 -0
- package/.git/objects/14/5ab9cf82c40696a07ab42f117ba199acb2a50b +4 -0
- package/.git/objects/17/7b0dc4bf884f8ae0403b4aad053e76baafd632 +2 -0
- package/.git/objects/1d/a517ce3527df45a4f28e52ff2c0d9d1c8179f6 +0 -0
- package/.git/objects/27/50076ed23b5211a52ef834f40f183ddecb917a +0 -0
- package/.git/objects/2a/96e4bb57fa4bd69c719dca224b17b569e94e82 +2 -0
- package/.git/objects/2b/38c26b4ec43b8f5574acb164d2ba64bca8e230 +0 -0
- package/.git/objects/2c/61d463bee185f04e7c2bd1d2a15ad1117c589e +0 -0
- package/.git/objects/2d/22dbc836cfd75c8d7640ebe5a4fe90bd2c23c6 +0 -0
- package/.git/objects/2e/58414df7b4d5c972167a83270f78fc4ed508f5 +0 -0
- package/.git/objects/38/0be191ee415827a1217f46626fea4fefba48e5 +0 -0
- package/.git/objects/3a/93aa29cd19bdc95a87d15910baec8455f8b7b7 +0 -0
- package/.git/objects/50/150b739272269be2ede552448013eba65323da +0 -0
- package/.git/objects/53/2b7b796ffd3223f913a5a5e1e17743ee3591fe +0 -0
- package/.git/objects/54/a8535f50287f6a7a8c00aed143ca6e5ee5f5d1 +0 -0
- package/.git/objects/5d/4aa0709f62f1bc1fa80251208b570cb3b89d9c +0 -0
- package/.git/objects/63/1c43e00d4c34ba914c510f4fe2e6df15b8b06e +0 -0
- package/.git/objects/63/9900d13c6182e452e33a3bd638e70a0146c785 +2 -0
- package/.git/objects/64/3fa02661c3a1b54205729a75d2fb5f013833af +0 -0
- package/.git/objects/6c/59086d862516d2fffa5da2035e5003100fb5c7 +0 -0
- package/.git/objects/6c/b74f90a0c799eea1c54a04d8d6a8a9e9691cca +2 -0
- package/.git/objects/70/0e093acb1c1e55d523507411b7940a01a3bb65 +0 -0
- package/.git/objects/71/1ba2014bc137dece4c4156ff5e77e6abaeb95c +0 -0
- package/.git/objects/74/c82ffe8eb71efecbccfdf67b590949c944dd1a +0 -0
- package/.git/objects/76/1413a07839108abb46ef0e4490bd1c1444b4fc +0 -0
- package/.git/objects/77/96f8282f2c553ecdde72bc976478eb3a8a948e +0 -0
- package/.git/objects/79/ee123c2b23e069e35ed634d687e17f731cc702 +0 -0
- package/.git/objects/7d/80af9735f0527db35ecc79ae3c887e445cb3e0 +0 -0
- package/.git/objects/85/1d8d26c2a946ccfd5461a2573665c1fb7d71f7 +0 -0
- package/.git/objects/85/c5f24b8c55496f82a2680f94a7d3fa32887ea0 +0 -0
- package/.git/objects/87/00b3833597b600e6f0ffcfbaf622fd8cfaa9c3 +1 -0
- package/.git/objects/87/f31d3df8e7edbf96e45d80126f878b8e0c243f +0 -0
- package/.git/objects/8b/cc95b71b20c79513e9157b921238ca2c79f906 +0 -0
- package/.git/objects/8d/d819967bdc8457f04c1b5498bce89380d6552b +7 -0
- package/.git/objects/91/b0fba96bf994b6232bb923f2a9929fc258a05f +0 -0
- package/.git/objects/92/608c4e069a4301d466d8d18daecbe7abc9500e +0 -0
- package/.git/objects/94/a25f7f4cb416c083d265558da75d457237d671 +0 -0
- package/.git/objects/9c/69411050eac81b5dce09314516a30b38c41a20 +3 -0
- package/.git/objects/9f/54b5b21769da383f12fb9c7bd364bdb05e13a9 +0 -0
- package/.git/objects/a5/886c22eb68b152bb95ec5151504676d8e78ae1 +0 -0
- package/.git/objects/a6/582c9510e264f3b46fc3b20597a16923a03523 +0 -0
- package/.git/objects/a9/d7db9c0a81b2db47ca92e4e180b30090b27632 +0 -0
- package/.git/objects/ad/c418f9105db9ec488de6831584b82e3929eaef +0 -0
- package/.git/objects/b0/c1c68fbbad6b190434cd2bb0e807796bd56fca +0 -0
- package/.git/objects/b1/0f0d0ef3bc5aaf3a91be0b991cb6fe0fcadc40 +0 -0
- package/.git/objects/b6/3b642cfb4254fc0f7058903abc5b481895c4ef +0 -0
- package/.git/objects/b8/a2c461d7ffed9d4ba242c58a52341832b99e0a +0 -0
- package/.git/objects/ba/5b53857ced8d97f6d6e3fb3538b3273743dafc +2 -0
- package/.git/objects/ba/5ef7104c0d019a9692cd2d78261d96f29e916f +0 -0
- package/.git/objects/bc/91e0079eb00d56dcde16714748f36a10dbd525 +0 -0
- package/.git/objects/c1/beeb895b71b709e48560460199db11b3fc18af +0 -0
- package/.git/objects/c5/166c2aeebaeb0a0f7654223c843c50cd4c8953 +0 -0
- package/.git/objects/d4/0a2096fc36c1fd9c7a9263c458d5e8a4a5bee7 +0 -0
- package/.git/objects/e1/b744bc6076ebeb02fa86af98583ac22e070ec0 +0 -0
- package/.git/objects/e8/019be9e978a8e2f094e748cbb6ce0c7163adee +0 -0
- package/.git/objects/eb/1d744c4e9b47bc902647298424320078e32980 +0 -0
- package/.git/objects/ee/15af38be7f3c3862229e59c6b5688f8e0f6099 +0 -0
- package/.git/objects/f1/9e0f429f231c34432784f9e33b92ac1d598c17 +0 -0
- package/.git/objects/f9/86f2fe82493e85651396b6d5886316d1c890dd +0 -0
- package/.git/refs/heads/main +1 -0
- package/.git/refs/remotes/origin/main +1 -0
- package/.git/refs/tags/v0.1.1 +1 -0
- package/.git/shallow +1 -0
- package/.github/dependabot.yml +10 -0
- package/.github/workflows/ci.yml +12 -0
- package/.github/workflows/issues.yml +13 -0
- package/.github/workflows/publish.yml +21 -0
- package/.gitignore +13 -0
- package/.idea/.gitignore +10 -0
- package/.idea/aws.xml +11 -0
- package/.idea/codeStyles/Project.xml +58 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/commons-js.iml +14 -0
- package/.idea/inspectionProfiles/Project_Default.xml +7 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/.npmrc +1 -0
- package/.prettierignore +7 -0
- package/.prettierrc.cjs +3 -0
- package/LICENSE +26 -0
- package/README.md +14 -0
- package/coverage/base.css +224 -0
- package/coverage/bitsnbytes/b64.mts.html +559 -0
- package/coverage/bitsnbytes/index.html +131 -0
- package/coverage/bitsnbytes/index.mts.html +88 -0
- package/coverage/clover.xml +1003 -0
- package/coverage/coverage-final.json +15 -0
- package/coverage/errors/errors.mts.html +898 -0
- package/coverage/errors/index.html +131 -0
- package/coverage/errors/index.mts.html +88 -0
- package/coverage/favicon.png +0 -0
- package/coverage/http/http-method.mts.html +112 -0
- package/coverage/http/http-status-code.mts.html +211 -0
- package/coverage/http/index.html +146 -0
- package/coverage/http/index.mts.html +91 -0
- package/coverage/index.html +191 -0
- package/coverage/lang/index.html +146 -0
- package/coverage/lang/index.mts.html +91 -0
- package/coverage/lang/sleep.mts.html +109 -0
- package/coverage/lang/type-functions.mts.html +124 -0
- package/coverage/oauth/crypto-functions.mts.html +217 -0
- package/coverage/oauth/index.html +131 -0
- package/coverage/oauth/index.mts.html +88 -0
- package/coverage/prettify.css +1 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/validator/index.html +131 -0
- package/coverage/validator/index.mts.html +88 -0
- package/coverage/validator/validators.mts.html +1237 -0
- package/dist/package.json +72 -0
- package/node_modules/@eslint/eslintrc/LICENSE +19 -0
- package/node_modules/@eslint/eslintrc/README.md +115 -0
- package/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs +1104 -0
- package/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map +1 -0
- package/node_modules/@eslint/eslintrc/dist/eslintrc.cjs +4344 -0
- package/node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map +1 -0
- package/node_modules/@eslint/eslintrc/package.json +82 -0
- package/node_modules/@eslint/eslintrc/universal.js +9 -0
- package/node_modules/@eslint/js/LICENSE +19 -0
- package/node_modules/@eslint/js/README.md +57 -0
- package/node_modules/@eslint/js/package.json +31 -0
- package/node_modules/@eslint/js/src/index.js +17 -0
- package/node_modules/@eslint-community/eslint-utils/LICENSE +21 -0
- package/node_modules/@eslint-community/eslint-utils/README.md +37 -0
- package/node_modules/@eslint-community/eslint-utils/index.js +2068 -0
- package/node_modules/@eslint-community/eslint-utils/index.js.map +1 -0
- package/node_modules/@eslint-community/eslint-utils/index.mjs +2027 -0
- package/node_modules/@eslint-community/eslint-utils/index.mjs.map +1 -0
- package/node_modules/@eslint-community/eslint-utils/package.json +73 -0
- package/node_modules/@eslint-community/regexpp/LICENSE +21 -0
- package/node_modules/@eslint-community/regexpp/README.md +177 -0
- package/node_modules/@eslint-community/regexpp/index.d.ts +1065 -0
- package/node_modules/@eslint-community/regexpp/index.js +2747 -0
- package/node_modules/@eslint-community/regexpp/index.js.map +1 -0
- package/node_modules/@eslint-community/regexpp/index.mjs +2737 -0
- package/node_modules/@eslint-community/regexpp/index.mjs.map +1 -0
- package/node_modules/@eslint-community/regexpp/package.json +93 -0
- package/node_modules/@types/node/LICENSE +21 -0
- package/node_modules/@types/node/README.md +15 -0
- package/node_modules/@types/node/package.json +217 -0
- package/node_modules/@typescript-eslint/eslint-plugin/LICENSE +21 -0
- package/node_modules/@typescript-eslint/eslint-plugin/README.md +10 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/index.js +23 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/README.md +23 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/TEMPLATE.md +26 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/adjacent-overload-signatures.md +93 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/array-type.md +103 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/await-thenable.md +40 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/ban-ts-comment.md +148 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/ban-tslint-comment.md +39 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/ban-types.md +183 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/block-spacing.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/brace-style.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/camelcase.md +10 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/class-literal-property-style.md +114 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/comma-dangle.md +22 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/comma-spacing.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-generic-constructors.md +73 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-indexed-object-style.md +80 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-assertions.md +108 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-definitions.md +82 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-exports.md +100 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-imports.md +105 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/default-param-last.md +48 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/dot-notation.md +77 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/explicit-function-return-type.md +319 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/explicit-member-accessibility.md +331 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/explicit-module-boundary-types.md +250 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/func-call-spacing.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/indent.md +20 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/init-declarations.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/key-spacing.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/keyword-spacing.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/lines-around-comment.md +37 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/lines-between-class-members.md +63 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/member-delimiter-style.md +161 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/member-ordering.md +1360 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/method-signature-style.md +110 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/naming-convention.md +706 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-array-constructor.md +35 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-base-to-string.md +88 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-confusing-non-null-assertion.md +56 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-confusing-void-expression.md +116 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-dupe-class-members.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-duplicate-enum-values.md +50 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-duplicate-imports.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-duplicate-type-constituents.md +61 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-dynamic-delete.md +53 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-empty-function.md +88 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-empty-interface.md +70 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-explicit-any.md +174 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extra-non-null-assertion.md +52 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extra-parens.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extra-semi.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extraneous-class.md +294 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-floating-promises.md +106 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-for-in-array.md +56 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-implicit-any-catch.md +73 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-implied-eval.md +101 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-import-type-side-effects.md +75 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-inferrable-types.md +103 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-invalid-this.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-invalid-void-type.md +113 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-loop-func.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-loss-of-precision.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-magic-numbers.md +131 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-meaningless-void-operator.md +47 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-misused-new.md +46 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-misused-promises.md +245 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-mixed-enums.md +88 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-namespace.md +129 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-non-null-asserted-nullish-coalescing.md +49 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-non-null-asserted-optional-chain.md +35 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-non-null-assertion.md +42 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-parameter-properties.md +406 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-redeclare.md +73 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-redundant-type-constituents.md +78 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-require-imports.md +37 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-restricted-imports.md +63 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-shadow.md +101 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-this-alias.md +38 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-throw-literal.md +111 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-type-alias.md +602 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.md +133 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-condition.md +103 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-qualifier.md +51 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md +73 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md +77 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md +55 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-argument.md +83 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-assignment.md +86 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-call.md +58 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-declaration-merging.md +54 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-enum-comparison.md +75 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-member-access.md +64 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-return.md +103 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unused-expressions.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unused-vars.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-use-before-define.md +97 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-useless-constructor.md +21 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-useless-empty-export.md +43 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-var-requires.md +37 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/non-nullable-type-assertion-style.md +41 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/object-curly-spacing.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/padding-line-between-statements.md +35 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/parameter-properties.md +485 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-as-const.md +44 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-enum-initializers.md +62 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-for-of.md +46 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-function-type.md +92 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-includes.md +77 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-literal-enum-member.md +101 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-namespace-keyword.md +47 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-nullish-coalescing.md +164 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-optional-chain.md +71 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md +268 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-readonly.md +87 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md +58 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-regexp-exec.md +46 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-return-this-type.md +87 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md +57 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-ts-expect-error.md +69 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/promise-function-async.md +59 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/quotes.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/require-array-sort-compare.md +78 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/require-await.md +24 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/restrict-plus-operands.md +208 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/restrict-template-expressions.md +117 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/return-await.md +216 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/semi.md +16 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/sort-type-constituents.md +101 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/sort-type-union-intersection-members.md +106 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/space-before-blocks.md +42 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/space-before-function-paren.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/space-infix-ops.md +16 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/strict-boolean-expressions.md +183 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/switch-exhaustiveness-check.md +106 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/triple-slash-reference.md +61 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/type-annotation-spacing.md +303 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/typedef.md +320 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/unbound-method.md +103 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/unified-signatures.md +70 -0
- package/node_modules/@typescript-eslint/eslint-plugin/index.d.ts +4 -0
- package/node_modules/@typescript-eslint/eslint-plugin/package.json +87 -0
- package/node_modules/@typescript-eslint/parser/LICENSE +22 -0
- package/node_modules/@typescript-eslint/parser/README.md +10 -0
- package/node_modules/@typescript-eslint/parser/dist/index.js +17 -0
- package/node_modules/@typescript-eslint/parser/package.json +75 -0
- package/node_modules/@typescript-eslint/scope-manager/LICENSE +21 -0
- package/node_modules/@typescript-eslint/scope-manager/README.md +8 -0
- package/node_modules/@typescript-eslint/scope-manager/dist/index.js +31 -0
- package/node_modules/@typescript-eslint/scope-manager/package.json +67 -0
- package/node_modules/@typescript-eslint/type-utils/LICENSE +21 -0
- package/node_modules/@typescript-eslint/type-utils/README.md +12 -0
- package/node_modules/@typescript-eslint/type-utils/dist/index.js +36 -0
- package/node_modules/@typescript-eslint/type-utils/package.json +71 -0
- package/node_modules/@typescript-eslint/types/LICENSE +21 -0
- package/node_modules/@typescript-eslint/types/README.md +12 -0
- package/node_modules/@typescript-eslint/types/dist/index.js +24 -0
- package/node_modules/@typescript-eslint/types/package.json +84 -0
- package/node_modules/@typescript-eslint/typescript-estree/LICENSE +26 -0
- package/node_modules/@typescript-eslint/typescript-estree/README.md +10 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/index.js +38 -0
- package/node_modules/@typescript-eslint/typescript-estree/package.json +85 -0
- package/node_modules/@typescript-eslint/utils/LICENSE +21 -0
- package/node_modules/@typescript-eslint/utils/README.md +10 -0
- package/node_modules/@typescript-eslint/utils/dist/index.js +41 -0
- package/node_modules/@typescript-eslint/utils/package.json +70 -0
- package/node_modules/@typescript-eslint/visitor-keys/LICENSE +21 -0
- package/node_modules/@typescript-eslint/visitor-keys/README.md +10 -0
- package/node_modules/@typescript-eslint/visitor-keys/dist/index.js +8 -0
- package/node_modules/@typescript-eslint/visitor-keys/package.json +60 -0
- package/node_modules/@vitest/coverage-v8/LICENSE +21 -0
- package/node_modules/@vitest/coverage-v8/dist/index.js +54 -0
- package/node_modules/@vitest/coverage-v8/package.json +72 -0
- package/package.json +6 -6
- package/pnpm-lock.yaml +3277 -0
- package/src/bitsnbytes/b64.mts +158 -0
- package/src/bitsnbytes/b64.test.mts +78 -0
- package/src/bitsnbytes/index.mts +1 -0
- package/src/errors/errors.mts +271 -0
- package/src/errors/errors.test.mts +74 -0
- package/src/errors/index.mts +1 -0
- package/src/http/http-method.mts +9 -0
- package/src/http/http-status-code.mts +42 -0
- package/src/http/index.mts +2 -0
- package/src/lang/index.mts +2 -0
- package/src/lang/sleep.mts +8 -0
- package/src/lang/type-functions.mts +13 -0
- package/src/oauth/crypto-functions.mts +44 -0
- package/src/oauth/crypto-functions.test.mts +48 -0
- package/src/oauth/index.mts +1 -0
- package/src/validator/index.mts +1 -0
- package/src/validator/validators.mts +384 -0
- package/src/validator/validators.test.mts +245 -0
- package/tsconfig.json +18 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.d.mts +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.d.mts.map +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.mjs +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.mjs.map +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.test.d.mts +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.test.d.mts.map +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.test.mjs +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.test.mjs.map +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/index.d.mts +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/index.d.mts.map +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/index.mjs +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/index.mjs.map +0 -0
- /package/{errors → dist/errors}/errors.d.mts +0 -0
- /package/{errors → dist/errors}/errors.d.mts.map +0 -0
- /package/{errors → dist/errors}/errors.mjs +0 -0
- /package/{errors → dist/errors}/errors.mjs.map +0 -0
- /package/{errors → dist/errors}/errors.test.d.mts +0 -0
- /package/{errors → dist/errors}/errors.test.d.mts.map +0 -0
- /package/{errors → dist/errors}/errors.test.mjs +0 -0
- /package/{errors → dist/errors}/errors.test.mjs.map +0 -0
- /package/{errors → dist/errors}/index.d.mts +0 -0
- /package/{errors → dist/errors}/index.d.mts.map +0 -0
- /package/{errors → dist/errors}/index.mjs +0 -0
- /package/{errors → dist/errors}/index.mjs.map +0 -0
- /package/{http → dist/http}/http-method.d.mts +0 -0
- /package/{http → dist/http}/http-method.d.mts.map +0 -0
- /package/{http → dist/http}/http-method.mjs +0 -0
- /package/{http → dist/http}/http-method.mjs.map +0 -0
- /package/{http → dist/http}/http-status-code.d.mts +0 -0
- /package/{http → dist/http}/http-status-code.d.mts.map +0 -0
- /package/{http → dist/http}/http-status-code.mjs +0 -0
- /package/{http → dist/http}/http-status-code.mjs.map +0 -0
- /package/{http → dist/http}/index.d.mts +0 -0
- /package/{http → dist/http}/index.d.mts.map +0 -0
- /package/{http → dist/http}/index.mjs +0 -0
- /package/{http → dist/http}/index.mjs.map +0 -0
- /package/{lang → dist/lang}/index.d.mts +0 -0
- /package/{lang → dist/lang}/index.d.mts.map +0 -0
- /package/{lang → dist/lang}/index.mjs +0 -0
- /package/{lang → dist/lang}/index.mjs.map +0 -0
- /package/{lang → dist/lang}/sleep.d.mts +0 -0
- /package/{lang → dist/lang}/sleep.d.mts.map +0 -0
- /package/{lang → dist/lang}/sleep.mjs +0 -0
- /package/{lang → dist/lang}/sleep.mjs.map +0 -0
- /package/{lang → dist/lang}/type-functions.d.mts +0 -0
- /package/{lang → dist/lang}/type-functions.d.mts.map +0 -0
- /package/{lang → dist/lang}/type-functions.mjs +0 -0
- /package/{lang → dist/lang}/type-functions.mjs.map +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.d.mts +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.d.mts.map +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.mjs +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.mjs.map +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.test.d.mts +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.test.d.mts.map +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.test.mjs +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.test.mjs.map +0 -0
- /package/{oauth → dist/oauth}/index.d.mts +0 -0
- /package/{oauth → dist/oauth}/index.d.mts.map +0 -0
- /package/{oauth → dist/oauth}/index.mjs +0 -0
- /package/{oauth → dist/oauth}/index.mjs.map +0 -0
- /package/{validator → dist/validator}/index.d.mts +0 -0
- /package/{validator → dist/validator}/index.d.mts.map +0 -0
- /package/{validator → dist/validator}/index.mjs +0 -0
- /package/{validator → dist/validator}/index.mjs.map +0 -0
- /package/{validator → dist/validator}/validators.d.mts +0 -0
- /package/{validator → dist/validator}/validators.d.mts.map +0 -0
- /package/{validator → dist/validator}/validators.mjs +0 -0
- /package/{validator → dist/validator}/validators.mjs.map +0 -0
- /package/{validator → dist/validator}/validators.test.d.mts +0 -0
- /package/{validator → dist/validator}/validators.test.d.mts.map +0 -0
- /package/{validator → dist/validator}/validators.test.mjs +0 -0
- /package/{validator → dist/validator}/validators.test.mjs.map +0 -0
|
@@ -0,0 +1,1360 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'Require a consistent member declaration order.'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
|
+
>
|
|
7
|
+
> See **https://typescript-eslint.io/rules/member-ordering** for documentation.
|
|
8
|
+
|
|
9
|
+
This rule aims to standardize the way classes, interfaces, and type literals are structured and ordered.
|
|
10
|
+
A consistent ordering of fields, methods and constructors can make code easier to read, navigate, and edit.
|
|
11
|
+
|
|
12
|
+
## Options
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
interface Options {
|
|
16
|
+
default?: OrderConfig;
|
|
17
|
+
classes?: OrderConfig;
|
|
18
|
+
classExpressions?: OrderConfig;
|
|
19
|
+
interfaces?: OrderConfig;
|
|
20
|
+
typeLiterals?: OrderConfig;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type OrderConfig = MemberType[] | SortedOrderConfig | 'never';
|
|
24
|
+
|
|
25
|
+
interface SortedOrderConfig {
|
|
26
|
+
memberTypes?: MemberType[] | 'never';
|
|
27
|
+
optionalityOrder?: 'optional-first' | 'required-first';
|
|
28
|
+
order:
|
|
29
|
+
| 'alphabetically'
|
|
30
|
+
| 'alphabetically-case-insensitive'
|
|
31
|
+
| 'as-written'
|
|
32
|
+
| 'natural'
|
|
33
|
+
| 'natural-case-insensitive';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// See below for the more specific MemberType strings
|
|
37
|
+
type MemberType = string | string[];
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
You can configure `OrderConfig` options for:
|
|
41
|
+
|
|
42
|
+
- **`default`**: all constructs (used as a fallback)
|
|
43
|
+
- **`classes`**?: override ordering specifically for classes
|
|
44
|
+
- **`classExpressions`**?: override ordering specifically for class expressions
|
|
45
|
+
- **`interfaces`**?: override ordering specifically for interfaces
|
|
46
|
+
- **`typeLiterals`**?: override ordering specifically for type literals
|
|
47
|
+
|
|
48
|
+
The `OrderConfig` settings for each kind of construct may configure sorting on up to three levels:
|
|
49
|
+
|
|
50
|
+
- **`memberTypes`**: organizing on member type groups such as methods vs. properties
|
|
51
|
+
- **`optionalityOrder`**: whether to put all optional members first or all required members first
|
|
52
|
+
- **`order`**: organizing based on member names, such as alphabetically
|
|
53
|
+
|
|
54
|
+
### Groups
|
|
55
|
+
|
|
56
|
+
You can define many different groups based on different attributes of members.
|
|
57
|
+
The supported member attributes are, in order:
|
|
58
|
+
|
|
59
|
+
- **Accessibility** (`'public' | 'protected' | 'private' | '#private'`)
|
|
60
|
+
- **Decoration** (`'decorated'`): Whether the member has an explicit accessibility decorator
|
|
61
|
+
- **Kind** (`'call-signature' | 'constructor' | 'field' | 'readonly-field' | 'get' | 'method' | 'set' | 'signature' | 'readonly-signature'`)
|
|
62
|
+
|
|
63
|
+
Member attributes may be joined with a `'-'` to combine into more specific groups.
|
|
64
|
+
For example, `'public-field'` would come before `'private-field'`.
|
|
65
|
+
|
|
66
|
+
### Orders
|
|
67
|
+
|
|
68
|
+
The `order` value specifies what order members should be within a group.
|
|
69
|
+
It defaults to `as-written`, meaning any order is fine.
|
|
70
|
+
Other allowed values are:
|
|
71
|
+
|
|
72
|
+
- `alphabetically`: Sorted in a-z alphabetical order, directly using string `<` comparison (so `B` comes before `a`)
|
|
73
|
+
- `alphabetically-case-insensitive`: Sorted in a-z alphabetical order, ignoring case (so `a` comes before `B`)
|
|
74
|
+
- `natural`: Same as `alphabetically`, but using [`natural-compare-lite`](https://github.com/litejs/natural-compare-lite) for more friendly sorting of numbers
|
|
75
|
+
- `natural-case-insensitive`: Same as `alphabetically-case-insensitive`, but using [`natural-compare-lite`](https://github.com/litejs/natural-compare-lite) for more friendly sorting of numbers
|
|
76
|
+
|
|
77
|
+
### Default configuration
|
|
78
|
+
|
|
79
|
+
The default configuration looks as follows:
|
|
80
|
+
|
|
81
|
+
```jsonc
|
|
82
|
+
{
|
|
83
|
+
"default": [
|
|
84
|
+
// Index signature
|
|
85
|
+
"signature",
|
|
86
|
+
"call-signature",
|
|
87
|
+
|
|
88
|
+
// Fields
|
|
89
|
+
"public-static-field",
|
|
90
|
+
"protected-static-field",
|
|
91
|
+
"private-static-field",
|
|
92
|
+
"#private-static-field",
|
|
93
|
+
|
|
94
|
+
"public-decorated-field",
|
|
95
|
+
"protected-decorated-field",
|
|
96
|
+
"private-decorated-field",
|
|
97
|
+
|
|
98
|
+
"public-instance-field",
|
|
99
|
+
"protected-instance-field",
|
|
100
|
+
"private-instance-field",
|
|
101
|
+
"#private-instance-field",
|
|
102
|
+
|
|
103
|
+
"public-abstract-field",
|
|
104
|
+
"protected-abstract-field",
|
|
105
|
+
|
|
106
|
+
"public-field",
|
|
107
|
+
"protected-field",
|
|
108
|
+
"private-field",
|
|
109
|
+
"#private-field",
|
|
110
|
+
|
|
111
|
+
"static-field",
|
|
112
|
+
"instance-field",
|
|
113
|
+
"abstract-field",
|
|
114
|
+
|
|
115
|
+
"decorated-field",
|
|
116
|
+
|
|
117
|
+
"field",
|
|
118
|
+
|
|
119
|
+
// Static initialization
|
|
120
|
+
"static-initialization",
|
|
121
|
+
|
|
122
|
+
// Constructors
|
|
123
|
+
"public-constructor",
|
|
124
|
+
"protected-constructor",
|
|
125
|
+
"private-constructor",
|
|
126
|
+
|
|
127
|
+
"constructor",
|
|
128
|
+
|
|
129
|
+
// Getters
|
|
130
|
+
"public-static-get",
|
|
131
|
+
"protected-static-get",
|
|
132
|
+
"private-static-get",
|
|
133
|
+
"#private-static-get",
|
|
134
|
+
|
|
135
|
+
"public-decorated-get",
|
|
136
|
+
"protected-decorated-get",
|
|
137
|
+
"private-decorated-get",
|
|
138
|
+
|
|
139
|
+
"public-instance-get",
|
|
140
|
+
"protected-instance-get",
|
|
141
|
+
"private-instance-get",
|
|
142
|
+
"#private-instance-get",
|
|
143
|
+
|
|
144
|
+
"public-abstract-get",
|
|
145
|
+
"protected-abstract-get",
|
|
146
|
+
|
|
147
|
+
"public-get",
|
|
148
|
+
"protected-get",
|
|
149
|
+
"private-get",
|
|
150
|
+
"#private-get",
|
|
151
|
+
|
|
152
|
+
"static-get",
|
|
153
|
+
"instance-get",
|
|
154
|
+
"abstract-get",
|
|
155
|
+
|
|
156
|
+
"decorated-get",
|
|
157
|
+
|
|
158
|
+
"get",
|
|
159
|
+
|
|
160
|
+
// Setters
|
|
161
|
+
"public-static-set",
|
|
162
|
+
"protected-static-set",
|
|
163
|
+
"private-static-set",
|
|
164
|
+
"#private-static-set",
|
|
165
|
+
|
|
166
|
+
"public-decorated-set",
|
|
167
|
+
"protected-decorated-set",
|
|
168
|
+
"private-decorated-set",
|
|
169
|
+
|
|
170
|
+
"public-instance-set",
|
|
171
|
+
"protected-instance-set",
|
|
172
|
+
"private-instance-set",
|
|
173
|
+
"#private-instance-set",
|
|
174
|
+
|
|
175
|
+
"public-abstract-set",
|
|
176
|
+
"protected-abstract-set",
|
|
177
|
+
|
|
178
|
+
"public-set",
|
|
179
|
+
"protected-set",
|
|
180
|
+
"private-set",
|
|
181
|
+
"#private-set",
|
|
182
|
+
|
|
183
|
+
"static-set",
|
|
184
|
+
"instance-set",
|
|
185
|
+
"abstract-set",
|
|
186
|
+
|
|
187
|
+
"decorated-set",
|
|
188
|
+
|
|
189
|
+
"set",
|
|
190
|
+
|
|
191
|
+
// Methods
|
|
192
|
+
"public-static-method",
|
|
193
|
+
"protected-static-method",
|
|
194
|
+
"private-static-method",
|
|
195
|
+
"#private-static-method",
|
|
196
|
+
|
|
197
|
+
"public-decorated-method",
|
|
198
|
+
"protected-decorated-method",
|
|
199
|
+
"private-decorated-method",
|
|
200
|
+
|
|
201
|
+
"public-instance-method",
|
|
202
|
+
"protected-instance-method",
|
|
203
|
+
"private-instance-method",
|
|
204
|
+
"#private-instance-method",
|
|
205
|
+
|
|
206
|
+
"public-abstract-method",
|
|
207
|
+
"protected-abstract-method",
|
|
208
|
+
|
|
209
|
+
"public-method",
|
|
210
|
+
"protected-method",
|
|
211
|
+
"private-method",
|
|
212
|
+
"#private-method",
|
|
213
|
+
|
|
214
|
+
"static-method",
|
|
215
|
+
"instance-method",
|
|
216
|
+
"abstract-method",
|
|
217
|
+
|
|
218
|
+
"decorated-method",
|
|
219
|
+
|
|
220
|
+
"method"
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
:::note
|
|
226
|
+
The default configuration contains member group types which contain other member types.
|
|
227
|
+
This is intentional to provide better error messages.
|
|
228
|
+
:::
|
|
229
|
+
|
|
230
|
+
:::tip
|
|
231
|
+
By default, the members are not sorted.
|
|
232
|
+
If you want to sort them alphabetically, you have to provide a custom configuration.
|
|
233
|
+
:::
|
|
234
|
+
|
|
235
|
+
## Examples
|
|
236
|
+
|
|
237
|
+
### General Order on All Constructs
|
|
238
|
+
|
|
239
|
+
This config specifies the order for all constructs.
|
|
240
|
+
It ignores member types other than signatures, methods, constructors, and fields.
|
|
241
|
+
It also ignores accessibility and scope.
|
|
242
|
+
|
|
243
|
+
```jsonc
|
|
244
|
+
// .eslintrc.json
|
|
245
|
+
{
|
|
246
|
+
"rules": {
|
|
247
|
+
"@typescript-eslint/member-ordering": [
|
|
248
|
+
"error",
|
|
249
|
+
{ "default": ["signature", "method", "constructor", "field"] }
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
<!--tabs-->
|
|
256
|
+
|
|
257
|
+
#### ❌ Incorrect
|
|
258
|
+
|
|
259
|
+
```ts
|
|
260
|
+
interface Foo {
|
|
261
|
+
B: string; // -> field
|
|
262
|
+
|
|
263
|
+
new (); // -> constructor
|
|
264
|
+
|
|
265
|
+
A(): void; // -> method
|
|
266
|
+
|
|
267
|
+
[Z: string]: any; // -> signature
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
type Foo = {
|
|
273
|
+
B: string; // -> field
|
|
274
|
+
|
|
275
|
+
// no constructor
|
|
276
|
+
|
|
277
|
+
A(): void; // -> method
|
|
278
|
+
|
|
279
|
+
// no signature
|
|
280
|
+
};
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
```ts
|
|
284
|
+
class Foo {
|
|
285
|
+
private C: string; // -> field
|
|
286
|
+
public D: string; // -> field
|
|
287
|
+
protected static E: string; // -> field
|
|
288
|
+
|
|
289
|
+
constructor() {} // -> constructor
|
|
290
|
+
|
|
291
|
+
public static A(): void {} // -> method
|
|
292
|
+
public B(): void {} // -> method
|
|
293
|
+
|
|
294
|
+
[Z: string]: any; // -> signature
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
const Foo = class {
|
|
300
|
+
private C: string; // -> field
|
|
301
|
+
public D: string; // -> field
|
|
302
|
+
|
|
303
|
+
constructor() {} // -> constructor
|
|
304
|
+
|
|
305
|
+
public static A(): void {} // -> method
|
|
306
|
+
public B(): void {} // -> method
|
|
307
|
+
|
|
308
|
+
[Z: string]: any; // -> signature
|
|
309
|
+
|
|
310
|
+
protected static E: string; // -> field
|
|
311
|
+
};
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
#### ✅ Correct
|
|
315
|
+
|
|
316
|
+
```ts
|
|
317
|
+
interface Foo {
|
|
318
|
+
[Z: string]: any; // -> signature
|
|
319
|
+
|
|
320
|
+
A(): void; // -> method
|
|
321
|
+
|
|
322
|
+
new (); // -> constructor
|
|
323
|
+
|
|
324
|
+
B: string; // -> field
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
type Foo = {
|
|
330
|
+
// no signature
|
|
331
|
+
|
|
332
|
+
A(): void; // -> method
|
|
333
|
+
|
|
334
|
+
// no constructor
|
|
335
|
+
|
|
336
|
+
B: string; // -> field
|
|
337
|
+
};
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
```ts
|
|
341
|
+
class Foo {
|
|
342
|
+
[Z: string]: any; // -> signature
|
|
343
|
+
|
|
344
|
+
public static A(): void {} // -> method
|
|
345
|
+
public B(): void {} // -> method
|
|
346
|
+
|
|
347
|
+
constructor() {} // -> constructor
|
|
348
|
+
|
|
349
|
+
private C: string; // -> field
|
|
350
|
+
public D: string; // -> field
|
|
351
|
+
protected static E: string; // -> field
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
const Foo = class {
|
|
357
|
+
[Z: string]: any; // -> signature
|
|
358
|
+
|
|
359
|
+
public static A(): void {} // -> method
|
|
360
|
+
public B(): void {} // -> method
|
|
361
|
+
|
|
362
|
+
constructor() {} // -> constructor
|
|
363
|
+
|
|
364
|
+
private C: string; // -> field
|
|
365
|
+
public D: string; // -> field
|
|
366
|
+
protected static E: string; // -> field
|
|
367
|
+
};
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### Classes
|
|
371
|
+
|
|
372
|
+
#### Public Instance Methods Before Public Static Fields
|
|
373
|
+
|
|
374
|
+
This config specifies that public instance methods should come first before public static fields.
|
|
375
|
+
Everything else can be placed anywhere.
|
|
376
|
+
It doesn't apply to interfaces or type literals as accessibility and scope are not part of them.
|
|
377
|
+
|
|
378
|
+
```jsonc
|
|
379
|
+
// .eslintrc.json
|
|
380
|
+
{
|
|
381
|
+
"rules": {
|
|
382
|
+
"@typescript-eslint/member-ordering": [
|
|
383
|
+
"error",
|
|
384
|
+
{ "default": ["public-instance-method", "public-static-field"] }
|
|
385
|
+
]
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
<!--tabs-->
|
|
391
|
+
|
|
392
|
+
##### ❌ Incorrect
|
|
393
|
+
|
|
394
|
+
```ts
|
|
395
|
+
class Foo {
|
|
396
|
+
private C: string; // (irrelevant)
|
|
397
|
+
|
|
398
|
+
public D: string; // (irrelevant)
|
|
399
|
+
|
|
400
|
+
public static E: string; // -> public static field
|
|
401
|
+
|
|
402
|
+
constructor() {} // (irrelevant)
|
|
403
|
+
|
|
404
|
+
public static A(): void {} // (irrelevant)
|
|
405
|
+
|
|
406
|
+
[Z: string]: any; // (irrelevant)
|
|
407
|
+
|
|
408
|
+
public B(): void {} // -> public instance method
|
|
409
|
+
}
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
```ts
|
|
413
|
+
const Foo = class {
|
|
414
|
+
private C: string; // (irrelevant)
|
|
415
|
+
|
|
416
|
+
[Z: string]: any; // (irrelevant)
|
|
417
|
+
|
|
418
|
+
public static E: string; // -> public static field
|
|
419
|
+
|
|
420
|
+
public D: string; // (irrelevant)
|
|
421
|
+
|
|
422
|
+
constructor() {} // (irrelevant)
|
|
423
|
+
|
|
424
|
+
public static A(): void {} // (irrelevant)
|
|
425
|
+
|
|
426
|
+
public B(): void {} // -> public instance method
|
|
427
|
+
};
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
##### ✅ Correct
|
|
431
|
+
|
|
432
|
+
```ts
|
|
433
|
+
class Foo {
|
|
434
|
+
public B(): void {} // -> public instance method
|
|
435
|
+
|
|
436
|
+
private C: string; // (irrelevant)
|
|
437
|
+
|
|
438
|
+
public D: string; // (irrelevant)
|
|
439
|
+
|
|
440
|
+
public static E: string; // -> public static field
|
|
441
|
+
|
|
442
|
+
constructor() {} // (irrelevant)
|
|
443
|
+
|
|
444
|
+
public static A(): void {} // (irrelevant)
|
|
445
|
+
|
|
446
|
+
[Z: string]: any; // (irrelevant)
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
```ts
|
|
451
|
+
const Foo = class {
|
|
452
|
+
public B(): void {} // -> public instance method
|
|
453
|
+
|
|
454
|
+
private C: string; // (irrelevant)
|
|
455
|
+
|
|
456
|
+
[Z: string]: any; // (irrelevant)
|
|
457
|
+
|
|
458
|
+
public D: string; // (irrelevant)
|
|
459
|
+
|
|
460
|
+
constructor() {} // (irrelevant)
|
|
461
|
+
|
|
462
|
+
public static A(): void {} // (irrelevant)
|
|
463
|
+
|
|
464
|
+
public static E: string; // -> public static field
|
|
465
|
+
};
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
#### Static Fields Before Instance Fields
|
|
469
|
+
|
|
470
|
+
This config specifies that static fields should come before instance fields, with public static fields first.
|
|
471
|
+
It doesn't apply to interfaces or type literals as accessibility and scope are not part of them.
|
|
472
|
+
|
|
473
|
+
```jsonc
|
|
474
|
+
{
|
|
475
|
+
"rules": {
|
|
476
|
+
"@typescript-eslint/member-ordering": [
|
|
477
|
+
"error",
|
|
478
|
+
{ "default": ["public-static-field", "static-field", "instance-field"] }
|
|
479
|
+
]
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
<!--tabs-->
|
|
485
|
+
|
|
486
|
+
##### ❌ Incorrect
|
|
487
|
+
|
|
488
|
+
```ts
|
|
489
|
+
class Foo {
|
|
490
|
+
private E: string; // -> instance field
|
|
491
|
+
|
|
492
|
+
private static B: string; // -> static field
|
|
493
|
+
protected static C: string; // -> static field
|
|
494
|
+
private static D: string; // -> static field
|
|
495
|
+
|
|
496
|
+
public static A: string; // -> public static field
|
|
497
|
+
|
|
498
|
+
[Z: string]: any; // (irrelevant)
|
|
499
|
+
}
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
```ts
|
|
503
|
+
const foo = class {
|
|
504
|
+
public T(): void {} // method (irrelevant)
|
|
505
|
+
|
|
506
|
+
private static B: string; // -> static field
|
|
507
|
+
|
|
508
|
+
constructor() {} // constructor (irrelevant)
|
|
509
|
+
|
|
510
|
+
private E: string; // -> instance field
|
|
511
|
+
|
|
512
|
+
protected static C: string; // -> static field
|
|
513
|
+
private static D: string; // -> static field
|
|
514
|
+
|
|
515
|
+
[Z: string]: any; // signature (irrelevant)
|
|
516
|
+
|
|
517
|
+
public static A: string; // -> public static field
|
|
518
|
+
};
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
##### ✅ Correct
|
|
522
|
+
|
|
523
|
+
```ts
|
|
524
|
+
class Foo {
|
|
525
|
+
public static A: string; // -> public static field
|
|
526
|
+
|
|
527
|
+
private static B: string; // -> static field
|
|
528
|
+
protected static C: string; // -> static field
|
|
529
|
+
private static D: string; // -> static field
|
|
530
|
+
|
|
531
|
+
private E: string; // -> instance field
|
|
532
|
+
|
|
533
|
+
[Z: string]: any; // (irrelevant)
|
|
534
|
+
}
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
```ts
|
|
538
|
+
const foo = class {
|
|
539
|
+
[Z: string]: any; // -> signature (irrelevant)
|
|
540
|
+
|
|
541
|
+
public static A: string; // -> public static field
|
|
542
|
+
|
|
543
|
+
constructor() {} // -> constructor (irrelevant)
|
|
544
|
+
|
|
545
|
+
private static B: string; // -> static field
|
|
546
|
+
protected static C: string; // -> static field
|
|
547
|
+
private static D: string; // -> static field
|
|
548
|
+
|
|
549
|
+
private E: string; // -> instance field
|
|
550
|
+
|
|
551
|
+
public T(): void {} // -> method (irrelevant)
|
|
552
|
+
};
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
#### Class Declarations
|
|
556
|
+
|
|
557
|
+
This config only specifies an order for classes: methods, then the constructor, then fields.
|
|
558
|
+
It does not apply to class expressions (use `classExpressions` for them).
|
|
559
|
+
Default settings will be used for class declarations and all other syntax constructs other than class declarations.
|
|
560
|
+
|
|
561
|
+
```jsonc
|
|
562
|
+
// .eslintrc.json
|
|
563
|
+
{
|
|
564
|
+
"rules": {
|
|
565
|
+
"@typescript-eslint/member-ordering": [
|
|
566
|
+
"error",
|
|
567
|
+
{ "classes": ["method", "constructor", "field"] }
|
|
568
|
+
]
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
<!--tabs-->
|
|
574
|
+
|
|
575
|
+
##### ❌ Incorrect
|
|
576
|
+
|
|
577
|
+
```ts
|
|
578
|
+
class Foo {
|
|
579
|
+
private C: string; // -> field
|
|
580
|
+
public D: string; // -> field
|
|
581
|
+
protected static E: string; // -> field
|
|
582
|
+
|
|
583
|
+
constructor() {} // -> constructor
|
|
584
|
+
|
|
585
|
+
public static A(): void {} // -> method
|
|
586
|
+
public B(): void {} // -> method
|
|
587
|
+
}
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
##### ✅ Correct
|
|
591
|
+
|
|
592
|
+
```ts
|
|
593
|
+
class Foo {
|
|
594
|
+
public static A(): void {} // -> method
|
|
595
|
+
public B(): void {} // -> method
|
|
596
|
+
|
|
597
|
+
constructor() {} // -> constructor
|
|
598
|
+
|
|
599
|
+
private C: string; // -> field
|
|
600
|
+
public D: string; // -> field
|
|
601
|
+
protected static E: string; // -> field
|
|
602
|
+
}
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
#### Class Expressions
|
|
606
|
+
|
|
607
|
+
This config only specifies an order for classes expressions: methods, then the constructor, then fields.
|
|
608
|
+
It does not apply to class declarations (use `classes` for them).
|
|
609
|
+
Default settings will be used for class declarations and all other syntax constructs other than class expressions.
|
|
610
|
+
|
|
611
|
+
```jsonc
|
|
612
|
+
// .eslintrc.json
|
|
613
|
+
{
|
|
614
|
+
"rules": {
|
|
615
|
+
"@typescript-eslint/member-ordering": [
|
|
616
|
+
"error",
|
|
617
|
+
{ "classExpressions": ["method", "constructor", "field"] }
|
|
618
|
+
]
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
<!--tabs-->
|
|
624
|
+
|
|
625
|
+
##### ❌ Incorrect
|
|
626
|
+
|
|
627
|
+
```ts
|
|
628
|
+
const foo = class {
|
|
629
|
+
private C: string; // -> field
|
|
630
|
+
public D: string; // -> field
|
|
631
|
+
protected static E: string; // -> field
|
|
632
|
+
|
|
633
|
+
constructor() {} // -> constructor
|
|
634
|
+
|
|
635
|
+
public static A(): void {} // -> method
|
|
636
|
+
public B(): void {} // -> method
|
|
637
|
+
};
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
##### ✅ Correct
|
|
641
|
+
|
|
642
|
+
```ts
|
|
643
|
+
const foo = class {
|
|
644
|
+
public static A(): void {} // -> method
|
|
645
|
+
public B(): void {} // -> method
|
|
646
|
+
|
|
647
|
+
constructor() {} // -> constructor
|
|
648
|
+
|
|
649
|
+
private C: string; // -> field
|
|
650
|
+
public D: string; // -> field
|
|
651
|
+
protected static E: string; // -> field
|
|
652
|
+
};
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
### Interfaces
|
|
656
|
+
|
|
657
|
+
This config only specifies an order for interfaces: signatures, then methods, then constructors, then fields.
|
|
658
|
+
It does not apply to type literals (use `typeLiterals` for them).
|
|
659
|
+
Default settings will be used for type literals and all other syntax constructs other than class expressions.
|
|
660
|
+
|
|
661
|
+
:::note
|
|
662
|
+
These member types are the only ones allowed for `interfaces`.
|
|
663
|
+
:::
|
|
664
|
+
|
|
665
|
+
```jsonc
|
|
666
|
+
// .eslintrc.json
|
|
667
|
+
{
|
|
668
|
+
"rules": {
|
|
669
|
+
"@typescript-eslint/member-ordering": [
|
|
670
|
+
"error",
|
|
671
|
+
{ "interfaces": ["signature", "method", "constructor", "field"] }
|
|
672
|
+
]
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
<!--tabs-->
|
|
678
|
+
|
|
679
|
+
#### ❌ Incorrect
|
|
680
|
+
|
|
681
|
+
```ts
|
|
682
|
+
interface Foo {
|
|
683
|
+
B: string; // -> field
|
|
684
|
+
|
|
685
|
+
new (); // -> constructor
|
|
686
|
+
|
|
687
|
+
A(): void; // -> method
|
|
688
|
+
|
|
689
|
+
[Z: string]: any; // -> signature
|
|
690
|
+
}
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
#### ✅ Correct
|
|
694
|
+
|
|
695
|
+
```ts
|
|
696
|
+
interface Foo {
|
|
697
|
+
[Z: string]: any; // -> signature
|
|
698
|
+
|
|
699
|
+
A(): void; // -> method
|
|
700
|
+
|
|
701
|
+
new (); // -> constructor
|
|
702
|
+
|
|
703
|
+
B: string; // -> field
|
|
704
|
+
}
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
### Type Literals
|
|
708
|
+
|
|
709
|
+
This config only specifies an order for type literals: signatures, then methods, then constructors, then fields.
|
|
710
|
+
It does not apply to interfaces (use `interfaces` for them).
|
|
711
|
+
Default settings will be used for interfaces and all other syntax constructs other than class expressions.
|
|
712
|
+
|
|
713
|
+
:::note
|
|
714
|
+
These member types are the only ones allowed for `typeLiterals`.
|
|
715
|
+
:::
|
|
716
|
+
|
|
717
|
+
```jsonc
|
|
718
|
+
// .eslintrc.json
|
|
719
|
+
{
|
|
720
|
+
"rules": {
|
|
721
|
+
"@typescript-eslint/member-ordering": [
|
|
722
|
+
"error",
|
|
723
|
+
{ "typeLiterals": ["signature", "method", "constructor", "field"] }
|
|
724
|
+
]
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
<!--tabs-->
|
|
730
|
+
|
|
731
|
+
#### ❌ Incorrect
|
|
732
|
+
|
|
733
|
+
```ts
|
|
734
|
+
type Foo = {
|
|
735
|
+
B: string; // -> field
|
|
736
|
+
|
|
737
|
+
A(): void; // -> method
|
|
738
|
+
|
|
739
|
+
new (); // -> constructor
|
|
740
|
+
|
|
741
|
+
[Z: string]: any; // -> signature
|
|
742
|
+
};
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
#### ✅ Correct
|
|
746
|
+
|
|
747
|
+
```ts
|
|
748
|
+
type Foo = {
|
|
749
|
+
[Z: string]: any; // -> signature
|
|
750
|
+
|
|
751
|
+
A(): void; // -> method
|
|
752
|
+
|
|
753
|
+
new (); // -> constructor
|
|
754
|
+
|
|
755
|
+
B: string; // -> field
|
|
756
|
+
};
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
### Sorting Options
|
|
760
|
+
|
|
761
|
+
#### Sorting Alphabetically Within Member Groups
|
|
762
|
+
|
|
763
|
+
This config specifies that within each `memberTypes` group, members are in an alphabetic case-sensitive order.
|
|
764
|
+
You can copy and paste the default order from [Default Configuration](#default-configuration).
|
|
765
|
+
|
|
766
|
+
```jsonc
|
|
767
|
+
// .eslintrc.json
|
|
768
|
+
{
|
|
769
|
+
"rules": {
|
|
770
|
+
"@typescript-eslint/member-ordering": [
|
|
771
|
+
"error",
|
|
772
|
+
{
|
|
773
|
+
"default": {
|
|
774
|
+
"memberTypes": [
|
|
775
|
+
/* <Default Order> */
|
|
776
|
+
],
|
|
777
|
+
"order": "alphabetically"
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
]
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
<!--tabs-->
|
|
786
|
+
|
|
787
|
+
##### ❌ Incorrect
|
|
788
|
+
|
|
789
|
+
```ts
|
|
790
|
+
interface Foo {
|
|
791
|
+
a: x;
|
|
792
|
+
B: x;
|
|
793
|
+
c: x;
|
|
794
|
+
|
|
795
|
+
B(): void;
|
|
796
|
+
c(): void;
|
|
797
|
+
a(): void;
|
|
798
|
+
}
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
##### ✅ Correct
|
|
802
|
+
|
|
803
|
+
```ts
|
|
804
|
+
interface Foo {
|
|
805
|
+
B: x;
|
|
806
|
+
a: x;
|
|
807
|
+
c: x;
|
|
808
|
+
|
|
809
|
+
B(): void;
|
|
810
|
+
a(): void;
|
|
811
|
+
c(): void;
|
|
812
|
+
}
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
#### Sorting Alphabetically Case Insensitive Within Member Groups
|
|
816
|
+
|
|
817
|
+
This config specifies that within each `memberTypes` group, members are in an alphabetic case-sensitive order.
|
|
818
|
+
You can copy and paste the default order from [Default Configuration](#default-configuration).
|
|
819
|
+
|
|
820
|
+
```jsonc
|
|
821
|
+
// .eslintrc.json
|
|
822
|
+
{
|
|
823
|
+
"rules": {
|
|
824
|
+
"@typescript-eslint/member-ordering": [
|
|
825
|
+
"error",
|
|
826
|
+
{
|
|
827
|
+
"default": {
|
|
828
|
+
"memberTypes": [
|
|
829
|
+
/* <Default Order> */
|
|
830
|
+
],
|
|
831
|
+
"order": "alphabetically-case-insensitive"
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
]
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
<!--tabs-->
|
|
840
|
+
|
|
841
|
+
##### ❌ Incorrect
|
|
842
|
+
|
|
843
|
+
```ts
|
|
844
|
+
interface Foo {
|
|
845
|
+
B: x;
|
|
846
|
+
a: x;
|
|
847
|
+
c: x;
|
|
848
|
+
|
|
849
|
+
B(): void;
|
|
850
|
+
c(): void;
|
|
851
|
+
a(): void;
|
|
852
|
+
}
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
##### ✅ Correct
|
|
856
|
+
|
|
857
|
+
```ts
|
|
858
|
+
interface Foo {
|
|
859
|
+
a: x;
|
|
860
|
+
B: x;
|
|
861
|
+
c: x;
|
|
862
|
+
|
|
863
|
+
a(): void;
|
|
864
|
+
B(): void;
|
|
865
|
+
c(): void;
|
|
866
|
+
}
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
#### Sorting Alphabetically Ignoring Member Groups
|
|
870
|
+
|
|
871
|
+
This config specifies that members are all sorted in an alphabetic case-sensitive order.
|
|
872
|
+
It ignores any member group types completely by specifying `"never"` for `memberTypes`.
|
|
873
|
+
|
|
874
|
+
```jsonc
|
|
875
|
+
// .eslintrc.json
|
|
876
|
+
{
|
|
877
|
+
"rules": {
|
|
878
|
+
"@typescript-eslint/member-ordering": [
|
|
879
|
+
"error",
|
|
880
|
+
{ "default": { "memberTypes": "never", "order": "alphabetically" } }
|
|
881
|
+
]
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
```
|
|
885
|
+
|
|
886
|
+
<!--tabs-->
|
|
887
|
+
|
|
888
|
+
##### ❌ Incorrect
|
|
889
|
+
|
|
890
|
+
```ts
|
|
891
|
+
interface Foo {
|
|
892
|
+
static c = 0;
|
|
893
|
+
b(): void;
|
|
894
|
+
a: boolean;
|
|
895
|
+
|
|
896
|
+
[a: string]: number; // Order doesn't matter (no sortable identifier)
|
|
897
|
+
new (): Bar; // Order doesn't matter (no sortable identifier)
|
|
898
|
+
(): Baz; // Order doesn't matter (no sortable identifier)
|
|
899
|
+
}
|
|
900
|
+
```
|
|
901
|
+
|
|
902
|
+
##### ✅ Correct
|
|
903
|
+
|
|
904
|
+
```ts
|
|
905
|
+
interface Foo {
|
|
906
|
+
a: boolean;
|
|
907
|
+
b(): void;
|
|
908
|
+
static c = 0;
|
|
909
|
+
|
|
910
|
+
[a: string]: number; // Order doesn't matter (no sortable identifier)
|
|
911
|
+
new (): Bar; // Order doesn't matter (no sortable identifier)
|
|
912
|
+
(): Baz; // Order doesn't matter (no sortable identifier)
|
|
913
|
+
}
|
|
914
|
+
```
|
|
915
|
+
|
|
916
|
+
#### Sorting Optional Members First or Last
|
|
917
|
+
|
|
918
|
+
The `optionalityOrder` option may be enabled to place all optional members in a group at the beginning or end of that group.
|
|
919
|
+
|
|
920
|
+
This config places all optional members before all required members:
|
|
921
|
+
|
|
922
|
+
```jsonc
|
|
923
|
+
// .eslintrc.json
|
|
924
|
+
{
|
|
925
|
+
"rules": {
|
|
926
|
+
"@typescript-eslint/member-ordering": [
|
|
927
|
+
"error",
|
|
928
|
+
{
|
|
929
|
+
"default": {
|
|
930
|
+
"optionalityOrder": "optional-first",
|
|
931
|
+
"order": "alphabetically"
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
]
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
```
|
|
938
|
+
|
|
939
|
+
<!--tabs-->
|
|
940
|
+
|
|
941
|
+
##### ❌ Incorrect
|
|
942
|
+
|
|
943
|
+
```ts
|
|
944
|
+
interface Foo {
|
|
945
|
+
a: boolean;
|
|
946
|
+
b?: number;
|
|
947
|
+
c: string;
|
|
948
|
+
}
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
##### ✅ Correct
|
|
952
|
+
|
|
953
|
+
```ts
|
|
954
|
+
interface Foo {
|
|
955
|
+
b?: number;
|
|
956
|
+
a: boolean;
|
|
957
|
+
c: string;
|
|
958
|
+
}
|
|
959
|
+
```
|
|
960
|
+
|
|
961
|
+
<!--/tabs-->
|
|
962
|
+
|
|
963
|
+
This config places all required members before all optional members:
|
|
964
|
+
|
|
965
|
+
```jsonc
|
|
966
|
+
// .eslintrc.json
|
|
967
|
+
{
|
|
968
|
+
"rules": {
|
|
969
|
+
"@typescript-eslint/member-ordering": [
|
|
970
|
+
"error",
|
|
971
|
+
{
|
|
972
|
+
"default": {
|
|
973
|
+
"optionalityOrder": "required-first",
|
|
974
|
+
"order": "alphabetically"
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
]
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
```
|
|
981
|
+
|
|
982
|
+
<!--tabs-->
|
|
983
|
+
|
|
984
|
+
##### ❌ Incorrect
|
|
985
|
+
|
|
986
|
+
```ts
|
|
987
|
+
interface Foo {
|
|
988
|
+
a: boolean;
|
|
989
|
+
b?: number;
|
|
990
|
+
c: string;
|
|
991
|
+
}
|
|
992
|
+
```
|
|
993
|
+
|
|
994
|
+
##### ✅ Correct
|
|
995
|
+
|
|
996
|
+
```ts
|
|
997
|
+
interface Foo {
|
|
998
|
+
a: boolean;
|
|
999
|
+
c: string;
|
|
1000
|
+
b?: number;
|
|
1001
|
+
}
|
|
1002
|
+
```
|
|
1003
|
+
|
|
1004
|
+
<!--/tabs-->
|
|
1005
|
+
|
|
1006
|
+
## All Supported Options
|
|
1007
|
+
|
|
1008
|
+
### Member Types (Granular Form)
|
|
1009
|
+
|
|
1010
|
+
There are multiple ways to specify the member types.
|
|
1011
|
+
The most explicit and granular form is the following:
|
|
1012
|
+
|
|
1013
|
+
```jsonc
|
|
1014
|
+
[
|
|
1015
|
+
// Index signature
|
|
1016
|
+
"signature",
|
|
1017
|
+
"readonly-signature",
|
|
1018
|
+
|
|
1019
|
+
// Fields
|
|
1020
|
+
"public-static-field",
|
|
1021
|
+
"public-static-readonly-field",
|
|
1022
|
+
"protected-static-field",
|
|
1023
|
+
"protected-static-readonly-field",
|
|
1024
|
+
"private-static-field",
|
|
1025
|
+
"private-static-readonly-field",
|
|
1026
|
+
"#private-static-field",
|
|
1027
|
+
"#private-static-readonly-field",
|
|
1028
|
+
|
|
1029
|
+
"public-decorated-field",
|
|
1030
|
+
"public-decorated-readonly-field",
|
|
1031
|
+
"protected-decorated-field",
|
|
1032
|
+
"protected-decorated-readonly-field",
|
|
1033
|
+
"private-decorated-field",
|
|
1034
|
+
"private-decorated-readonly-field",
|
|
1035
|
+
|
|
1036
|
+
"public-instance-field",
|
|
1037
|
+
"public-instance-readonly-field",
|
|
1038
|
+
"protected-instance-field",
|
|
1039
|
+
"protected-instance-readonly-field",
|
|
1040
|
+
"private-instance-field",
|
|
1041
|
+
"private-instance-readonly-field",
|
|
1042
|
+
"#private-instance-field",
|
|
1043
|
+
"#private-instance-readonly-field",
|
|
1044
|
+
|
|
1045
|
+
"public-abstract-field",
|
|
1046
|
+
"public-abstract-readonly-field",
|
|
1047
|
+
"protected-abstract-field",
|
|
1048
|
+
"protected-abstract-readonly-field",
|
|
1049
|
+
|
|
1050
|
+
"public-field",
|
|
1051
|
+
"public-readonly-field",
|
|
1052
|
+
"protected-field",
|
|
1053
|
+
"protected-readonly-field",
|
|
1054
|
+
"private-field",
|
|
1055
|
+
"private-readonly-field"
|
|
1056
|
+
"#private-field",
|
|
1057
|
+
"#private-readonly-field"
|
|
1058
|
+
|
|
1059
|
+
"static-field",
|
|
1060
|
+
"static-readonly-field",
|
|
1061
|
+
"instance-field",
|
|
1062
|
+
"instance-readonly-field"
|
|
1063
|
+
"abstract-field",
|
|
1064
|
+
"abstract-readonly-field",
|
|
1065
|
+
|
|
1066
|
+
"decorated-field",
|
|
1067
|
+
"decorated-readonly-field",
|
|
1068
|
+
|
|
1069
|
+
"field",
|
|
1070
|
+
"readonly-field",
|
|
1071
|
+
|
|
1072
|
+
// Static initialization
|
|
1073
|
+
"static-initialization",
|
|
1074
|
+
|
|
1075
|
+
// Constructors
|
|
1076
|
+
"public-constructor",
|
|
1077
|
+
"protected-constructor",
|
|
1078
|
+
"private-constructor",
|
|
1079
|
+
|
|
1080
|
+
// Getters
|
|
1081
|
+
"public-static-get",
|
|
1082
|
+
"protected-static-get",
|
|
1083
|
+
"private-static-get",
|
|
1084
|
+
"#private-static-get",
|
|
1085
|
+
|
|
1086
|
+
"public-decorated-get",
|
|
1087
|
+
"protected-decorated-get",
|
|
1088
|
+
"private-decorated-get",
|
|
1089
|
+
|
|
1090
|
+
"public-instance-get",
|
|
1091
|
+
"protected-instance-get",
|
|
1092
|
+
"private-instance-get",
|
|
1093
|
+
"#private-instance-get",
|
|
1094
|
+
|
|
1095
|
+
"public-abstract-get",
|
|
1096
|
+
"protected-abstract-get",
|
|
1097
|
+
|
|
1098
|
+
"public-get",
|
|
1099
|
+
"protected-get",
|
|
1100
|
+
"private-get",
|
|
1101
|
+
"#private-get",
|
|
1102
|
+
|
|
1103
|
+
"static-get",
|
|
1104
|
+
"instance-get",
|
|
1105
|
+
"abstract-get",
|
|
1106
|
+
|
|
1107
|
+
"decorated-get",
|
|
1108
|
+
|
|
1109
|
+
"get",
|
|
1110
|
+
|
|
1111
|
+
// Setters
|
|
1112
|
+
"public-static-set",
|
|
1113
|
+
"protected-static-set",
|
|
1114
|
+
"private-static-set",
|
|
1115
|
+
"#private-static-set",
|
|
1116
|
+
|
|
1117
|
+
"public-decorated-set",
|
|
1118
|
+
"protected-decorated-set",
|
|
1119
|
+
"private-decorated-set",
|
|
1120
|
+
|
|
1121
|
+
"public-instance-set",
|
|
1122
|
+
"protected-instance-set",
|
|
1123
|
+
"private-instance-set",
|
|
1124
|
+
"#private-instance-set",
|
|
1125
|
+
|
|
1126
|
+
"public-abstract-set",
|
|
1127
|
+
"protected-abstract-set",
|
|
1128
|
+
|
|
1129
|
+
"public-set",
|
|
1130
|
+
"protected-set",
|
|
1131
|
+
"private-set",
|
|
1132
|
+
|
|
1133
|
+
"static-set",
|
|
1134
|
+
"instance-set",
|
|
1135
|
+
"abstract-set",
|
|
1136
|
+
|
|
1137
|
+
"decorated-set",
|
|
1138
|
+
|
|
1139
|
+
"set",
|
|
1140
|
+
|
|
1141
|
+
// Methods
|
|
1142
|
+
"public-static-method",
|
|
1143
|
+
"protected-static-method",
|
|
1144
|
+
"private-static-method",
|
|
1145
|
+
"#private-static-method",
|
|
1146
|
+
"public-decorated-method",
|
|
1147
|
+
"protected-decorated-method",
|
|
1148
|
+
"private-decorated-method",
|
|
1149
|
+
"public-instance-method",
|
|
1150
|
+
"protected-instance-method",
|
|
1151
|
+
"private-instance-method",
|
|
1152
|
+
"#private-instance-method",
|
|
1153
|
+
"public-abstract-method",
|
|
1154
|
+
"protected-abstract-method"
|
|
1155
|
+
]
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
:::note
|
|
1159
|
+
If you only specify some of the possible types, the non-specified ones can have any particular order.
|
|
1160
|
+
This means that they can be placed before, within or after the specified types and the linter won't complain about it.
|
|
1161
|
+
:::
|
|
1162
|
+
|
|
1163
|
+
### Member Group Types (With Accessibility, Ignoring Scope)
|
|
1164
|
+
|
|
1165
|
+
It is also possible to group member types by their accessibility (`static`, `instance`, `abstract`), ignoring their scope.
|
|
1166
|
+
|
|
1167
|
+
```jsonc
|
|
1168
|
+
[
|
|
1169
|
+
// Index signature
|
|
1170
|
+
// No accessibility for index signature.
|
|
1171
|
+
|
|
1172
|
+
// Fields
|
|
1173
|
+
"public-field", // = ["public-static-field", "public-instance-field"]
|
|
1174
|
+
"protected-field", // = ["protected-static-field", "protected-instance-field"]
|
|
1175
|
+
"private-field", // = ["private-static-field", "private-instance-field"]
|
|
1176
|
+
|
|
1177
|
+
// Static initialization
|
|
1178
|
+
// No accessibility for static initialization.
|
|
1179
|
+
|
|
1180
|
+
// Constructors
|
|
1181
|
+
// Only the accessibility of constructors is configurable. See below.
|
|
1182
|
+
|
|
1183
|
+
// Getters
|
|
1184
|
+
"public-get", // = ["public-static-get", "public-instance-get"]
|
|
1185
|
+
"protected-get", // = ["protected-static-get", "protected-instance-get"]
|
|
1186
|
+
"private-get", // = ["private-static-get", "private-instance-get"]
|
|
1187
|
+
|
|
1188
|
+
// Setters
|
|
1189
|
+
"public-set", // = ["public-static-set", "public-instance-set"]
|
|
1190
|
+
"protected-set", // = ["protected-static-set", "protected-instance-set"]
|
|
1191
|
+
"private-set", // = ["private-static-set", "private-instance-set"]
|
|
1192
|
+
|
|
1193
|
+
// Methods
|
|
1194
|
+
"public-method", // = ["public-static-method", "public-instance-method"]
|
|
1195
|
+
"protected-method", // = ["protected-static-method", "protected-instance-method"]
|
|
1196
|
+
"private-method" // = ["private-static-method", "private-instance-method"]
|
|
1197
|
+
]
|
|
1198
|
+
```
|
|
1199
|
+
|
|
1200
|
+
### Member Group Types (With Accessibility and a Decorator)
|
|
1201
|
+
|
|
1202
|
+
It is also possible to group methods or fields with a decorator separately, optionally specifying
|
|
1203
|
+
their accessibility.
|
|
1204
|
+
|
|
1205
|
+
```jsonc
|
|
1206
|
+
[
|
|
1207
|
+
// Index signature
|
|
1208
|
+
// No decorators for index signature.
|
|
1209
|
+
|
|
1210
|
+
// Fields
|
|
1211
|
+
"public-decorated-field",
|
|
1212
|
+
"protected-decorated-field",
|
|
1213
|
+
"private-decorated-field",
|
|
1214
|
+
|
|
1215
|
+
"decorated-field", // = ["public-decorated-field", "protected-decorated-field", "private-decorated-field"]
|
|
1216
|
+
|
|
1217
|
+
// Static initialization
|
|
1218
|
+
// No decorators for static initialization.
|
|
1219
|
+
|
|
1220
|
+
// Constructors
|
|
1221
|
+
// There are no decorators for constructors.
|
|
1222
|
+
|
|
1223
|
+
// Getters
|
|
1224
|
+
"public-decorated-get",
|
|
1225
|
+
"protected-decorated-get",
|
|
1226
|
+
"private-decorated-get",
|
|
1227
|
+
|
|
1228
|
+
"decorated-get", // = ["public-decorated-get", "protected-decorated-get", "private-decorated-get"]
|
|
1229
|
+
|
|
1230
|
+
// Setters
|
|
1231
|
+
"public-decorated-set",
|
|
1232
|
+
"protected-decorated-set",
|
|
1233
|
+
"private-decorated-set",
|
|
1234
|
+
|
|
1235
|
+
"decorated-set", // = ["public-decorated-set", "protected-decorated-set", "private-decorated-set"]
|
|
1236
|
+
|
|
1237
|
+
// Methods
|
|
1238
|
+
"public-decorated-method",
|
|
1239
|
+
"protected-decorated-method",
|
|
1240
|
+
"private-decorated-method",
|
|
1241
|
+
|
|
1242
|
+
"decorated-method" // = ["public-decorated-method", "protected-decorated-method", "private-decorated-method"]
|
|
1243
|
+
]
|
|
1244
|
+
```
|
|
1245
|
+
|
|
1246
|
+
### Member Group Types (With Scope, Ignoring Accessibility)
|
|
1247
|
+
|
|
1248
|
+
Another option is to group the member types by their scope (`public`, `protected`, `private`), ignoring their accessibility.
|
|
1249
|
+
|
|
1250
|
+
```jsonc
|
|
1251
|
+
[
|
|
1252
|
+
// Index signature
|
|
1253
|
+
// No scope for index signature.
|
|
1254
|
+
|
|
1255
|
+
// Fields
|
|
1256
|
+
"static-field", // = ["public-static-field", "protected-static-field", "private-static-field"]
|
|
1257
|
+
"instance-field", // = ["public-instance-field", "protected-instance-field", "private-instance-field"]
|
|
1258
|
+
"abstract-field", // = ["public-abstract-field", "protected-abstract-field"]
|
|
1259
|
+
|
|
1260
|
+
// Static initialization
|
|
1261
|
+
// No scope for static initialization.
|
|
1262
|
+
|
|
1263
|
+
// Constructors
|
|
1264
|
+
"constructor", // = ["public-constructor", "protected-constructor", "private-constructor"]
|
|
1265
|
+
|
|
1266
|
+
// Getters
|
|
1267
|
+
"static-get", // = ["public-static-get", "protected-static-get", "private-static-get"]
|
|
1268
|
+
"instance-get", // = ["public-instance-get", "protected-instance-get", "private-instance-get"]
|
|
1269
|
+
"abstract-get", // = ["public-abstract-get", "protected-abstract-get"]
|
|
1270
|
+
|
|
1271
|
+
// Setters
|
|
1272
|
+
"static-set", // = ["public-static-set", "protected-static-set", "private-static-set"]
|
|
1273
|
+
"instance-set", // = ["public-instance-set", "protected-instance-set", "private-instance-set"]
|
|
1274
|
+
"abstract-set", // = ["public-abstract-set", "protected-abstract-set"]
|
|
1275
|
+
|
|
1276
|
+
// Methods
|
|
1277
|
+
"static-method", // = ["public-static-method", "protected-static-method", "private-static-method"]
|
|
1278
|
+
"instance-method", // = ["public-instance-method", "protected-instance-method", "private-instance-method"]
|
|
1279
|
+
"abstract-method" // = ["public-abstract-method", "protected-abstract-method"]
|
|
1280
|
+
]
|
|
1281
|
+
```
|
|
1282
|
+
|
|
1283
|
+
### Member Group Types (With Scope and Accessibility)
|
|
1284
|
+
|
|
1285
|
+
The third grouping option is to ignore both scope and accessibility.
|
|
1286
|
+
|
|
1287
|
+
```jsonc
|
|
1288
|
+
[
|
|
1289
|
+
// Index signature
|
|
1290
|
+
// No grouping for index signature.
|
|
1291
|
+
|
|
1292
|
+
// Fields
|
|
1293
|
+
"field", // = ["public-static-field", "protected-static-field", "private-static-field", "public-instance-field", "protected-instance-field", "private-instance-field",
|
|
1294
|
+
// "public-abstract-field", "protected-abstract-field"]
|
|
1295
|
+
|
|
1296
|
+
// Static initialization
|
|
1297
|
+
// No grouping for static initialization.
|
|
1298
|
+
|
|
1299
|
+
// Constructors
|
|
1300
|
+
// Only the accessibility of constructors is configurable.
|
|
1301
|
+
|
|
1302
|
+
// Getters
|
|
1303
|
+
"get", // = ["public-static-get", "protected-static-get", "private-static-get", "public-instance-get", "protected-instance-get", "private-instance-get",
|
|
1304
|
+
// "public-abstract-get", "protected-abstract-get"]
|
|
1305
|
+
|
|
1306
|
+
// Setters
|
|
1307
|
+
"set", // = ["public-static-set", "protected-static-set", "private-static-set", "public-instance-set", "protected-instance-set", "private-instance-set",
|
|
1308
|
+
// "public-abstract-set", "protected-abstract-set"]
|
|
1309
|
+
|
|
1310
|
+
// Methods
|
|
1311
|
+
"method" // = ["public-static-method", "protected-static-method", "private-static-method", "public-instance-method", "protected-instance-method", "private-instance-method",
|
|
1312
|
+
// "public-abstract-method", "protected-abstract-method"]
|
|
1313
|
+
]
|
|
1314
|
+
```
|
|
1315
|
+
|
|
1316
|
+
### Member Group Types (Readonly Fields)
|
|
1317
|
+
|
|
1318
|
+
It is possible to group fields by their `readonly` modifiers.
|
|
1319
|
+
|
|
1320
|
+
```jsonc
|
|
1321
|
+
[
|
|
1322
|
+
// Index signature
|
|
1323
|
+
"readonly-signature",
|
|
1324
|
+
"signature",
|
|
1325
|
+
|
|
1326
|
+
// Fields
|
|
1327
|
+
"readonly-field", // = ["public-static-readonly-field", "protected-static-readonly-field", "private-static-readonly-field", "public-instance-readonly-field", "protected-instance-readonly-field", "private-instance-readonly-field", "public-abstract-readonly-field", "protected-abstract-readonly-field"]
|
|
1328
|
+
"field" // = ["public-static-field", "protected-static-field", "private-static-field", "public-instance-field", "protected-instance-field", "private-instance-field", "public-abstract-field", "protected-abstract-field"]
|
|
1329
|
+
]
|
|
1330
|
+
```
|
|
1331
|
+
|
|
1332
|
+
### Grouping Different Member Types at the Same Rank
|
|
1333
|
+
|
|
1334
|
+
It is also possible to group different member types at the same rank.
|
|
1335
|
+
|
|
1336
|
+
```jsonc
|
|
1337
|
+
[
|
|
1338
|
+
// Index signature
|
|
1339
|
+
"signature",
|
|
1340
|
+
|
|
1341
|
+
// Fields
|
|
1342
|
+
"field",
|
|
1343
|
+
|
|
1344
|
+
// Static initialization
|
|
1345
|
+
"static-initialization",
|
|
1346
|
+
|
|
1347
|
+
// Constructors
|
|
1348
|
+
"constructor",
|
|
1349
|
+
|
|
1350
|
+
// Getters and Setters at the same rank
|
|
1351
|
+
["get", "set"],
|
|
1352
|
+
|
|
1353
|
+
// Methods
|
|
1354
|
+
"method"
|
|
1355
|
+
]
|
|
1356
|
+
```
|
|
1357
|
+
|
|
1358
|
+
## When Not To Use It
|
|
1359
|
+
|
|
1360
|
+
If you don't care about the general order of your members, then you will not need this rule.
|