How to use util-deprecate - 10 common examples

To help you get started, we’ve selected a few util-deprecate 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 storybookjs / storybook / addons / a11y / src / index.ts View on Github external
if (storedDefaultSetup === null) {
        storedDefaultSetup = { ...setup };
      }
      Object.assign(setup, parameters as Setup);
    } else if (storedDefaultSetup !== null) {
      Object.assign(setup, storedDefaultSetup);
      storedDefaultSetup = null;
    }
    addons.getChannel().on(EVENTS.REQUEST, () => run(setup.element, setup.config, setup.options));

    return getStory(context);
  },
});

// TODO: REMOVE at v6.0.0
export const withA11Y = deprecate(
  // @ts-ignore
  (...args: any[]) => withA11y(...args),
  'withA11Y has been renamed withA11y'
);

// TODO: REMOVE at v6.0.0
export const checkA11y = deprecate(
  // @ts-ignore
  (...args: any[]) => withA11y(...args),
  'checkA11y has been renamed withA11y'
);

// TODO: REMOVE at v6.0.0
export const configureA11y = deprecate(
  (config: any) => {
    setup = config;
github storybookjs / storybook / addons / a11y / src / index.ts View on Github external
// TODO: REMOVE at v6.0.0
export const withA11Y = deprecate(
  // @ts-ignore
  (...args: any[]) => withA11y(...args),
  'withA11Y has been renamed withA11y'
);

// TODO: REMOVE at v6.0.0
export const checkA11y = deprecate(
  // @ts-ignore
  (...args: any[]) => withA11y(...args),
  'checkA11y has been renamed withA11y'
);

// TODO: REMOVE at v6.0.0
export const configureA11y = deprecate(
  (config: any) => {
    setup = config;
  },
  dedent`
    configureA11y is deprecated, please configure addon-a11y using the addParameter api:
    
    addParameters({
      a11y: {
        // ... axe options
        element: '#root', // optional selector which element to inspect
      },
    });
  `
);
github storybookjs / storybook / app / angular / src / server / utils.js View on Github external
import path from 'path';
import fs from 'fs';
import deprecate from 'util-deprecate';

const fallbackHeadUsage = deprecate(() => {},
'Usage of head.html has been deprecated. Please rename head.html to preview-head.html');

export function parseList(str) {
  return str.split(',');
}

export function getPreviewHeadHtml(configDirPath) {
  const headHtmlPath = path.resolve(configDirPath, 'preview-head.html');
  const fallbackHtmlPath = path.resolve(configDirPath, 'head.html');
  let headHtml = '';
  if (fs.existsSync(headHtmlPath)) {
    headHtml = fs.readFileSync(headHtmlPath, 'utf8');
  } else if (fs.existsSync(fallbackHtmlPath)) {
    headHtml = fs.readFileSync(fallbackHtmlPath, 'utf8');
    fallbackHeadUsage();
  }
github storybookjs / storybook / lib / api / src / modules / layout.ts View on Github external
showStoriesPanel: 'showNav';
  showAddonPanel: 'showPanel';
  addonPanelInRight: 'panelPosition';
} = {
  goFullScreen: 'isFullscreen',
  showStoriesPanel: 'showNav',
  showAddonPanel: 'showPanel',
  addonPanelInRight: 'panelPosition',
};

const deprecationMessage = (optionsMap: OptionsMap, prefix = '') =>
  `The options { ${Object.keys(optionsMap).join(', ')} } are deprecated -- use ${
    prefix ? `${prefix}'s` : ''
  } { ${Object.values(optionsMap).join(', ')} } instead.`;

const applyDeprecatedThemeOptions = deprecate(({ name, url, theme }: Options): PartialThemeVars => {
  const { brandTitle, brandUrl, brandImage }: PartialThemeVars = theme || {};
  return {
    brandTitle: brandTitle || name,
    brandUrl: brandUrl || url,
    brandImage: brandImage || null,
  };
}, deprecationMessage(deprecatedThemeOptions));

const applyDeprecatedLayoutOptions = deprecate((options: Options): PartialLayout => {
  const layoutUpdate: PartialLayout = {};

  ['goFullScreen', 'showStoriesPanel', 'showAddonPanel'].forEach(
    (option: 'goFullScreen' | 'showStoriesPanel' | 'showAddonPanel') => {
      const v = options[option];
      if (typeof v !== 'undefined') {
        const key = deprecatedLayoutOptions[option];
github storybookjs / storybook / addons / knobs / src / base.js View on Github external
value,
    groupId,
  };

  return manager.knob(name, finalOptions);
}

export function color(name, value, groupId) {
  return manager.knob(name, { type: 'color', value, groupId });
}

export function object(name, value, groupId) {
  return manager.knob(name, { type: 'object', value, groupId });
}

export const select = deprecate(
  (name, options, value, groupId) =>
    manager.knob(name, { type: 'select', options, value, groupId }),
  'in v4 keys/values of the options argument are reversed'
);

export function selectV2(name, options, value, groupId) {
  return manager.knob(name, { type: 'select', selectV2: true, options, value, groupId });
}

export function array(name, value, separator = ',', groupId) {
  return manager.knob(name, { type: 'array', value, separator, groupId });
}

export function date(name, value = new Date(), groupId) {
  const proxyValue = value ? value.getTime() : null;
  return manager.knob(name, { type: 'date', value: proxyValue, groupId });
github storybookjs / storybook / app / react / src / server / utils.js View on Github external
import path from 'path';
import fs from 'fs';
import deprecate from 'util-deprecate';

const fallbackHeadUsage = deprecate(() => {},
'Usage of head.html has been deprecated. Please rename head.html to preview-head.html');

export function getPreviewHeadHtml(configDirPath) {
  const headHtmlPath = path.resolve(configDirPath, 'preview-head.html');
  const fallbackHtmlPath = path.resolve(configDirPath, 'head.html');
  let headHtml = '';
  if (fs.existsSync(headHtmlPath)) {
    headHtml = fs.readFileSync(headHtmlPath, 'utf8');
  } else if (fs.existsSync(fallbackHtmlPath)) {
    headHtml = fs.readFileSync(fallbackHtmlPath, 'utf8');
    fallbackHeadUsage();
  }

  return headHtml;
}
github storybookjs / storybook / addons / options / src / register.ts View on Github external
import addons from '@storybook/addons';
import deprecate from 'util-deprecate';
import EVENTS, { ADDON_ID } from './constants';

addons.register(
  ADDON_ID,
  deprecate(api => {
    const channel = addons.getChannel();

    channel.on(EVENTS.SET, data => {
      api.setOptions(data.options);
    });
  }, 'storybook-addon-options is deprecated and will stop working soon')
);
github storybookjs / storybook / app / mithril / src / server / config / defaults / webpack.config.js View on Github external
import deprecate from 'util-deprecate';
import { createDefaultWebpackConfig } from '@storybook/core/server';

module.exports = deprecate(
  createDefaultWebpackConfig,
  "importing default webpack config generator from '@storybook/mithril/dist/server/config/defaults/webpack.config.js' is deprecated. Use third argument of your exported function instead. See https://storybook.js.org/configurations/custom-webpack-config/#full-control-mode--default"
);
github storybookjs / storybook / app / react-native / src / server / addons.js View on Github external
import deprecate from 'util-deprecate';
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';

deprecate(
  () => {},
  '@storybook/react-native/addons is deprecated. See https://storybook.js.org/addons/using-addons/'
)();
github storybookjs / storybook / addons / knobs / src / deprecated.js View on Github external
color,
  object,
  array,
  date,
  select,
  files,
  button,
  withKnobs as commonWithKnobs,
  withKnobsOptions as commonWithKnobsOptions,
} from '.';

export { knob, text, boolean, number, color, object, array, date, select, files, button };

export const selectV2 = deprecate(select, 'selectV2 has been renamed to select');

export const withKnobs = deprecate(
  commonWithKnobs,
  "addon-knobs: framework-specific imports are deprecated, just use `import {withKnobs} from '@storybook/addon-knobs`"
);

export const withKnobsOptions = deprecate(
  commonWithKnobsOptions,
  "addon-knobs: framework-specific imports are deprecated, just use `import {withKnobsOptions} from '@storybook/addon-knobs`"
);

util-deprecate

The Node.js `util.deprecate()` function with browser support

MIT
Latest version published 8 years ago

Package Health Score

65 / 100
Full package analysis

Popular util-deprecate functions