How to use ast-metadata-inferer - 2 common examples

To help you get started, we’ve selected a few ast-metadata-inferer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github amilajack / eslint-plugin-compat / src / providers / MdnProvider.js View on Github external
return targets
    .filter(target => !mdnSupported(node, target))
    .map(formatTargetNames);
}

function getMetadataName(metadata: Node) {
  switch (metadata.protoChain.length) {
    case 1: {
      return metadata.protoChain[0];
    }
    default:
      return `${metadata.protoChain.join('.')}()`;
  }
}

const MdnProvider: Array = AstMetadata
  // Create entries for each ast node type
  .map(metadata =>
    metadata.astNodeTypes.map(astNodeType => ({
      ...metadata,
      name: getMetadataName(metadata),
      id: metadata.protoChainId,
      protoChainId: metadata.protoChainId,
      astNodeType,
      object: metadata.protoChain[0],
      // @TODO Handle cases where 'prototype' is in protoChain
      property: metadata.protoChain[1]
    }))
  )
  // Flatten the array of arrays
  .reduce((p, c) => [...p, ...c])
  // Add rule and target support logic for each entry
github amilajack / eslint-plugin-compat / src / providers / MdnProvider.js View on Github external
protoChainId: string,
  astNodeTypes: Array,
  isStatic: boolean,
  compat: {
    support: {
      [browserName: string]: {
        // If a version is true then it is supported but version is unsure
        version_added: string | boolean
      }
    },
    [x: string]: any
  }
};

const mdnRecords: Map = new Map(
  AstMetadata.map(e => [e.protoChainId, e])
);

/**
 * Map ids of mdn targets to their "common/friendly" name
 */
const targetNameMappings = {
  chrome: 'Chrome',
  firefox: 'Firefox',
  opera: 'Opera',
  safari: 'Safari',
  ie: 'IE',
  edge: 'Edge',
  safari_ios: 'iOS Safari',
  opera_android: 'Opera Mobile',
  chrome_android: 'Android Chrome',
  edge_mobile: 'Edge Mobile',

ast-metadata-inferer

[![Test](https://github.com/amilajack/ast-metadata-inferer/actions/workflows/test.yml/badge.svg)](https://github.com/amilajack/ast-metadata-inferer/actions/workflows/test.yml)

MIT
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis

Popular ast-metadata-inferer functions