Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make `tsconfigRootDir` relative to the `.eslintrc` file #251

wibblymat opened this issue Feb 11, 2019 · 5 comments


Copy link

commented Feb 11, 2019

I am linting my project from two places. Firstly, I run eslint in a shell as part of the CI process. This will have a current working directory that is the location of the .eslintrc file.

I also run the ESLint plugin in VS Code. The current working directory for this is the project root, which is not the same location.

If I set the project setting to be tsconfig.json, and tsconfigRootDir to be . then I can run eslint from the shell. And if I set tsconfigRootDir to be path/to/my/subproject then I can use the VS code plugin. But there is no possible combination of options that let's both work.

Furthermore, tsconfigRootDir seems to be entirely redundant anyway, because there is no combination of project and tsconfigRootDir that can't be just concatenated into the project field, like { "project": "path/to/my/subproject/tsconfig.json" }


This comment has been minimized.

Copy link

commented Feb 15, 2019

FYI: To workaround, rename your eslintrc into .eslintrc.js then "tsconfigRootDir": __dirname.


This comment has been minimized.

Copy link

commented May 1, 2019

@ypresto Does not work for me.


module.exports = {
  parser: '@typescript-eslint/parser',
  plugins: ['@typescript-eslint'],
  env: {
    es6: true,
    node: true,
  extends: ['plugin:@typescript-eslint/recommended', 'prettier/@typescript-eslint', 'plugin:prettier/recommended'],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly',
  parserOptions: {
    ecmaVersion: 2018,
    sourceType: 'module',
    project: './tsconfig.json',
    tsconfigRootDir: __dirname,
  rules: {
    quotes: ['off'],
    'no-process-env': ['warn'],
    'no-var': ['warn'],
    'sort-imports': ['warn'],
    'func-style': ['error', 'expression'],
    'prefer-arrow-callback': ['error'],
    '@typescript-eslint/explicit-function-return-type': ['warn'],
    '@typescript-eslint/await-thenable': ['warn'],
    '@typescript-eslint/no-require-imports': ['warn'],
    '@typescript-eslint/no-unnecessary-type-assertion': ['warn'],
    '@typescript-eslint/prefer-string-starts-ends-with': ['warn'],
    '@typescript-eslint/interface-name-prefix': ['off'],
    '@typescript-eslint/explicit-member-accessibility': [
        accessibility: 'no-public',
    'prettier/prettier': [
        semi: false,
        trailingComma: 'es5',
        singleQuote: true,
        printWidth: 140,
        tabWidth: 2,
        arrowParens: 'always',
        usePrettierrc: false,


5/1/2019, 3:09:36 PM:
Error while loading rule '@typescript-eslint/await-thenable'/Users/prokop/Sites/_other/typescript-tutorial-adel/src/index.ts:: You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Occurred while linting /Users/prokop/Sites/_other/typescript-tutorial-adel/src/index.ts

This comment has been minimized.

Copy link

commented May 2, 2019

the easy workaround for this is to just import path and do it:

const path = require('path');
module.exports = {
  parserOptions: {
    project: path.resolve(__dirname, './tsconfig.json'),
    tsconfigRootDir: __dirname,

This comment has been minimized.

Copy link

commented May 16, 2019

Here's my solution for a Google Cloud Functions project in VSCode in case it helps someone.

My project has the usual structure for a functions project: the functions code and related configuration files are in a 'functions' subfolder of the project/workspace's root.

The beginning of my .eslint.json...

  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "project": "tsconfig.json",
    "tsconfigRootDir": "functions" 
  "plugins": ["@typescript-eslint"],

This got it working properly in the IDE but broke command line invocations, so now my package.json includes this:

  "scripts": {
    "lint": "eslint **/*.ts --parser-options={tsconfigRootDir:null}",

Which reverses the setting of 'tsconfigRootDir' in my eslintrc.json for the cmd line.

[edit: though this solves the problem of this issue (for me, at least) it doesn't help with the location of eslintignore.]


This comment has been minimized.

Copy link

commented Aug 14, 2019

If I understand the question, this can be resolved at VSCode's ESLint plugin side

  "eslint.workingDirectories": [
    {"directory": "./client", "changeProcessCWD": true}
kaicataldo pushed a commit to kaicataldo/typescript-eslint that referenced this issue Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
6 participants
You can’t perform that action at this time.