SublimeLinter-contrib-eslint_d icon indicating copy to clipboard operation
SublimeLinter-contrib-eslint_d copied to clipboard

node/no-missing-require errors with relative paths

Open swarthy opened this issue 8 years ago • 2 comments

Running eslint_d in terminal output nothing (no errors)

alex@alex-workstantion:~/work/imm/auth$ node -v
v7.10.0
alex@alex-workstantion:~/work/imm/auth$ ./node_modules/.bin/eslint_d -v
v3.19.0 (eslint_d v4.2.5)
alex@alex-workstantion:~/work/imm/auth$ ./node_modules/.bin/eslint_d --format compact --config /home/alex/work/imm/auth/.eslintrc ./api/services/PassportService.js
alex@alex-workstantion:~/work/imm/auth$ 
alex@alex-workstantion:~/work/imm/auth$ ./node_modules/.bin/eslint_d --format compact --config /home/alex/work/imm/auth/.eslintrc .
alex@alex-workstantion:~/work/imm/auth$ 

but in sublime its reports about missing files

SublimeLinter: eslint_d: PassportService.js ['/home/alex/work/imm/auth/node_modules/.bin/eslint_d', '--format', 'compact', '--stdin', '--stdin-filename', '__RELATIVE_TO_FOLDER__', '--config', '/home/alex/work/imm/auth/.eslintrc'] 
SublimeLinter: eslint_d output:
/home/alex/work/imm/auth/api/services/api/services/PassportService.js: line 7, col 32, Error - "../errors/ForbiddenError" is not found. (node/no-missing-require)
/home/alex/work/imm/auth/api/services/api/services/PassportService.js: line 8, col 31, Error - "../errors/BadUsageError" is not found. (node/no-missing-require)
/home/alex/work/imm/auth/api/services/api/services/PassportService.js: line 9, col 31, Error - "../errors/NotFoundError" is not found. (node/no-missing-require)
/home/alex/work/imm/auth/api/services/api/services/PassportService.js: line 11, col 27, Error - "./protocols" is not found. (node/no-missing-require)
/home/alex/work/imm/auth/api/services/api/services/PassportService.js: line 13, col 90, Error - "../constants/authEvents" is not found. (node/no-missing-require)

5 problems 

P.S. "missing" files exist and eslint dont report any errors

swarthy avatar May 31 '17 12:05 swarthy

I'm seeing this error too. Notice the repeated api/services in the path of the input files in the debug output. I think this is showing the error.

zol avatar Oct 20 '17 20:10 zol

I've modified linter.py in ~/.config/sublime-text-3/Installed Packages/SublimeLinter-contrib-eslint_d.sublime-package

linter.py

    def communicate(self, cmd, code=None):
        """Run an external executable using stdin to pass code and return its output."""

        if '__RELATIVE_TO_FOLDER__' in cmd:

            relfilename = self.filename
            window = self.view.window()
            print("relfilename 1", relfilename) # DEBUG MESSAGE HERE

            # can't get active folder, it will work only if there is one folder in project
            if int(sublime.version()) >= 3080 and len(window.folders()) < 2:

                vars = window.extract_variables()

                if 'folder' in vars:
                    relfilename = os.path.relpath(self.filename, vars['folder'])
                    print("relfilename 2", relfilename) # DEBUG MESSAGE HERE

            cmd[cmd.index('__RELATIVE_TO_FOLDER__')] = relfilename
            print("relfilename 3", relfilename) # DEBUG MESSAGE HERE
        elif not code:
            cmd.append(self.filename)

then in project with only one folder I got output:

SublimeLinter: eslint_d: index.test.js ['/home/alex/.nvm/versions/node/v9.4.0/bin/eslint_d', '--format', 'compact', '--stdin', '--stdin-filename', '__RELATIVE_TO_FOLDER__', '--config', '/home/alex/work/redis-semaphore/test/.eslintrc'] 
relfilename 1 /home/alex/work/redis-semaphore/test/unit/index.test.js
relfilename 2 test/unit/index.test.js
relfilename 3 test/unit/index.test.js
SublimeLinter: eslint_d output:
/home/alex/work/redis-semaphore/test/unit/test/unit/index.test.js: line 3, col 38, Error - "../../index" is not found. (node/no-missing-require)

1 problem 

I don't know python, so can't create PR with fix :cry: As temporary solution I add second folder in project

UPD: Node v9.4.0 OS: Ubuntu 17.10

swarthy avatar Jan 12 '18 17:01 swarthy