Eslint-plugin-import: Bug: import/no-deprecated doesn't work with typescript

Created on 5 Apr 2019  路  6Comments  路  Source: benmosher/eslint-plugin-import

.eslintrc.js

module.exports = {
  root: true,
  plugins: [
    '@typescript-eslint',
    'react',
    'react-hooks',
    'jsx-a11y',
    'filenames',
    'import',
  ],
  rules: {
    'import/no-deprecated': 'error',
  },
};

Code:

// usage.ts

import { foo } from './foo';

console.log(foo());

// foo.ts
/**
 * this is what you get when you trust a mouse talk show
 * @deprecated don't use this!
 * @returns {string} nonsense
 */
export function foo() {
  return 'bar';
}

lint run:

eslint --ignore-path .gitignore --ext .ts,.tsx packages

will produce NO lint errors

bug help wanted typescript

Most helpful comment

I think you need to configure a parser. I just added some tests and it seems to be working, _if_ a TypeScript parser is configured. Might also need the TS resolver:

settings: {
  'import/parsers': { '@typescript-eslint/parser': ['.ts'] },
  'import/resolver': { 'eslint-import-resolver-typescript': true },
}

All 6 comments

I think you need to configure a parser. I just added some tests and it seems to be working, _if_ a TypeScript parser is configured. Might also need the TS resolver:

settings: {
  'import/parsers': { '@typescript-eslint/parser': ['.ts'] },
  'import/resolver': { 'eslint-import-resolver-typescript': true },
}

Is the fix released already? I can't tell from the comments on #1257

Long fixed. Try it and see.

It still doesn't work for me. I was using RxJs forkJoin and it was not marked as deprecated in vscode (other eslint warnings work fine). A colleague using IntelliJ (which I guess uses an internal check, not eslint-based) pointed it out to me.

Please file a new issue for that.

Was this page helpful?
0 / 5 - 0 ratings