Published on

es-lint

Authors
  • avatar
    Name
    Timothy Blanks
// eslint-disable-line

// eslint-disable-next-line

Prevent the use of a built in function/method, Add this to .eslint rules

Example to prevent use of postMessage

rules:{
    ...,
    'no-restricted-syntax': [
      'error',
      {
        selector: "CallExpression[callee.property.name='postMessage']",
        message: 'Do not use `postMessage` directly, use XXX instead',
      },
    ],
    ...,
}

Example to prevent use of localStorage

    {
      selector: "CallExpression[callee.object.name='localStorage']",
      message: 'Do not use `localStorage` directly, use the storage wrapper instead',
    },