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

node/no-missing-require errors with relative paths #14

Open
swarthy opened this issue May 31, 2017 · 2 comments
Open

node/no-missing-require errors with relative paths #14

swarthy opened this issue May 31, 2017 · 2 comments

Comments

@swarthy
Copy link

swarthy commented May 31, 2017

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

@zol
Copy link

zol commented Oct 20, 2017

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.

@swarthy
Copy link
Author

swarthy commented Jan 12, 2018

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 😢
As temporary solution I add second folder in project

UPD: Node v9.4.0 OS: Ubuntu 17.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants