How to use the grim.deprecate function in grim

To help you get started, we’ve selected a few grim 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 atom / atom / src / pane.js View on Github external
addItem (item, options = {}) {
    // Backward compat with old API:
    //   addItem(item, index=@getActiveItemIndex() + 1)
    if (typeof options === 'number') {
      Grim.deprecate(`Pane::addItem(item, ${options}) is deprecated in favor of Pane::addItem(item, {index: ${options}})`)
      options = {index: options}
    }

    const index = options.index != null ? options.index : this.getActiveItemIndex() + 1
    const moved = options.moved != null ? options.moved : false
    const pending = options.pending != null ? options.pending : false

    if (!item || typeof item !== 'object') {
      throw new Error(`Pane items must be objects. Attempted to add item ${item}.`)
    }

    if (typeof item.isDestroyed === 'function' && item.isDestroyed()) {
      throw new Error(`Adding a pane item with URI '${typeof item.getURI === 'function' && item.getURI()}' that has already been destroyed`)
    }

    if (this.items.includes(item)) return
github atom / atom / exports / ipc.js View on Github external
module.exports = require('electron').ipcRenderer;

const Grim = require('grim');
Grim.deprecate(
  'Use `require("electron").ipcRenderer` instead of `require("ipc")`'
);

// Ensure each package that requires this shim causes a deprecation warning
delete require.cache[__filename];
github steelbrain / atom-linter / src / index.js View on Github external
export function parse(
  data: string,
  regex: string,
  givenOptions: { flags?: string, filePath?: string } = {}
) {
  // TODO: Remove this in atom-linter v11.
  deprecate(
    "The `parse` method is deprecated and will be removed in the next major release of atom-linter."
  );
  if (typeof data !== "string") {
    throw new Error("Invalid or no `data` provided");
  } else if (typeof regex !== "string") {
    throw new Error("Invalid or no `regex` provided");
  } else if (typeof givenOptions !== "object") {
    throw new Error("Invalid or no `options` provided");
  }

  if (NamedRegexp === null) {
    /* eslint-disable global-require */
    NamedRegexp = require("named-js-regexp");
    /* eslint-enable global-require */
  }
github atom / text-buffer / src / text-buffer.js View on Github external
loadSync (options) {
    if (!options || !options.internal) {
      Grim.deprecate('The .loadSync instance method is deprecated. Create a loaded buffer using TextBuffer.loadSync(filePath) instead.')
    }

    let patch = null
    let checkpoint = null
    try {
      patch = this.buffer.loadSync(
        this.getPath(),
        this.getEncoding(),
        (percentDone, patch) => {
          if (patch && patch.getChangeCount() > 0) {
            checkpoint = this.historyProvider.createCheckpoint({
              markers: this.createMarkerSnapshot(),
              isBarrier: true
            })
            this.emitter.emit('will-reload')
            this.emitWillChangeEvent()
github atom / atom / src / electron-shims.js View on Github external
return this.Dialog;
    case 'app':
      Grim.deprecate('Use `remote.app` instead of `remote.require("app")`');
      return this.app;
    case 'crash-reporter':
      Grim.deprecate(
        'Use `remote.crashReporter` instead of `remote.require("crashReporter")`'
      );
      return this.crashReporter;
    case 'global-shortcut':
      Grim.deprecate(
        'Use `remote.globalShortcut` instead of `remote.require("global-shortcut")`'
      );
      return this.globalShortcut;
    case 'clipboard':
      Grim.deprecate(
        'Use `remote.clipboard` instead of `remote.require("clipboard")`'
      );
      return this.clipboard;
    case 'native-image':
      Grim.deprecate(
        'Use `remote.nativeImage` instead of `remote.require("native-image")`'
      );
      return this.nativeImage;
    case 'tray':
      Grim.deprecate('Use `remote.Tray` instead of `remote.require("tray")`');
      return this.Tray;
    default:
      return remoteRequire.call(this, moduleName);
  }
};
github atom / atom / src / dock.js View on Github external
getActiveTextEditor() {
    Grim.deprecate(
      'Text editors are not allowed in docks. Use atom.workspace.getActiveTextEditor() instead.'
    );

    const activeItem = this.getActivePaneItem();
    if (activeItem instanceof TextEditor) {
      return activeItem;
    }
  }
github atom / text-buffer / src / text-buffer.js View on Github external
setTextInRange (range, newText, options) {
    let normalizeLineEndings, undo
    if (options) ({normalizeLineEndings, undo} = options)
    if (normalizeLineEndings == null) normalizeLineEndings = true
    if (undo != null) {
      Grim.deprecate('The `undo` option is deprecated. Call groupLastChanges() on the TextBuffer afterward instead.')
    }

    if (this.transactCallDepth === 0) {
      const newRange = this.transact(() => this.setTextInRange(range, newText, {normalizeLineEndings}))
      if (undo === 'skip') this.groupLastChanges()
      return newRange
    }

    const oldRange = this.clipRange(range)
    const oldText = this.getTextInRange(oldRange)

    if (normalizeLineEndings) {
      const normalizedEnding = this.preferredLineEnding ||
        this.lineEndingForRow(oldRange.start.row) ||
        this.lineEndingForRow(oldRange.start.row - 1)
      if (normalizedEnding) {
github atom / atom / src / electron-shims.js View on Github external
Grim.deprecate(
        'Use `remote.MenuItem` instead of `remote.require("menu-item")`'
      );
      return this.MenuItem;
    case 'browser-window':
      Grim.deprecate(
        'Use `remote.BrowserWindow` instead of `remote.require("browser-window")`'
      );
      return this.BrowserWindow;
    case 'dialog':
      Grim.deprecate(
        'Use `remote.Dialog` instead of `remote.require("dialog")`'
      );
      return this.Dialog;
    case 'app':
      Grim.deprecate('Use `remote.app` instead of `remote.require("app")`');
      return this.app;
    case 'crash-reporter':
      Grim.deprecate(
        'Use `remote.crashReporter` instead of `remote.require("crashReporter")`'
      );
      return this.crashReporter;
    case 'global-shortcut':
      Grim.deprecate(
        'Use `remote.globalShortcut` instead of `remote.require("global-shortcut")`'
      );
      return this.globalShortcut;
    case 'clipboard':
      Grim.deprecate(
        'Use `remote.clipboard` instead of `remote.require("clipboard")`'
      );
      return this.clipboard;
github atom / atom / src / atom-environment.js View on Github external
Promise.prototype.done = function (callback) {
  deprecate('Atom now uses ES6 Promises instead of Q. Call promise.then instead of promise.done')
  return this.then(callback)
}
github atom / atom / src / electron-shims.js View on Github external
path.dirname = function(path) {
  if (typeof path !== 'string') {
    path = '' + path;
    const Grim = require('grim');
    Grim.deprecate('Argument to `path.dirname` must be a string');
  }

  return dirname(path);
};

grim

Log usage of deprecated methods

MIT
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis