How to use ember-rfc176-data - 6 common examples

To help you get started, we’ve selected a few ember-rfc176-data 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 emberjs / ember.js / generate-modules-api.js View on Github external
['Ember.RouterDSL', 'ember-routing'],
  ['Ember.Router', 'ember-routing'],
  ['Ember.Route', 'ember-routing'],
  ['Ember.Application', 'ember-application'],
  ['Ember.ApplicationInstance', 'ember-application'],
  ['Ember.Engine', 'ember-application'],
  ['Ember.EngineInstance', 'ember-application'],
  ['Ember.Resolver', 'ember-application'],
  ['Ember.DefaultResolver', 'ember-application', 'Resolver'],
  ['Ember.DataAdapter', 'ember-extension-support'],
  ['Ember.ContainerDebugAdapter', 'ember-extension-support'],
];
const fs = require('fs-extra');
const path = require('path');

let moduleNames = new Set(mappings.filter(m => !m.deprecated).map(m => m.module));

moduleNames.forEach(moduleName => {
  let contents = '';
  mappings.filter(m => m.module === moduleName).forEach(m => {
    let exportForGlobal = allExports.find(e => e[0] === m.global);

    if (!exportForGlobal) {
      console.log('could not find: ' + m.global);

      if (m.export === 'default') {
        contents += `// TODO: export default ${m.global};\n`;
      } else {
        contents += `// TODO: export const ${m.export} = ${m.global};\n`;
      }
    } else {
      let exportName = exportForGlobal[2] || exportForGlobal[0].slice(6);
github emberjs / ember.js / generate-modules-api.js View on Github external
moduleNames.forEach(moduleName => {
  let contents = '';
  mappings.filter(m => m.module === moduleName).forEach(m => {
    let exportForGlobal = allExports.find(e => e[0] === m.global);

    if (!exportForGlobal) {
      console.log('could not find: ' + m.global);

      if (m.export === 'default') {
        contents += `// TODO: export default ${m.global};\n`;
      } else {
        contents += `// TODO: export const ${m.export} = ${m.global};\n`;
      }
    } else {
      let exportName = exportForGlobal[2] || exportForGlobal[0].slice(6);

      if (m.export === 'default') {
        contents += `export { ${exportName} as default } from '${exportForGlobal[1]}';\n`;
      } else if (m.export === exportName) {
github ember-cli / eslint-plugin-ember / lib / rules / new-module-imports.js View on Github external
'use strict';

const MAPPING = require('ember-rfc176-data');
const { buildMessage, getFullNames, isDestructuring } = require('../utils/new-module');
const { getSourceModuleNameForIdentifier } = require('../utils/import');

const GLOBALS = MAPPING.reduce((memo, exportDefinition) => {
  if (exportDefinition.deprecated) {
    return memo;
  }

  if (exportDefinition.global in memo) {
    return memo;
  }

  memo[exportDefinition.global] = exportDefinition; // eslint-disable-line no-param-reassign

  return memo;
}, Object.create(null));

//------------------------------------------------------------------------------
// General rule - Use "New Module Imports" from Ember RFC #176
//------------------------------------------------------------------------------
github ember-cli / eslint-plugin-ember / lib / rules / no-deprecated-modules.js View on Github external
'use strict';

const MAPPING = require('ember-rfc176-data');

const GLOBALS = MAPPING.reduce((memo, exportDefinition) => {
  if (!exportDefinition.deprecated) {
    return memo;
  }

  if (!exportDefinition.replacement) {
    return memo;
  }

  const exportName = exportDefinition.export;
  const moduleName = exportDefinition.module;

  if (!(moduleName in memo)) {
    memo[moduleName] = {}; // eslint-disable-line no-param-reassign
  }

  memo[moduleName][exportName] = exportDefinition; // eslint-disable-line no-param-reassign
github ember-cli / babel-plugin-ember-modules-api-polyfill / src / index.js View on Github external
module.exports = function(babel) {
  const t = babel.types;
  // Flips the ember-rfc176-data mapping into an 'import' indexed object, that exposes the
  // default import as well as named imports, e.g. import {foo} from 'bar'
  const reverseMapping = {};
  mapping.forEach(exportDefinition => {
    const imported = exportDefinition.global;
    const importRoot = exportDefinition.module;
    let importName = exportDefinition.export;

    if (!reverseMapping[importRoot]) {
      reverseMapping[importRoot] = {};
    }

    reverseMapping[importRoot][importName] = imported;
  });

  return {
    name: 'ember-modules-api-polyfill',
    visitor: {
      ImportDeclaration(path, state) {
        let blacklist = (state.opts && state.opts.blacklist) || [];
github kyleshevlin / alfred-ember-module-lookup / index.js View on Github external
'use strict'
const alfy = require('alfy')
const mapping = require('ember-rfc176-data')

function isDefaultExport(localName) {
  return !!localName
}

const pairs = mapping.map(
  ({ global, module, export: exportName, localName, deprecated }) => {
    if (isDefaultExport(localName)) {
      return {
        key: localName,
        value: `import ${localName} from '${module}'`
      }
    }

    return {
      key: exportName,
      value: `import { ${exportName} } from '${module}'`
    }
  }
)

const matches = alfy.inputMatches(pairs, 'key')

ember-rfc176-data

JSON data for Ember.js RFC #176

MIT
Latest version published 1 year ago

Package Health Score

63 / 100
Full package analysis

Similar packages