@dhzh/eslint-plugin-better-tailwindcss 0.0.0-stage → 4.9.0-patch
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/LICENSE +21 -0
- package/README.md +247 -2
- package/lib/api/defaults.d.ts +103 -0
- package/lib/api/defaults.d.ts.map +1 -0
- package/lib/api/defaults.js +34 -0
- package/lib/api/defaults.js.map +1 -0
- package/lib/api/types.d.ts +9 -0
- package/lib/api/types.d.ts.map +1 -0
- package/lib/api/types.js +5 -0
- package/lib/api/types.js.map +1 -0
- package/lib/async-utils/cache.d.ts +30 -0
- package/lib/async-utils/cache.d.ts.map +1 -0
- package/lib/async-utils/cache.js +116 -0
- package/lib/async-utils/cache.js.map +1 -0
- package/lib/async-utils/escape.d.ts +2 -0
- package/lib/async-utils/escape.d.ts.map +1 -0
- package/lib/async-utils/escape.js +5 -0
- package/lib/async-utils/escape.js.map +1 -0
- package/lib/async-utils/fs.d.ts +3 -0
- package/lib/async-utils/fs.d.ts.map +1 -0
- package/lib/async-utils/fs.js +28 -0
- package/lib/async-utils/fs.js.map +1 -0
- package/lib/async-utils/module.d.ts +3 -0
- package/lib/async-utils/module.d.ts.map +1 -0
- package/lib/async-utils/module.js +7 -0
- package/lib/async-utils/module.js.map +1 -0
- package/lib/async-utils/operations.d.ts +23 -0
- package/lib/async-utils/operations.d.ts.map +1 -0
- package/lib/async-utils/operations.js +2 -0
- package/lib/async-utils/operations.js.map +1 -0
- package/lib/async-utils/order.d.ts +4 -0
- package/lib/async-utils/order.d.ts.map +1 -0
- package/lib/async-utils/order.js +5 -0
- package/lib/async-utils/order.js.map +1 -0
- package/lib/async-utils/path.d.ts +2 -0
- package/lib/async-utils/path.d.ts.map +1 -0
- package/lib/async-utils/path.js +7 -0
- package/lib/async-utils/path.js.map +1 -0
- package/lib/async-utils/platform.d.ts +2 -0
- package/lib/async-utils/platform.d.ts.map +1 -0
- package/lib/async-utils/platform.js +4 -0
- package/lib/async-utils/platform.js.map +1 -0
- package/lib/async-utils/regex.d.ts +3 -0
- package/lib/async-utils/regex.d.ts.map +1 -0
- package/lib/async-utils/regex.js +32 -0
- package/lib/async-utils/regex.js.map +1 -0
- package/lib/async-utils/resolvers.d.ts +7 -0
- package/lib/async-utils/resolvers.d.ts.map +1 -0
- package/lib/async-utils/resolvers.js +64 -0
- package/lib/async-utils/resolvers.js.map +1 -0
- package/lib/async-utils/segment.d.ts +2 -0
- package/lib/async-utils/segment.d.ts.map +1 -0
- package/lib/async-utils/segment.js +82 -0
- package/lib/async-utils/segment.js.map +1 -0
- package/lib/async-utils/worker.d.ts +3 -0
- package/lib/async-utils/worker.d.ts.map +1 -0
- package/lib/async-utils/worker.js +17 -0
- package/lib/async-utils/worker.js.map +1 -0
- package/lib/configs/config.d.ts +3521 -0
- package/lib/configs/config.d.ts.map +1 -0
- package/lib/configs/config.js +98 -0
- package/lib/configs/config.js.map +1 -0
- package/lib/options/callees/cc.d.ts +30 -0
- package/lib/options/callees/cc.d.ts.map +1 -0
- package/lib/options/callees/cc.js +25 -0
- package/lib/options/callees/cc.js.map +1 -0
- package/lib/options/callees/clb.d.ts +35 -0
- package/lib/options/callees/clb.d.ts.map +1 -0
- package/lib/options/callees/clb.js +39 -0
- package/lib/options/callees/clb.js.map +1 -0
- package/lib/options/callees/clsx.d.ts +30 -0
- package/lib/options/callees/clsx.d.ts.map +1 -0
- package/lib/options/callees/clsx.js +25 -0
- package/lib/options/callees/clsx.js.map +1 -0
- package/lib/options/callees/cn.d.ts +30 -0
- package/lib/options/callees/cn.d.ts.map +1 -0
- package/lib/options/callees/cn.js +25 -0
- package/lib/options/callees/cn.js.map +1 -0
- package/lib/options/callees/cnb.d.ts +30 -0
- package/lib/options/callees/cnb.d.ts.map +1 -0
- package/lib/options/callees/cnb.js +25 -0
- package/lib/options/callees/cnb.js.map +1 -0
- package/lib/options/callees/ctl.d.ts +17 -0
- package/lib/options/callees/ctl.d.ts.map +1 -0
- package/lib/options/callees/ctl.js +15 -0
- package/lib/options/callees/ctl.js.map +1 -0
- package/lib/options/callees/cva.d.ts +40 -0
- package/lib/options/callees/cva.d.ts.map +1 -0
- package/lib/options/callees/cva.js +37 -0
- package/lib/options/callees/cva.js.map +1 -0
- package/lib/options/callees/cx.d.ts +30 -0
- package/lib/options/callees/cx.d.ts.map +1 -0
- package/lib/options/callees/cx.js +25 -0
- package/lib/options/callees/cx.js.map +1 -0
- package/lib/options/callees/dcnb.d.ts +30 -0
- package/lib/options/callees/dcnb.d.ts.map +1 -0
- package/lib/options/callees/dcnb.js +25 -0
- package/lib/options/callees/dcnb.js.map +1 -0
- package/lib/options/callees/objstr.d.ts +24 -0
- package/lib/options/callees/objstr.d.ts.map +1 -0
- package/lib/options/callees/objstr.js +24 -0
- package/lib/options/callees/objstr.js.map +1 -0
- package/lib/options/callees/tv.d.ts +64 -0
- package/lib/options/callees/tv.d.ts.map +1 -0
- package/lib/options/callees/tv.js +70 -0
- package/lib/options/callees/tv.js.map +1 -0
- package/lib/options/callees/twJoin.d.ts +17 -0
- package/lib/options/callees/twJoin.d.ts.map +1 -0
- package/lib/options/callees/twJoin.js +15 -0
- package/lib/options/callees/twJoin.js.map +1 -0
- package/lib/options/callees/twMerge.d.ts +17 -0
- package/lib/options/callees/twMerge.d.ts.map +1 -0
- package/lib/options/callees/twMerge.js +15 -0
- package/lib/options/callees/twMerge.js.map +1 -0
- package/lib/options/default-options.d.ts +114 -0
- package/lib/options/default-options.d.ts.map +1 -0
- package/lib/options/default-options.js +176 -0
- package/lib/options/default-options.js.map +1 -0
- package/lib/options/descriptions.d.ts +657 -0
- package/lib/options/descriptions.d.ts.map +1 -0
- package/lib/options/descriptions.js +22 -0
- package/lib/options/descriptions.js.map +1 -0
- package/lib/options/migrate.d.ts +16 -0
- package/lib/options/migrate.d.ts.map +1 -0
- package/lib/options/migrate.js +132 -0
- package/lib/options/migrate.js.map +1 -0
- package/lib/options/schemas/attributes.d.ts +100 -0
- package/lib/options/schemas/attributes.d.ts.map +1 -0
- package/lib/options/schemas/attributes.js +19 -0
- package/lib/options/schemas/attributes.js.map +1 -0
- package/lib/options/schemas/callees.d.ts +101 -0
- package/lib/options/schemas/callees.d.ts.map +1 -0
- package/lib/options/schemas/callees.js +19 -0
- package/lib/options/schemas/callees.js.map +1 -0
- package/lib/options/schemas/common.d.ts +30 -0
- package/lib/options/schemas/common.d.ts.map +1 -0
- package/lib/options/schemas/common.js +30 -0
- package/lib/options/schemas/common.js.map +1 -0
- package/lib/options/schemas/matchers.d.ts +13 -0
- package/lib/options/schemas/matchers.d.ts.map +1 -0
- package/lib/options/schemas/matchers.js +14 -0
- package/lib/options/schemas/matchers.js.map +1 -0
- package/lib/options/schemas/selectors.d.ts +1289 -0
- package/lib/options/schemas/selectors.d.ts.map +1 -0
- package/lib/options/schemas/selectors.js +100 -0
- package/lib/options/schemas/selectors.js.map +1 -0
- package/lib/options/schemas/tags.d.ts +101 -0
- package/lib/options/schemas/tags.d.ts.map +1 -0
- package/lib/options/schemas/tags.js +19 -0
- package/lib/options/schemas/tags.js.map +1 -0
- package/lib/options/schemas/variables.d.ts +100 -0
- package/lib/options/schemas/variables.d.ts.map +1 -0
- package/lib/options/schemas/variables.js +19 -0
- package/lib/options/schemas/variables.js.map +1 -0
- package/lib/options/tags/twc.d.ts +36 -0
- package/lib/options/tags/twc.d.ts.map +1 -0
- package/lib/options/tags/twc.js +26 -0
- package/lib/options/tags/twc.js.map +1 -0
- package/lib/options/tags/twx.d.ts +36 -0
- package/lib/options/tags/twx.d.ts.map +1 -0
- package/lib/options/tags/twx.js +26 -0
- package/lib/options/tags/twx.js.map +1 -0
- package/lib/parsers/angular.d.ts +11 -0
- package/lib/parsers/angular.d.ts.map +1 -0
- package/lib/parsers/angular.js +736 -0
- package/lib/parsers/angular.js.map +1 -0
- package/lib/parsers/css.d.ts +5 -0
- package/lib/parsers/css.d.ts.map +1 -0
- package/lib/parsers/css.js +100 -0
- package/lib/parsers/css.js.map +1 -0
- package/lib/parsers/es.d.ts +49 -0
- package/lib/parsers/es.d.ts.map +1 -0
- package/lib/parsers/es.js +924 -0
- package/lib/parsers/es.js.map +1 -0
- package/lib/parsers/html.d.ts +8 -0
- package/lib/parsers/html.d.ts.map +1 -0
- package/lib/parsers/html.js +51 -0
- package/lib/parsers/html.js.map +1 -0
- package/lib/parsers/jsx.d.ts +9 -0
- package/lib/parsers/jsx.d.ts.map +1 -0
- package/lib/parsers/jsx.js +118 -0
- package/lib/parsers/jsx.js.map +1 -0
- package/lib/parsers/svelte.d.ts +11 -0
- package/lib/parsers/svelte.d.ts.map +1 -0
- package/lib/parsers/svelte.js +204 -0
- package/lib/parsers/svelte.js.map +1 -0
- package/lib/parsers/vue.d.ts +9 -0
- package/lib/parsers/vue.d.ts.map +1 -0
- package/lib/parsers/vue.js +155 -0
- package/lib/parsers/vue.js.map +1 -0
- package/lib/rules/enforce-canonical-classes.d.ts +229 -0
- package/lib/rules/enforce-canonical-classes.d.ts.map +1 -0
- package/lib/rules/enforce-canonical-classes.js +84 -0
- package/lib/rules/enforce-canonical-classes.js.map +1 -0
- package/lib/rules/enforce-consistent-class-order.d.ts +229 -0
- package/lib/rules/enforce-consistent-class-order.d.ts.map +1 -0
- package/lib/rules/enforce-consistent-class-order.js +250 -0
- package/lib/rules/enforce-consistent-class-order.js.map +1 -0
- package/lib/rules/enforce-consistent-important-position.d.ts +225 -0
- package/lib/rules/enforce-consistent-important-position.d.ts.map +1 -0
- package/lib/rules/enforce-consistent-important-position.js +68 -0
- package/lib/rules/enforce-consistent-important-position.js.map +1 -0
- package/lib/rules/enforce-consistent-line-wrapping.d.ts +235 -0
- package/lib/rules/enforce-consistent-line-wrapping.d.ts.map +1 -0
- package/lib/rules/enforce-consistent-line-wrapping.js +537 -0
- package/lib/rules/enforce-consistent-line-wrapping.js.map +1 -0
- package/lib/rules/enforce-consistent-variable-syntax.d.ts +225 -0
- package/lib/rules/enforce-consistent-variable-syntax.d.ts.map +1 -0
- package/lib/rules/enforce-consistent-variable-syntax.js +164 -0
- package/lib/rules/enforce-consistent-variable-syntax.js.map +1 -0
- package/lib/rules/enforce-consistent-variant-order.d.ts +225 -0
- package/lib/rules/enforce-consistent-variant-order.d.ts.map +1 -0
- package/lib/rules/enforce-consistent-variant-order.js +77 -0
- package/lib/rules/enforce-consistent-variant-order.js.map +1 -0
- package/lib/rules/enforce-logical-properties.d.ts +227 -0
- package/lib/rules/enforce-logical-properties.d.ts.map +1 -0
- package/lib/rules/enforce-logical-properties.js +142 -0
- package/lib/rules/enforce-logical-properties.js.map +1 -0
- package/lib/rules/enforce-shorthand-classes.d.ts +229 -0
- package/lib/rules/enforce-shorthand-classes.d.ts.map +1 -0
- package/lib/rules/enforce-shorthand-classes.js +217 -0
- package/lib/rules/enforce-shorthand-classes.js.map +1 -0
- package/lib/rules/no-concatenated-classes.d.ts +225 -0
- package/lib/rules/no-concatenated-classes.d.ts.map +1 -0
- package/lib/rules/no-concatenated-classes.js +31 -0
- package/lib/rules/no-concatenated-classes.js.map +1 -0
- package/lib/rules/no-conflicting-classes.d.ts +225 -0
- package/lib/rules/no-conflicting-classes.d.ts.map +1 -0
- package/lib/rules/no-conflicting-classes.js +60 -0
- package/lib/rules/no-conflicting-classes.js.map +1 -0
- package/lib/rules/no-deprecated-classes.d.ts +227 -0
- package/lib/rules/no-deprecated-classes.d.ts.map +1 -0
- package/lib/rules/no-deprecated-classes.js +103 -0
- package/lib/rules/no-deprecated-classes.js.map +1 -0
- package/lib/rules/no-duplicate-classes.d.ts +225 -0
- package/lib/rules/no-duplicate-classes.d.ts.map +1 -0
- package/lib/rules/no-duplicate-classes.js +52 -0
- package/lib/rules/no-duplicate-classes.js.map +1 -0
- package/lib/rules/no-restricted-classes.d.ts +225 -0
- package/lib/rules/no-restricted-classes.d.ts.map +1 -0
- package/lib/rules/no-restricted-classes.js +57 -0
- package/lib/rules/no-restricted-classes.js.map +1 -0
- package/lib/rules/no-unknown-classes.d.ts +225 -0
- package/lib/rules/no-unknown-classes.d.ts.map +1 -0
- package/lib/rules/no-unknown-classes.js +82 -0
- package/lib/rules/no-unknown-classes.js.map +1 -0
- package/lib/rules/no-unnecessary-whitespace.d.ts +225 -0
- package/lib/rules/no-unnecessary-whitespace.d.ts.map +1 -0
- package/lib/rules/no-unnecessary-whitespace.js +141 -0
- package/lib/rules/no-unnecessary-whitespace.js.map +1 -0
- package/lib/tailwindcss/canonical-classes.async.v4.d.ts +3 -0
- package/lib/tailwindcss/canonical-classes.async.v4.d.ts.map +1 -0
- package/lib/tailwindcss/canonical-classes.async.v4.js +54 -0
- package/lib/tailwindcss/canonical-classes.async.v4.js.map +1 -0
- package/lib/tailwindcss/canonical-classes.d.ts +21 -0
- package/lib/tailwindcss/canonical-classes.d.ts.map +1 -0
- package/lib/tailwindcss/canonical-classes.js +16 -0
- package/lib/tailwindcss/canonical-classes.js.map +1 -0
- package/lib/tailwindcss/class-order.async.v3.d.ts +3 -0
- package/lib/tailwindcss/class-order.async.v3.d.ts.map +1 -0
- package/lib/tailwindcss/class-order.async.v3.js +4 -0
- package/lib/tailwindcss/class-order.async.v3.js.map +1 -0
- package/lib/tailwindcss/class-order.async.v4.d.ts +3 -0
- package/lib/tailwindcss/class-order.async.v4.d.ts.map +1 -0
- package/lib/tailwindcss/class-order.async.v4.js +4 -0
- package/lib/tailwindcss/class-order.async.v4.js.map +1 -0
- package/lib/tailwindcss/class-order.d.ts +11 -0
- package/lib/tailwindcss/class-order.d.ts.map +1 -0
- package/lib/tailwindcss/class-order.js +16 -0
- package/lib/tailwindcss/class-order.js.map +1 -0
- package/lib/tailwindcss/conflicting-classes.async.v4.d.ts +35 -0
- package/lib/tailwindcss/conflicting-classes.async.v4.d.ts.map +1 -0
- package/lib/tailwindcss/conflicting-classes.async.v4.js +82 -0
- package/lib/tailwindcss/conflicting-classes.async.v4.js.map +1 -0
- package/lib/tailwindcss/conflicting-classes.d.ts +19 -0
- package/lib/tailwindcss/conflicting-classes.d.ts.map +1 -0
- package/lib/tailwindcss/conflicting-classes.js +17 -0
- package/lib/tailwindcss/conflicting-classes.js.map +1 -0
- package/lib/tailwindcss/context.async.v3.d.ts +3 -0
- package/lib/tailwindcss/context.async.v3.d.ts.map +1 -0
- package/lib/tailwindcss/context.async.v3.js +13 -0
- package/lib/tailwindcss/context.async.v3.js.map +1 -0
- package/lib/tailwindcss/context.async.v4.d.ts +3 -0
- package/lib/tailwindcss/context.async.v4.d.ts.map +1 -0
- package/lib/tailwindcss/context.async.v4.js +82 -0
- package/lib/tailwindcss/context.async.v4.js.map +1 -0
- package/lib/tailwindcss/custom-component-classes.async.v3.d.ts +4 -0
- package/lib/tailwindcss/custom-component-classes.async.v3.d.ts.map +1 -0
- package/lib/tailwindcss/custom-component-classes.async.v3.js +4 -0
- package/lib/tailwindcss/custom-component-classes.async.v3.js.map +1 -0
- package/lib/tailwindcss/custom-component-classes.async.v4.d.ts +4 -0
- package/lib/tailwindcss/custom-component-classes.async.v4.d.ts.map +1 -0
- package/lib/tailwindcss/custom-component-classes.async.v4.js +101 -0
- package/lib/tailwindcss/custom-component-classes.async.v4.js.map +1 -0
- package/lib/tailwindcss/custom-component-classes.d.ts +11 -0
- package/lib/tailwindcss/custom-component-classes.d.ts.map +1 -0
- package/lib/tailwindcss/custom-component-classes.js +16 -0
- package/lib/tailwindcss/custom-component-classes.js.map +1 -0
- package/lib/tailwindcss/dissect-classes.async.v3.d.ts +4 -0
- package/lib/tailwindcss/dissect-classes.async.v3.d.ts.map +1 -0
- package/lib/tailwindcss/dissect-classes.async.v3.js +32 -0
- package/lib/tailwindcss/dissect-classes.async.v3.js.map +1 -0
- package/lib/tailwindcss/dissect-classes.async.v4.d.ts +3 -0
- package/lib/tailwindcss/dissect-classes.async.v4.d.ts.map +1 -0
- package/lib/tailwindcss/dissect-classes.async.v4.js +39 -0
- package/lib/tailwindcss/dissect-classes.async.v4.js.map +1 -0
- package/lib/tailwindcss/dissect-classes.d.ts +23 -0
- package/lib/tailwindcss/dissect-classes.d.ts.map +1 -0
- package/lib/tailwindcss/dissect-classes.js +16 -0
- package/lib/tailwindcss/dissect-classes.js.map +1 -0
- package/lib/tailwindcss/prefix.async.v3.d.ts +4 -0
- package/lib/tailwindcss/prefix.async.v3.d.ts.map +1 -0
- package/lib/tailwindcss/prefix.async.v3.js +7 -0
- package/lib/tailwindcss/prefix.async.v3.js.map +1 -0
- package/lib/tailwindcss/prefix.async.v4.d.ts +4 -0
- package/lib/tailwindcss/prefix.async.v4.d.ts.map +1 -0
- package/lib/tailwindcss/prefix.async.v4.js +7 -0
- package/lib/tailwindcss/prefix.async.v4.js.map +1 -0
- package/lib/tailwindcss/prefix.d.ts +13 -0
- package/lib/tailwindcss/prefix.d.ts.map +1 -0
- package/lib/tailwindcss/prefix.js +15 -0
- package/lib/tailwindcss/prefix.js.map +1 -0
- package/lib/tailwindcss/tailwind.async.worker.v3.d.ts +2 -0
- package/lib/tailwindcss/tailwind.async.worker.v3.d.ts.map +1 -0
- package/lib/tailwindcss/tailwind.async.worker.v3.js +57 -0
- package/lib/tailwindcss/tailwind.async.worker.v3.js.map +1 -0
- package/lib/tailwindcss/tailwind.async.worker.v4.d.ts +2 -0
- package/lib/tailwindcss/tailwind.async.worker.v4.d.ts.map +1 -0
- package/lib/tailwindcss/tailwind.async.worker.v4.js +56 -0
- package/lib/tailwindcss/tailwind.async.worker.v4.js.map +1 -0
- package/lib/tailwindcss/unknown-classes.async.v3.d.ts +4 -0
- package/lib/tailwindcss/unknown-classes.async.v3.d.ts.map +1 -0
- package/lib/tailwindcss/unknown-classes.async.v3.js +10 -0
- package/lib/tailwindcss/unknown-classes.async.v3.js.map +1 -0
- package/lib/tailwindcss/unknown-classes.async.v4.d.ts +3 -0
- package/lib/tailwindcss/unknown-classes.async.v4.d.ts.map +1 -0
- package/lib/tailwindcss/unknown-classes.async.v4.js +5 -0
- package/lib/tailwindcss/unknown-classes.async.v4.js.map +1 -0
- package/lib/tailwindcss/unknown-classes.d.ts +11 -0
- package/lib/tailwindcss/unknown-classes.d.ts.map +1 -0
- package/lib/tailwindcss/unknown-classes.js +21 -0
- package/lib/tailwindcss/unknown-classes.js.map +1 -0
- package/lib/tailwindcss/variant-order.async.v3.d.ts +3 -0
- package/lib/tailwindcss/variant-order.async.v3.d.ts.map +1 -0
- package/lib/tailwindcss/variant-order.async.v3.js +4 -0
- package/lib/tailwindcss/variant-order.async.v3.js.map +1 -0
- package/lib/tailwindcss/variant-order.async.v4.d.ts +3 -0
- package/lib/tailwindcss/variant-order.async.v4.d.ts.map +1 -0
- package/lib/tailwindcss/variant-order.async.v4.js +34 -0
- package/lib/tailwindcss/variant-order.async.v4.js.map +1 -0
- package/lib/tailwindcss/variant-order.d.ts +11 -0
- package/lib/tailwindcss/variant-order.d.ts.map +1 -0
- package/lib/tailwindcss/variant-order.js +16 -0
- package/lib/tailwindcss/variant-order.js.map +1 -0
- package/lib/types/ast.d.ts +79 -0
- package/lib/types/ast.d.ts.map +1 -0
- package/lib/types/ast.js +2 -0
- package/lib/types/ast.js.map +1 -0
- package/lib/types/async.d.ts +7 -0
- package/lib/types/async.d.ts.map +1 -0
- package/lib/types/async.js +2 -0
- package/lib/types/async.js.map +1 -0
- package/lib/types/estree.d.ts +7 -0
- package/lib/types/estree.d.ts.map +1 -0
- package/lib/types/estree.js +2 -0
- package/lib/types/estree.js.map +1 -0
- package/lib/types/rule.d.ts +163 -0
- package/lib/types/rule.d.ts.map +1 -0
- package/lib/types/rule.js +24 -0
- package/lib/types/rule.js.map +1 -0
- package/lib/utils/ast.d.ts +4 -0
- package/lib/utils/ast.d.ts.map +1 -0
- package/lib/utils/ast.js +9 -0
- package/lib/utils/ast.js.map +1 -0
- package/lib/utils/class.d.ts +12 -0
- package/lib/utils/class.d.ts.map +1 -0
- package/lib/utils/class.js +19 -0
- package/lib/utils/class.js.map +1 -0
- package/lib/utils/context.d.ts +20 -0
- package/lib/utils/context.d.ts.map +1 -0
- package/lib/utils/context.js +91 -0
- package/lib/utils/context.js.map +1 -0
- package/lib/utils/lint.d.ts +17 -0
- package/lib/utils/lint.d.ts.map +1 -0
- package/lib/utils/lint.js +40 -0
- package/lib/utils/lint.js.map +1 -0
- package/lib/utils/matchers.d.ts +24 -0
- package/lib/utils/matchers.d.ts.map +1 -0
- package/lib/utils/matchers.js +154 -0
- package/lib/utils/matchers.js.map +1 -0
- package/lib/utils/quotes.d.ts +3 -0
- package/lib/utils/quotes.d.ts.map +1 -0
- package/lib/utils/quotes.js +9 -0
- package/lib/utils/quotes.js.map +1 -0
- package/lib/utils/rule.d.ts +31 -0
- package/lib/utils/rule.d.ts.map +1 -0
- package/lib/utils/rule.js +349 -0
- package/lib/utils/rule.js.map +1 -0
- package/lib/utils/selectors.d.ts +3 -0
- package/lib/utils/selectors.d.ts.map +1 -0
- package/lib/utils/selectors.js +4 -0
- package/lib/utils/selectors.js.map +1 -0
- package/lib/utils/utils.d.ts +49 -0
- package/lib/utils/utils.d.ts.map +1 -0
- package/lib/utils/utils.js +203 -0
- package/lib/utils/utils.js.map +1 -0
- package/lib/utils/valibot.d.ts +4 -0
- package/lib/utils/valibot.d.ts.map +1 -0
- package/lib/utils/valibot.js +12 -0
- package/lib/utils/valibot.js.map +1 -0
- package/lib/utils/version.d.ts +7 -0
- package/lib/utils/version.d.ts.map +1 -0
- package/lib/utils/version.js +6 -0
- package/lib/utils/version.js.map +1 -0
- package/lib/utils/visitedNodes.d.ts +4 -0
- package/lib/utils/visitedNodes.d.ts.map +1 -0
- package/lib/utils/visitedNodes.js +11 -0
- package/lib/utils/visitedNodes.js.map +1 -0
- package/lib/utils/warn.d.ts +2 -0
- package/lib/utils/warn.d.ts.map +1 -0
- package/lib/utils/warn.js +8 -0
- package/lib/utils/warn.js.map +1 -0
- package/package.json +163 -4
|
@@ -0,0 +1,924 @@
|
|
|
1
|
+
import { MATCHER_RESULT, MatcherType } from "../types/rule.js";
|
|
2
|
+
import { getLiteralNodesByMatchers, isIndexedAccessLiteral, isInsideConditionalExpressionTest, isInsideDisallowedBinaryExpression, isInsideLogicalExpressionLeft, isInsideMemberExpression, matchesPathPattern } from "../utils/matchers.js";
|
|
3
|
+
import { createObjectPathElement, deduplicateLiterals, getContent, getIndentation, getQuotes, getWhitespace, isGenericNodeWithParent, matchesName } from "../utils/utils.js";
|
|
4
|
+
import { createVisitedNodes, visitNode } from "../utils/visitedNodes.js";
|
|
5
|
+
export const ES_CONTAINER_TYPES_TO_REPLACE_QUOTES = [
|
|
6
|
+
"ArrayExpression",
|
|
7
|
+
"Property",
|
|
8
|
+
"CallExpression",
|
|
9
|
+
"VariableDeclarator",
|
|
10
|
+
"ConditionalExpression",
|
|
11
|
+
"LogicalExpression"
|
|
12
|
+
];
|
|
13
|
+
export const ES_CONTAINER_TYPES_TO_INSERT_BRACES = [];
|
|
14
|
+
export function getLiteralsByESVariableDeclarator(ctx, node, selectors) {
|
|
15
|
+
const literals = selectors.reduce((literals, selector) => {
|
|
16
|
+
if (!node.init) {
|
|
17
|
+
return literals;
|
|
18
|
+
}
|
|
19
|
+
if (!isESVariableSymbol(node.id)) {
|
|
20
|
+
return literals;
|
|
21
|
+
}
|
|
22
|
+
if (!matchesName(selector.name, node.id.name)) {
|
|
23
|
+
return literals;
|
|
24
|
+
}
|
|
25
|
+
if (!selector.match) {
|
|
26
|
+
literals.push(...getLiteralsByESExpression(ctx, [node.init]));
|
|
27
|
+
return literals;
|
|
28
|
+
}
|
|
29
|
+
if (isESCallExpression(node.init)) {
|
|
30
|
+
return literals;
|
|
31
|
+
}
|
|
32
|
+
literals.push(...getLiteralsByESMatchers(ctx, node.init, selector.match));
|
|
33
|
+
return literals;
|
|
34
|
+
}, []);
|
|
35
|
+
return literals.filter(deduplicateLiterals);
|
|
36
|
+
}
|
|
37
|
+
export function getLiteralsByESExportDefaultDeclaration(ctx, node, selectors) {
|
|
38
|
+
const literals = selectors.reduce((literals, selector) => {
|
|
39
|
+
if (!matchesName(selector.name, "default")) {
|
|
40
|
+
return literals;
|
|
41
|
+
}
|
|
42
|
+
if (!isESExportDefaultExpression(node.declaration)) {
|
|
43
|
+
return literals;
|
|
44
|
+
}
|
|
45
|
+
if (!selector.match) {
|
|
46
|
+
literals.push(...getLiteralsByESExpression(ctx, [node.declaration]));
|
|
47
|
+
return literals;
|
|
48
|
+
}
|
|
49
|
+
if (isESCallExpression(node.declaration)) {
|
|
50
|
+
return literals;
|
|
51
|
+
}
|
|
52
|
+
literals.push(...getLiteralsByESMatchers(ctx, node.declaration, selector.match));
|
|
53
|
+
return literals;
|
|
54
|
+
}, []);
|
|
55
|
+
return literals.filter(deduplicateLiterals);
|
|
56
|
+
}
|
|
57
|
+
export function getLiteralsByESCallExpression(ctx, node, selectors) {
|
|
58
|
+
if (isNestedCurriedCall(node)) {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
const callChain = getCurriedCallChain(node);
|
|
62
|
+
if (!callChain) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
const calleePath = getESCalleeName(callChain[0].callee, "path");
|
|
66
|
+
const calleeName = getESCalleeName(callChain[0].callee, "name");
|
|
67
|
+
const literals = selectors.reduce((literals, selector) => {
|
|
68
|
+
if (!selector.path && !selector.name ||
|
|
69
|
+
(!selector.path || !matchesName(selector.path, calleePath)) &&
|
|
70
|
+
(!selector.name || !matchesName(selector.name, calleeName))) {
|
|
71
|
+
return literals;
|
|
72
|
+
}
|
|
73
|
+
const targetCall = selector.targetCall ?? selector.callTarget;
|
|
74
|
+
const targetCalls = getTargetCalls(callChain, targetCall);
|
|
75
|
+
for (const targetCall of targetCalls) {
|
|
76
|
+
const targetArguments = getTargetArguments(targetCall.arguments, selector.targetArgument);
|
|
77
|
+
if (!selector.match) {
|
|
78
|
+
literals.push(...getLiteralsByESExpression(ctx, targetArguments));
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
for (const targetArgument of targetArguments) {
|
|
82
|
+
literals.push(...getLiteralsByESMatchers(ctx, targetArgument, selector.match));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return literals;
|
|
86
|
+
}, []);
|
|
87
|
+
return literals.filter(deduplicateLiterals);
|
|
88
|
+
}
|
|
89
|
+
export function getLiteralsByTaggedTemplateExpression(ctx, node, selectors) {
|
|
90
|
+
const tagPath = getTaggedTemplateName(node.tag, "path");
|
|
91
|
+
const tagName = getTaggedTemplateName(node.tag, "name");
|
|
92
|
+
if (!tagPath && !tagName) {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
const literals = selectors.reduce((literals, selector) => {
|
|
96
|
+
if (!selector.path && !selector.name ||
|
|
97
|
+
(!selector.path || !matchesName(selector.path, tagPath)) &&
|
|
98
|
+
(!selector.name || !matchesName(selector.name, tagName))) {
|
|
99
|
+
return literals;
|
|
100
|
+
}
|
|
101
|
+
if (!selector.match) {
|
|
102
|
+
literals.push(...getLiteralsByESTemplateLiteral(ctx, node.quasi));
|
|
103
|
+
return literals;
|
|
104
|
+
}
|
|
105
|
+
literals.push(...getLiteralsByESMatchers(ctx, node, selector.match));
|
|
106
|
+
return literals;
|
|
107
|
+
}, []);
|
|
108
|
+
return literals.filter(deduplicateLiterals);
|
|
109
|
+
}
|
|
110
|
+
export function getLiteralsByESBareTemplateLiteral(ctx, node, selectors) {
|
|
111
|
+
const leadingComment = getLeadingComment(ctx, node);
|
|
112
|
+
if (isTaggedTemplateLiteral(node) || !leadingComment) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
const literals = selectors.reduce((literals, selector) => {
|
|
116
|
+
if (!selector.name || !matchesName(selector.name, leadingComment)) {
|
|
117
|
+
return literals;
|
|
118
|
+
}
|
|
119
|
+
if (!selector.match) {
|
|
120
|
+
literals.push(...getLiteralsByESTemplateLiteral(ctx, node));
|
|
121
|
+
return literals;
|
|
122
|
+
}
|
|
123
|
+
literals.push(...getLiteralsByESMatchers(ctx, node, selector.match));
|
|
124
|
+
return literals;
|
|
125
|
+
}, []);
|
|
126
|
+
return literals.filter(deduplicateLiterals);
|
|
127
|
+
}
|
|
128
|
+
export function getLiteralsByESLiteralNode(ctx, node) {
|
|
129
|
+
if (isESTemplateLiteral(node)) {
|
|
130
|
+
return getLiteralsByESTemplateLiteral(ctx, node);
|
|
131
|
+
}
|
|
132
|
+
const literal = getLiteralByESLiteralNode(ctx, node);
|
|
133
|
+
return literal ? [literal] : [];
|
|
134
|
+
}
|
|
135
|
+
export function getLiteralByESLiteralNode(ctx, node) {
|
|
136
|
+
if (isESSimpleStringLiteral(node)) {
|
|
137
|
+
return getStringLiteralByESStringLiteral(ctx, node);
|
|
138
|
+
}
|
|
139
|
+
if (isESTemplateElement(node) && hasESNodeParentExtension(node)) {
|
|
140
|
+
return getLiteralByESTemplateElement(ctx, node);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function getLiteralByESLiteralNodeInternal(ctx, node, visitedNodes) {
|
|
144
|
+
if (isESSimpleStringLiteral(node)) {
|
|
145
|
+
return getStringLiteralByESStringLiteralInternal(ctx, node, visitedNodes);
|
|
146
|
+
}
|
|
147
|
+
if (isESTemplateElement(node) && hasESNodeParentExtension(node)) {
|
|
148
|
+
return getLiteralByESTemplateElementInternal(ctx, node, visitedNodes);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
export function getLiteralsByESMatchers(ctx, node, matchers) {
|
|
152
|
+
const matcherFunctions = getESMatcherFunctions(matchers);
|
|
153
|
+
const literalNodes = getLiteralNodesByMatchers(ctx, node, matcherFunctions);
|
|
154
|
+
const literals = literalNodes.flatMap(literalNode => getLiteralsByESLiteralNode(ctx, literalNode));
|
|
155
|
+
return literals.filter(deduplicateLiterals);
|
|
156
|
+
}
|
|
157
|
+
export function getStringLiteralByESStringLiteral(ctx, node) {
|
|
158
|
+
return getStringLiteralByESStringLiteralInternal(ctx, node, createVisitedNodes());
|
|
159
|
+
}
|
|
160
|
+
function getStringLiteralByESStringLiteralInternal(ctx, node, visitedNodes) {
|
|
161
|
+
const raw = node.raw;
|
|
162
|
+
if (!raw || !node.loc || !node.range || !node.parent.loc || !node.parent.range) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const line = ctx.sourceCode.lines[node.loc.start.line - 1];
|
|
166
|
+
const quotes = getQuotes(raw);
|
|
167
|
+
const priorLiterals = findPriorLiterals(ctx, node, visitedNodes);
|
|
168
|
+
const content = getContent(raw, quotes);
|
|
169
|
+
const whitespaces = getWhitespace(content);
|
|
170
|
+
const indentation = getIndentation(line);
|
|
171
|
+
const multilineQuotes = getMultilineQuotes(node);
|
|
172
|
+
const supportsMultiline = !isESObjectKey(node);
|
|
173
|
+
const concatenation = getStringConcatenationMeta(ctx, node, visitedNodes);
|
|
174
|
+
return {
|
|
175
|
+
...quotes,
|
|
176
|
+
...whitespaces,
|
|
177
|
+
...multilineQuotes,
|
|
178
|
+
...concatenation,
|
|
179
|
+
content,
|
|
180
|
+
indentation,
|
|
181
|
+
isInterpolated: false,
|
|
182
|
+
loc: node.loc,
|
|
183
|
+
priorLiterals,
|
|
184
|
+
range: node.range,
|
|
185
|
+
raw,
|
|
186
|
+
supportsMultiline,
|
|
187
|
+
type: "StringLiteral"
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function getLiteralByESTemplateElement(ctx, node) {
|
|
191
|
+
return getLiteralByESTemplateElementInternal(ctx, node, createVisitedNodes());
|
|
192
|
+
}
|
|
193
|
+
function getLiteralByESTemplateElementInternal(ctx, node, visitedNodes) {
|
|
194
|
+
const raw = ctx.sourceCode.getText(node);
|
|
195
|
+
if (!raw || !node.loc || !node.range || !node.parent.loc || !node.parent.range) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const line = ctx.sourceCode.lines[node.parent.loc.start.line - 1];
|
|
199
|
+
const quotes = getQuotes(raw);
|
|
200
|
+
const braces = getBracesByString(ctx, raw);
|
|
201
|
+
const isInterpolated = getIsInterpolated(ctx, raw);
|
|
202
|
+
const priorLiterals = findPriorLiterals(ctx, node, visitedNodes);
|
|
203
|
+
const content = getContent(raw, quotes, braces);
|
|
204
|
+
const whitespaces = getWhitespace(content);
|
|
205
|
+
const indentation = getIndentation(line);
|
|
206
|
+
const multilineQuotes = getMultilineQuotes(node);
|
|
207
|
+
const concatenation = getStringConcatenationMeta(ctx, node, visitedNodes);
|
|
208
|
+
return {
|
|
209
|
+
...whitespaces,
|
|
210
|
+
...quotes,
|
|
211
|
+
...braces,
|
|
212
|
+
...multilineQuotes,
|
|
213
|
+
...concatenation,
|
|
214
|
+
content,
|
|
215
|
+
indentation,
|
|
216
|
+
isInterpolated,
|
|
217
|
+
loc: node.loc,
|
|
218
|
+
priorLiterals,
|
|
219
|
+
range: node.range,
|
|
220
|
+
raw,
|
|
221
|
+
supportsMultiline: true,
|
|
222
|
+
type: "TemplateLiteral"
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function getMultilineQuotes(node) {
|
|
226
|
+
const surroundingBraces = ES_CONTAINER_TYPES_TO_INSERT_BRACES.includes(node.parent.type);
|
|
227
|
+
const multilineQuotes = ES_CONTAINER_TYPES_TO_REPLACE_QUOTES.includes(node.parent.type)
|
|
228
|
+
? ["`"]
|
|
229
|
+
: [];
|
|
230
|
+
return {
|
|
231
|
+
multilineQuotes,
|
|
232
|
+
surroundingBraces
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function getLiteralsByESExpression(ctx, args) {
|
|
236
|
+
return args.reduce((acc, node) => {
|
|
237
|
+
acc.push(...getLiteralsByESLiteralNode(ctx, node));
|
|
238
|
+
return acc;
|
|
239
|
+
}, []);
|
|
240
|
+
}
|
|
241
|
+
export function getLiteralsByESTemplateLiteral(ctx, node) {
|
|
242
|
+
return node.quasis.map(quasi => {
|
|
243
|
+
if (!hasESNodeParentExtension(quasi)) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
return getLiteralByESTemplateElement(ctx, quasi);
|
|
247
|
+
}).filter((literal) => literal !== undefined);
|
|
248
|
+
}
|
|
249
|
+
export function findParentESTemplateLiteralByESTemplateElement(node) {
|
|
250
|
+
if (!hasESNodeParentExtension(node)) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (node.parent.type === "TemplateLiteral") {
|
|
254
|
+
return node.parent;
|
|
255
|
+
}
|
|
256
|
+
return findParentESTemplateLiteralByESTemplateElement(node.parent);
|
|
257
|
+
}
|
|
258
|
+
function findPriorLiterals(ctx, node, visitedNodes) {
|
|
259
|
+
if (!hasESNodeParentExtension(node)) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const priorLiterals = [];
|
|
263
|
+
let currentNode = node;
|
|
264
|
+
const visited = createVisitedNodes(visitedNodes);
|
|
265
|
+
while (hasESNodeParentExtension(currentNode)) {
|
|
266
|
+
const parent = currentNode.parent;
|
|
267
|
+
if (isESCallExpression(parent)) {
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
if (isESArrowFunctionExpression(parent)) {
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
if (isESFunctionExpression(parent)) {
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
if (isESVariableDeclarator(parent)) {
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
if (parent.type === "TemplateLiteral") {
|
|
280
|
+
for (const quasi of parent.quasis) {
|
|
281
|
+
if (quasi.range === node.range) {
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
if (quasi.type === "TemplateElement" && hasESNodeParentExtension(quasi) && visitNode(visited, quasi)) {
|
|
285
|
+
const literal = getLiteralByESTemplateElementInternal(ctx, quasi, visited);
|
|
286
|
+
if (!literal) {
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
priorLiterals.push(literal);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (parent.type === "TemplateElement" && visitNode(visited, parent)) {
|
|
294
|
+
const literal = getLiteralByESTemplateElementInternal(ctx, parent, visited);
|
|
295
|
+
if (!literal) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
priorLiterals.push(literal);
|
|
299
|
+
}
|
|
300
|
+
if (parent.type === "Literal") {
|
|
301
|
+
const literals = getLiteralsByESLiteralNode(ctx, parent);
|
|
302
|
+
if (!literals) {
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
priorLiterals.push(...literals);
|
|
306
|
+
}
|
|
307
|
+
currentNode = parent;
|
|
308
|
+
}
|
|
309
|
+
return priorLiterals;
|
|
310
|
+
}
|
|
311
|
+
export function getESObjectPath(node) {
|
|
312
|
+
if (!isGenericNodeWithParent(node)) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (!hasESNodeParentExtension(node)) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if (node.type !== "Property" &&
|
|
319
|
+
node.type !== "ObjectExpression" &&
|
|
320
|
+
node.type !== "ArrayExpression" &&
|
|
321
|
+
node.type !== "Identifier" &&
|
|
322
|
+
node.type !== "Literal" &&
|
|
323
|
+
node.type !== "TemplateElement") {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const paths = [];
|
|
327
|
+
if (node.type === "Property") {
|
|
328
|
+
if (node.key.type === "Identifier") {
|
|
329
|
+
paths.unshift(createObjectPathElement(node.key.name));
|
|
330
|
+
}
|
|
331
|
+
else if (node.key.type === "Literal") {
|
|
332
|
+
paths.unshift(createObjectPathElement(node.key.value?.toString() ?? node.key.raw));
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
return "";
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (isESStringLike(node) && isInsideObjectValue(node)) {
|
|
339
|
+
const property = findMatchingParentNodes(node, (node) => {
|
|
340
|
+
return isESNode(node) && node.type === "Property";
|
|
341
|
+
});
|
|
342
|
+
if (property) {
|
|
343
|
+
return getESObjectPath(property);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (isESObjectKey(node)) {
|
|
347
|
+
const property = node.parent;
|
|
348
|
+
return getESObjectPath(property);
|
|
349
|
+
}
|
|
350
|
+
if (node.parent.type === "ArrayExpression" && node.type !== "Property" && node.type !== "TemplateElement") {
|
|
351
|
+
const index = node.parent.elements.indexOf(node);
|
|
352
|
+
paths.unshift(`[${index}]`);
|
|
353
|
+
}
|
|
354
|
+
paths.unshift(getESObjectPath(node.parent));
|
|
355
|
+
return paths.reduce((paths, currentPath) => {
|
|
356
|
+
if (!currentPath) {
|
|
357
|
+
return paths;
|
|
358
|
+
}
|
|
359
|
+
if (paths.length === 0) {
|
|
360
|
+
return [currentPath];
|
|
361
|
+
}
|
|
362
|
+
if (currentPath.startsWith("[") && currentPath.endsWith("]")) {
|
|
363
|
+
return [...paths, currentPath];
|
|
364
|
+
}
|
|
365
|
+
return [...paths, ".", currentPath];
|
|
366
|
+
}, []).join("");
|
|
367
|
+
}
|
|
368
|
+
export function isESObjectKey(node) {
|
|
369
|
+
return (node.parent.type === "Property" &&
|
|
370
|
+
node.parent.parent.type === "ObjectExpression" &&
|
|
371
|
+
node.parent.key === node);
|
|
372
|
+
}
|
|
373
|
+
export function isInsideObjectValue(node) {
|
|
374
|
+
if (!hasESNodeParentExtension(node)) {
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
// #34 allow call expressions as object values
|
|
378
|
+
if (isESCallExpression(node)) {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
if (isESArrowFunctionExpression(node)) {
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
if (isESFunctionExpression(node)) {
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
if (node.parent.type === "Property" &&
|
|
388
|
+
node.parent.parent.type === "ObjectExpression" &&
|
|
389
|
+
node.parent.value === node) {
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
return isInsideObjectValue(node.parent);
|
|
393
|
+
}
|
|
394
|
+
function findMatchingParentNodes(node, matchesNode) {
|
|
395
|
+
if (!isGenericNodeWithParent(node)) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
if (matchesNode(node.parent)) {
|
|
399
|
+
return node.parent;
|
|
400
|
+
}
|
|
401
|
+
return findMatchingParentNodes(node.parent, matchesNode);
|
|
402
|
+
}
|
|
403
|
+
export function isESSimpleStringLiteral(node) {
|
|
404
|
+
return (node.type === "Literal" &&
|
|
405
|
+
"value" in node &&
|
|
406
|
+
typeof node.value === "string");
|
|
407
|
+
}
|
|
408
|
+
export function isESStringLike(node) {
|
|
409
|
+
return isESSimpleStringLiteral(node) || isESTemplateElement(node);
|
|
410
|
+
}
|
|
411
|
+
export function isESTemplateLiteral(node) {
|
|
412
|
+
return node.type === "TemplateLiteral";
|
|
413
|
+
}
|
|
414
|
+
export function isESTemplateElement(node) {
|
|
415
|
+
return node.type === "TemplateElement";
|
|
416
|
+
}
|
|
417
|
+
export function isESBinaryExpression(node) {
|
|
418
|
+
return node.type === "BinaryExpression";
|
|
419
|
+
}
|
|
420
|
+
export function isESConditionalExpression(node) {
|
|
421
|
+
return node.type === "ConditionalExpression";
|
|
422
|
+
}
|
|
423
|
+
export function isESLogicalExpression(node) {
|
|
424
|
+
return node.type === "LogicalExpression";
|
|
425
|
+
}
|
|
426
|
+
export function isESNode(node) {
|
|
427
|
+
return (node !== null &&
|
|
428
|
+
typeof node === "object" &&
|
|
429
|
+
"type" in node);
|
|
430
|
+
}
|
|
431
|
+
export function isESCallExpression(node) {
|
|
432
|
+
return node.type === "CallExpression";
|
|
433
|
+
}
|
|
434
|
+
export function isESArrowFunctionExpression(node) {
|
|
435
|
+
return node.type === "ArrowFunctionExpression";
|
|
436
|
+
}
|
|
437
|
+
export function isESFunctionExpression(node) {
|
|
438
|
+
return node.type === "FunctionExpression";
|
|
439
|
+
}
|
|
440
|
+
export function isESFunctionDeclaration(node) {
|
|
441
|
+
return node.type === "FunctionDeclaration";
|
|
442
|
+
}
|
|
443
|
+
export function isESAnonymousFunction(node) {
|
|
444
|
+
if (isESArrowFunctionExpression(node)) {
|
|
445
|
+
return true;
|
|
446
|
+
}
|
|
447
|
+
if (isESFunctionExpression(node) && node.id === null) {
|
|
448
|
+
return true;
|
|
449
|
+
}
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
export function isESArrowFunctionWithoutBody(node) {
|
|
453
|
+
return isESArrowFunctionExpression(node) && node.body.type !== "BlockStatement";
|
|
454
|
+
}
|
|
455
|
+
export function isESReturnStatement(node) {
|
|
456
|
+
return node.type === "ReturnStatement";
|
|
457
|
+
}
|
|
458
|
+
function getESMemberExpressionPropertyName(node) {
|
|
459
|
+
if (!node.computed && node.property.type === "Identifier") {
|
|
460
|
+
return node.property.name;
|
|
461
|
+
}
|
|
462
|
+
if (node.computed && isESSimpleStringLiteral(node.property)) {
|
|
463
|
+
return node.property.value;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
function getESCalleeName(node, type) {
|
|
467
|
+
if (node.type === "Identifier" && "name" in node && typeof node.name === "string") {
|
|
468
|
+
return node.name;
|
|
469
|
+
}
|
|
470
|
+
if (node.type === "MemberExpression" && "object" in node) {
|
|
471
|
+
const memberNode = node;
|
|
472
|
+
if (memberNode.object.type === "Super") {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
const object = getESCalleeName(memberNode.object, type);
|
|
476
|
+
const property = getESMemberExpressionPropertyName(memberNode);
|
|
477
|
+
if (!property) {
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
if (type === "name") {
|
|
481
|
+
return property;
|
|
482
|
+
}
|
|
483
|
+
if (!object) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
return `${object}.${property}`;
|
|
487
|
+
}
|
|
488
|
+
if (node.type === "ChainExpression" && "expression" in node) {
|
|
489
|
+
return getESCalleeName(node.expression, type);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
function getTaggedTemplateName(node, type) {
|
|
493
|
+
if (node.type === "Identifier" && "name" in node && typeof node.name === "string" &&
|
|
494
|
+
hasESNodeParentExtension(node) &&
|
|
495
|
+
isTaggedTemplateExpression(node.parent)) {
|
|
496
|
+
return node.name;
|
|
497
|
+
}
|
|
498
|
+
if (node.type === "MemberExpression") {
|
|
499
|
+
return getESCalleeName(node, type);
|
|
500
|
+
}
|
|
501
|
+
if (node.type === "CallExpression") {
|
|
502
|
+
return getESCalleeName(node.callee, type);
|
|
503
|
+
}
|
|
504
|
+
if (node.type === "ChainExpression" && "expression" in node) {
|
|
505
|
+
return getTaggedTemplateName(node.expression, type);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
function isNestedCurriedCall(node) {
|
|
509
|
+
return hasESNodeParentExtension(node) && isESCallExpression(node.parent) && node.parent.callee === node;
|
|
510
|
+
}
|
|
511
|
+
function getCurriedCallChain(node) {
|
|
512
|
+
const calls = [node];
|
|
513
|
+
let currentCall = node;
|
|
514
|
+
while (isESCallExpression(currentCall.callee)) {
|
|
515
|
+
currentCall = currentCall.callee;
|
|
516
|
+
calls.unshift(currentCall);
|
|
517
|
+
}
|
|
518
|
+
return calls;
|
|
519
|
+
}
|
|
520
|
+
function getTargetCalls(callChain, callTarget) {
|
|
521
|
+
return getTargetItems(callChain, callTarget, "first");
|
|
522
|
+
}
|
|
523
|
+
function getTargetArguments(args, argumentTarget) {
|
|
524
|
+
const expressionArgs = args.map((arg) => {
|
|
525
|
+
return arg.type === "SpreadElement"
|
|
526
|
+
? arg.argument
|
|
527
|
+
: arg;
|
|
528
|
+
});
|
|
529
|
+
if (typeof argumentTarget !== "number") {
|
|
530
|
+
return getTargetItems(expressionArgs, argumentTarget, "all");
|
|
531
|
+
}
|
|
532
|
+
if (args.length === 0) {
|
|
533
|
+
return [];
|
|
534
|
+
}
|
|
535
|
+
const index = argumentTarget >= 0
|
|
536
|
+
? argumentTarget
|
|
537
|
+
: args.length + argumentTarget;
|
|
538
|
+
if (index < 0 || index >= args.length) {
|
|
539
|
+
return [];
|
|
540
|
+
}
|
|
541
|
+
const targetArg = args[index];
|
|
542
|
+
return [targetArg.type === "SpreadElement" ? targetArg.argument : targetArg];
|
|
543
|
+
}
|
|
544
|
+
function getTargetItems(items, target, defaultTarget) {
|
|
545
|
+
if (items.length === 0) {
|
|
546
|
+
return [];
|
|
547
|
+
}
|
|
548
|
+
if (target === "all" || target === undefined && defaultTarget === "all") {
|
|
549
|
+
return items;
|
|
550
|
+
}
|
|
551
|
+
if (target === "last") {
|
|
552
|
+
return [items[items.length - 1]];
|
|
553
|
+
}
|
|
554
|
+
if (target === undefined || target === "first") {
|
|
555
|
+
return [items[0]];
|
|
556
|
+
}
|
|
557
|
+
const index = target >= 0
|
|
558
|
+
? target
|
|
559
|
+
: items.length + target;
|
|
560
|
+
if (index < 0 || index >= items.length) {
|
|
561
|
+
return [];
|
|
562
|
+
}
|
|
563
|
+
return [items[index]];
|
|
564
|
+
}
|
|
565
|
+
function isTaggedTemplateExpression(node) {
|
|
566
|
+
return node.type === "TaggedTemplateExpression";
|
|
567
|
+
}
|
|
568
|
+
function isTaggedTemplateLiteral(node) {
|
|
569
|
+
return hasESNodeParentExtension(node) && isTaggedTemplateExpression(node.parent);
|
|
570
|
+
}
|
|
571
|
+
export function isESVariableDeclarator(node) {
|
|
572
|
+
return node.type === "VariableDeclarator";
|
|
573
|
+
}
|
|
574
|
+
function isESExportDefaultExpression(node) {
|
|
575
|
+
if (node.type === "FunctionDeclaration") {
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
if (node.type === "ClassDeclaration") {
|
|
579
|
+
return false;
|
|
580
|
+
}
|
|
581
|
+
return true;
|
|
582
|
+
}
|
|
583
|
+
function isESVariableSymbol(node) {
|
|
584
|
+
return node.type === "Identifier" && !!node.parent && isESVariableDeclarator(node.parent);
|
|
585
|
+
}
|
|
586
|
+
export function hasESNodeParentExtension(node) {
|
|
587
|
+
return "parent" in node && !!node.parent;
|
|
588
|
+
}
|
|
589
|
+
function getBracesByString(ctx, raw) {
|
|
590
|
+
const closingBraces = raw.trim().startsWith("}") ? "}" : undefined;
|
|
591
|
+
const openingBraces = raw.trim().endsWith("${") ? "${" : undefined;
|
|
592
|
+
return {
|
|
593
|
+
closingBraces,
|
|
594
|
+
openingBraces
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
function getIsInterpolated(ctx, raw) {
|
|
598
|
+
const braces = getBracesByString(ctx, raw);
|
|
599
|
+
return !!braces.closingBraces || !!braces.openingBraces;
|
|
600
|
+
}
|
|
601
|
+
function getLeadingComment(ctx, node) {
|
|
602
|
+
try {
|
|
603
|
+
const token = ctx.sourceCode.getTokenBefore(node, { includeComments: true });
|
|
604
|
+
if (token && isESTokenComment(token)) {
|
|
605
|
+
return token.value.trim();
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
catch { }
|
|
609
|
+
}
|
|
610
|
+
function isESTokenComment(token) {
|
|
611
|
+
return (token.type === "Block" || token.type === "Line") && typeof token.value === "string";
|
|
612
|
+
}
|
|
613
|
+
function getStringConcatenationMeta(ctx, node, visitedNodes) {
|
|
614
|
+
const { isConcatenatedLeft, isConcatenatedRight } = getStringConcatenationDirection(node);
|
|
615
|
+
const visited = createVisitedNodes(visitedNodes);
|
|
616
|
+
visitNode(visited, node);
|
|
617
|
+
const leftNodes = findAdjacentInterpolatedExpressionNodes(node, "left") ??
|
|
618
|
+
findAdjacentTemplateQuasiNodes(node, "left") ??
|
|
619
|
+
findAdjacentPlusConcatenatedLiteralNodes(node, "left");
|
|
620
|
+
const leftLiterals = isConcatenatedLeft
|
|
621
|
+
? buildConcatenationNeighborLiterals(ctx, leftNodes, visited)
|
|
622
|
+
: undefined;
|
|
623
|
+
const rightNodes = findAdjacentInterpolatedExpressionNodes(node, "right") ??
|
|
624
|
+
findAdjacentTemplateQuasiNodes(node, "right") ??
|
|
625
|
+
findAdjacentPlusConcatenatedLiteralNodes(node, "right");
|
|
626
|
+
const rightLiterals = isConcatenatedRight
|
|
627
|
+
? buildConcatenationNeighborLiterals(ctx, rightNodes, visited)
|
|
628
|
+
: undefined;
|
|
629
|
+
return { isConcatenatedLeft, isConcatenatedRight, leftLiterals, rightLiterals };
|
|
630
|
+
}
|
|
631
|
+
function buildConcatenationNeighborLiterals(ctx, nodes, visited) {
|
|
632
|
+
if (!nodes) {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
return nodes
|
|
636
|
+
.filter(adjacentNode => visitNode(visited, adjacentNode))
|
|
637
|
+
.map(adjacentNode => getLiteralByESLiteralNodeInternal(ctx, adjacentNode, visited))
|
|
638
|
+
.filter((literal) => literal !== undefined);
|
|
639
|
+
}
|
|
640
|
+
export function getStringConcatenationDirection(node, isConcatenatedLeft = false, isConcatenatedRight = false) {
|
|
641
|
+
if (!hasESNodeParentExtension(node)) {
|
|
642
|
+
return {
|
|
643
|
+
isConcatenatedLeft,
|
|
644
|
+
isConcatenatedRight
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
const parent = node.parent;
|
|
648
|
+
if (isESCallExpression(parent) ||
|
|
649
|
+
isESArrowFunctionExpression(parent) ||
|
|
650
|
+
isESFunctionExpression(parent) ||
|
|
651
|
+
isESVariableDeclarator(parent)) {
|
|
652
|
+
return {
|
|
653
|
+
isConcatenatedLeft,
|
|
654
|
+
isConcatenatedRight
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
if (isESTemplateLiteral(node.parent) && !isESTemplateElement(node)) {
|
|
658
|
+
return {
|
|
659
|
+
isConcatenatedLeft: true,
|
|
660
|
+
isConcatenatedRight: true
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
// a template quasi is concatenated with the interpolation adjacent to it (`}` before, `${` after)
|
|
664
|
+
if (isESTemplateElement(node) && isESTemplateLiteral(parent)) {
|
|
665
|
+
const index = parent.quasis.indexOf(node);
|
|
666
|
+
return getStringConcatenationDirection(parent, isConcatenatedLeft || index > 0, isConcatenatedRight || index < parent.quasis.length - 1);
|
|
667
|
+
}
|
|
668
|
+
if (isESBinaryExpression(parent) && parent.operator === "+") {
|
|
669
|
+
return getStringConcatenationDirection(parent, isConcatenatedLeft || parent.right === node, isConcatenatedRight || parent.left === node);
|
|
670
|
+
}
|
|
671
|
+
return getStringConcatenationDirection(parent, isConcatenatedLeft, isConcatenatedRight);
|
|
672
|
+
}
|
|
673
|
+
// resolves the literal nodes adjacent to `node` on the given side of a `+` concatenation chain
|
|
674
|
+
function findAdjacentPlusConcatenatedLiteralNodes(node, direction) {
|
|
675
|
+
const sibling = findConcatenationCounterpart(node, direction);
|
|
676
|
+
if (!sibling) {
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
const leafNodes = findConcatenationLeafNodes(sibling, direction === "left" ? "right" : "left");
|
|
680
|
+
return leafNodes.length > 0 ? leafNodes : undefined;
|
|
681
|
+
}
|
|
682
|
+
// resolves the leaf literal nodes of the interpolation expression adjacent to a template element (through conditional branches)
|
|
683
|
+
function findAdjacentInterpolatedExpressionNodes(node, direction) {
|
|
684
|
+
if (!isESTemplateElement(node) || !hasESNodeParentExtension(node) || !isESTemplateLiteral(node.parent)) {
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
const parent = node.parent;
|
|
688
|
+
const index = parent.quasis.indexOf(node);
|
|
689
|
+
if (index === -1) {
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
const expression = direction === "left" ? parent.expressions[index - 1] : parent.expressions[index];
|
|
693
|
+
if (!expression) {
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
const leafNodes = findConcatenationLeafNodes(expression, direction);
|
|
697
|
+
return leafNodes.length > 0 ? leafNodes : undefined;
|
|
698
|
+
}
|
|
699
|
+
// resolves the template quasis directly adjacent to an interpolation expression (through conditional branches)
|
|
700
|
+
function findAdjacentTemplateQuasiNodes(node, direction) {
|
|
701
|
+
let current = node;
|
|
702
|
+
while (hasESNodeParentExtension(current)) {
|
|
703
|
+
const parent = current.parent;
|
|
704
|
+
if (isESTemplateLiteral(parent)) {
|
|
705
|
+
if (isESTemplateElement(current)) {
|
|
706
|
+
current = parent;
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
const index = parent.expressions.indexOf(current);
|
|
710
|
+
if (index === -1) {
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
const quasi = direction === "left" ? parent.quasis[index] : parent.quasis[index + 1];
|
|
714
|
+
return quasi ? [quasi] : undefined;
|
|
715
|
+
}
|
|
716
|
+
if (isESConditionalExpression(parent) && (parent.consequent === current || parent.alternate === current)) {
|
|
717
|
+
current = parent;
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
if (isESLogicalExpression(parent) && parent.operator === "&&" && parent.right === current) {
|
|
721
|
+
current = parent;
|
|
722
|
+
continue;
|
|
723
|
+
}
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
function findConcatenationCounterpart(node, direction) {
|
|
728
|
+
let current = node;
|
|
729
|
+
while (hasESNodeParentExtension(current)) {
|
|
730
|
+
const parent = current.parent;
|
|
731
|
+
if (isESCallExpression(parent)) {
|
|
732
|
+
break;
|
|
733
|
+
}
|
|
734
|
+
if (isESArrowFunctionExpression(parent)) {
|
|
735
|
+
break;
|
|
736
|
+
}
|
|
737
|
+
if (isESFunctionExpression(parent)) {
|
|
738
|
+
break;
|
|
739
|
+
}
|
|
740
|
+
if (isESVariableDeclarator(parent)) {
|
|
741
|
+
break;
|
|
742
|
+
}
|
|
743
|
+
// conditionals are transparent: an operand's neighbor lives outside the branch
|
|
744
|
+
if (isESConditionalExpression(parent) && (parent.consequent === current || parent.alternate === current)) {
|
|
745
|
+
current = parent;
|
|
746
|
+
continue;
|
|
747
|
+
}
|
|
748
|
+
// an edge quasi's `+` neighbor lives outside the template literal
|
|
749
|
+
if (isESTemplateLiteral(parent)) {
|
|
750
|
+
const quasis = parent.quasis;
|
|
751
|
+
const isEdge = direction === "left"
|
|
752
|
+
? quasis[0] === current
|
|
753
|
+
: quasis[quasis.length - 1] === current;
|
|
754
|
+
if (isEdge) {
|
|
755
|
+
current = parent;
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
if (isESBinaryExpression(parent) && parent.operator === "+") {
|
|
761
|
+
if (direction === "left" && parent.right === current) {
|
|
762
|
+
return parent.left;
|
|
763
|
+
}
|
|
764
|
+
if (direction === "right" && parent.left === current) {
|
|
765
|
+
return parent.right;
|
|
766
|
+
}
|
|
767
|
+
current = parent;
|
|
768
|
+
continue;
|
|
769
|
+
}
|
|
770
|
+
if (isESLogicalExpression(parent) && parent.operator === "&&" && parent.right === current) {
|
|
771
|
+
current = parent;
|
|
772
|
+
continue;
|
|
773
|
+
}
|
|
774
|
+
break;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
function findConcatenationLeafNodes(node, edge) {
|
|
778
|
+
if (isESSimpleStringLiteral(node)) {
|
|
779
|
+
return [node];
|
|
780
|
+
}
|
|
781
|
+
if (isESTemplateLiteral(node)) {
|
|
782
|
+
const quasis = node.quasis;
|
|
783
|
+
const edgeQuasi = edge === "left" ? quasis[0] : quasis[quasis.length - 1];
|
|
784
|
+
return edgeQuasi ? [edgeQuasi] : [];
|
|
785
|
+
}
|
|
786
|
+
if (isESBinaryExpression(node) && node.operator === "+") {
|
|
787
|
+
return findConcatenationLeafNodes(edge === "left" ? node.left : node.right, edge);
|
|
788
|
+
}
|
|
789
|
+
if (isESConditionalExpression(node)) {
|
|
790
|
+
return [
|
|
791
|
+
...findConcatenationLeafNodes(node.consequent, edge),
|
|
792
|
+
...findConcatenationLeafNodes(node.alternate, edge)
|
|
793
|
+
];
|
|
794
|
+
}
|
|
795
|
+
if (isESLogicalExpression(node) && node.operator === "&&") {
|
|
796
|
+
return findConcatenationLeafNodes(node.right, "left");
|
|
797
|
+
}
|
|
798
|
+
return [];
|
|
799
|
+
}
|
|
800
|
+
export function getESMatcherFunctions(matchers, options) {
|
|
801
|
+
return matchers.reduce((matcherFunctions, matcher) => {
|
|
802
|
+
switch (matcher.type) {
|
|
803
|
+
case MatcherType.AnonymousFunctionReturn: {
|
|
804
|
+
matcherFunctions.push(node => {
|
|
805
|
+
if (isESNode(node) && (isESCallExpression(node) ||
|
|
806
|
+
isESVariableDeclarator(node))) {
|
|
807
|
+
return MATCHER_RESULT.UNCROSSABLE_BOUNDARY;
|
|
808
|
+
}
|
|
809
|
+
if (!isESNode(node) ||
|
|
810
|
+
!hasESNodeParentExtension(node) ||
|
|
811
|
+
!isESAnonymousFunction(node)) {
|
|
812
|
+
return MATCHER_RESULT.NO_MATCH;
|
|
813
|
+
}
|
|
814
|
+
// return matchers directly if the arrow function immediately returns
|
|
815
|
+
if (isESArrowFunctionWithoutBody(node)) {
|
|
816
|
+
return [(node) => {
|
|
817
|
+
if (!isESNode(node) ||
|
|
818
|
+
!hasESNodeParentExtension(node) ||
|
|
819
|
+
!isESArrowFunctionWithoutBody(node.parent) ||
|
|
820
|
+
node !== node.parent.body) {
|
|
821
|
+
return MATCHER_RESULT.NO_MATCH;
|
|
822
|
+
}
|
|
823
|
+
return getESMatcherFunctions(matcher.match, options);
|
|
824
|
+
}];
|
|
825
|
+
}
|
|
826
|
+
// create a matcher function that first matches the return statement and then the final matchers
|
|
827
|
+
return [(node) => {
|
|
828
|
+
if (isESNode(node) && (isESCallExpression(node) ||
|
|
829
|
+
isESArrowFunctionExpression(node) ||
|
|
830
|
+
isESVariableDeclarator(node) ||
|
|
831
|
+
isESFunctionExpression(node) ||
|
|
832
|
+
isESFunctionDeclaration(node))) {
|
|
833
|
+
return MATCHER_RESULT.UNCROSSABLE_BOUNDARY;
|
|
834
|
+
}
|
|
835
|
+
if (!isESNode(node) ||
|
|
836
|
+
!hasESNodeParentExtension(node) ||
|
|
837
|
+
!isESReturnStatement(node)) {
|
|
838
|
+
return MATCHER_RESULT.NO_MATCH;
|
|
839
|
+
}
|
|
840
|
+
return getESMatcherFunctions(matcher.match, options);
|
|
841
|
+
}];
|
|
842
|
+
});
|
|
843
|
+
break;
|
|
844
|
+
}
|
|
845
|
+
case MatcherType.String: {
|
|
846
|
+
matcherFunctions.push(node => {
|
|
847
|
+
if (isESNode(node) && (isESCallExpression(node) ||
|
|
848
|
+
isESArrowFunctionExpression(node) ||
|
|
849
|
+
isESVariableDeclarator(node) ||
|
|
850
|
+
isESFunctionExpression(node))) {
|
|
851
|
+
return MATCHER_RESULT.UNCROSSABLE_BOUNDARY;
|
|
852
|
+
}
|
|
853
|
+
if (!isESNode(node) ||
|
|
854
|
+
!hasESNodeParentExtension(node) ||
|
|
855
|
+
isInsideDisallowedBinaryExpression(node) ||
|
|
856
|
+
isInsideConditionalExpressionTest(node) ||
|
|
857
|
+
isInsideLogicalExpressionLeft(node) ||
|
|
858
|
+
isIndexedAccessLiteral(node) ||
|
|
859
|
+
isESObjectKey(node) ||
|
|
860
|
+
isInsideObjectValue(node)) {
|
|
861
|
+
return MATCHER_RESULT.NO_MATCH;
|
|
862
|
+
}
|
|
863
|
+
return isESStringLike(node) || !!options?.isStringLikeNode?.(node);
|
|
864
|
+
});
|
|
865
|
+
break;
|
|
866
|
+
}
|
|
867
|
+
case MatcherType.ObjectKey: {
|
|
868
|
+
matcherFunctions.push(node => {
|
|
869
|
+
if (isESNode(node) && (isESCallExpression(node) ||
|
|
870
|
+
isESArrowFunctionExpression(node) ||
|
|
871
|
+
isESVariableDeclarator(node) ||
|
|
872
|
+
isESFunctionExpression(node))) {
|
|
873
|
+
return MATCHER_RESULT.UNCROSSABLE_BOUNDARY;
|
|
874
|
+
}
|
|
875
|
+
if (!isESNode(node) ||
|
|
876
|
+
!hasESNodeParentExtension(node) ||
|
|
877
|
+
!isESObjectKey(node) ||
|
|
878
|
+
isInsideDisallowedBinaryExpression(node) ||
|
|
879
|
+
isInsideConditionalExpressionTest(node) ||
|
|
880
|
+
isInsideLogicalExpressionLeft(node) ||
|
|
881
|
+
isInsideMemberExpression(node) ||
|
|
882
|
+
isIndexedAccessLiteral(node)) {
|
|
883
|
+
return MATCHER_RESULT.NO_MATCH;
|
|
884
|
+
}
|
|
885
|
+
const path = getESObjectPath(node);
|
|
886
|
+
if (!path || !matcher.path) {
|
|
887
|
+
return MATCHER_RESULT.MATCH;
|
|
888
|
+
}
|
|
889
|
+
return matchesPathPattern(path, matcher.path);
|
|
890
|
+
});
|
|
891
|
+
break;
|
|
892
|
+
}
|
|
893
|
+
case MatcherType.ObjectValue: {
|
|
894
|
+
matcherFunctions.push(node => {
|
|
895
|
+
if (isESNode(node) && (isESCallExpression(node) ||
|
|
896
|
+
isESArrowFunctionExpression(node) ||
|
|
897
|
+
isESVariableDeclarator(node) ||
|
|
898
|
+
isESFunctionExpression(node))) {
|
|
899
|
+
return MATCHER_RESULT.UNCROSSABLE_BOUNDARY;
|
|
900
|
+
}
|
|
901
|
+
if (!isESNode(node) ||
|
|
902
|
+
!hasESNodeParentExtension(node) ||
|
|
903
|
+
!isInsideObjectValue(node) ||
|
|
904
|
+
isInsideDisallowedBinaryExpression(node) ||
|
|
905
|
+
isInsideConditionalExpressionTest(node) ||
|
|
906
|
+
isInsideLogicalExpressionLeft(node) ||
|
|
907
|
+
isESObjectKey(node) ||
|
|
908
|
+
isIndexedAccessLiteral(node) ||
|
|
909
|
+
!isESStringLike(node) && !options?.isStringLikeNode?.(node)) {
|
|
910
|
+
return MATCHER_RESULT.NO_MATCH;
|
|
911
|
+
}
|
|
912
|
+
const path = getESObjectPath(node);
|
|
913
|
+
if (!path || !matcher.path) {
|
|
914
|
+
return MATCHER_RESULT.MATCH;
|
|
915
|
+
}
|
|
916
|
+
return matchesPathPattern(path, matcher.path);
|
|
917
|
+
});
|
|
918
|
+
break;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
return matcherFunctions;
|
|
922
|
+
}, []);
|
|
923
|
+
}
|
|
924
|
+
//# sourceMappingURL=es.js.map
|