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

baseDir should be an absolute path #202

Closed
stephen-hardy opened this issue Feb 8, 2017 · 11 comments
Closed

baseDir should be an absolute path #202

stephen-hardy opened this issue Feb 8, 2017 · 11 comments
Labels
info-needed Issue requires more information from poster

Comments

@stephen-hardy
Copy link

When opening a JavaScript file hosted on SharePoint, accessed on Windows via WebDav, I get the following error on load and every time I type:

"baseDir should be an absolute path"

I don't think I saw this before v1.2.4. Everything was working well, until a couple days ago. Is this a configuration issue?

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Feb 9, 2017
@dbaeumer
Copy link
Member

dbaeumer commented Feb 9, 2017

ESLint has no configuration property baseDir, but TypeScript has which provides the JS smartness in VS Code.

Does this happen if you disable ESLint for the workspace? Which version of VS Code are you using?

@stephen-hardy
Copy link
Author

Hi, thanks for the reply!

I just updated to 1.9.1 this morning, and the issue persists. I'm still getting to know VSCode, having switched from Sublime, but I don't believe I can disable ESLint for the workspace because I'm not opening a folder - just a file. However, I tried disabling the extension altogether. When I did that, the error went away. When I re-enabled the extension, it came back.

I used to get errors and warnings, but now it is just 0 and 0. And, the "ESLint" on the right side in the status bar is greyed out. When I open the OUTPUT for ESLint I see:

[Info - 9:57:31 AM] ESLint server is running.
[Info - 9:57:33 AM] ESLint library loaded from: C:\Users\v-sthard\AppData\Roaming\npm\node_modules\eslint\lib\api.js

Also, it may be worth noting that this started happening days after I upgraded to v1.9.0 of VSCode. It worked well for a number of days, then stopped with the last two updates to ESLint.

Let me know if I can provide any other logs or diagnostic information.

Thanks,
Stephen

@dbaeumer
Copy link
Member

@stephen-hardy can you provide me a little more information about you setup:

  • which eslint version do you have installed
  • how does your eslintrc file look like
  • can you provide me with the content of the JS file you are validating

And could you enable eslint tracing to get more information. To do so please set the user settings "eslint.trace.server": "verbose" and attach the output of ESLint channel here.

@dbaeumer
Copy link
Member

@stephen-hardy I think I know what is going on. How does the path of the file look like. Is it a UNC path or is the server directory mounted as a drive letter?

@dbaeumer
Copy link
Member

dbaeumer commented Feb 10, 2017

In noder path.isAbsolute('\\192.168.1.2\folder\test.txt')evaluates to true. But I guess that the path you are using is not consider an absolute path hence resulting in an exception in this piece of ESLint code from path-util.js:

function getRelativePath(filepath, baseDir) {
    let relativePath;

    if (!path.isAbsolute(filepath)) {
        filepath = path.resolve(filepath);
    }
    if (baseDir) {
        if (!path.isAbsolute(baseDir)) {
            throw new Error("baseDir should be an absolute path");
        }
        relativePath = path.relative(baseDir, filepath);
    } else {
        relativePath = filepath.replace(/^\//, "");
    }
    return relativePath;
}

The change in ESLint that causes the problem is:

} else if (!workspaceRoot) {
	let dirname = path.dirname(file);
	if (dirname) {
		newOptions.cwd = dirname;
	}
}

@stephen-hardy
Copy link
Author

stephen-hardy commented Feb 10, 2017

Correct, the file does have a UNC path:

\\microsoft.sharepoint.com@SSL\DavWWWRoot\teams...

I'm currently on version 1.2.5, and a blank js file will cause the error.

@dbaeumer
Copy link
Member

Thanks. What is wired is that path.isAbsolute('\\microsoft.sharepoint.com@SSL\DavWWWRoot') evaluates to true. @stephen-hardy can you sent me the full path to my MS email address. Then I can have a look and see why this fails.

@stephen-hardy
Copy link
Author

Done!

Using a mapped drive works, just in case anybody is looking for a workaround. But then, unfortunately, TypeScript breaks (I opened the issue referenced directly above). So, if you want TypeScript you can open the file directly (as of VSCode 1.9.1), or if you want ESLint you can map a drive.

@dbaeumer
Copy link
Member

OK. The underlying problem is that
path.dirname('\\microsoft.sharepoint.com@SSL\DavWWWRoot\teams\myteam\myFile.js') returns \\ which is clearly not the directory containing the file. Need to see how I best handle this.

@stephen-hardy what error do you get with TS on a mapped network drive.

@stephen-hardy
Copy link
Author

Best described here: microsoft/TypeScript#13997

@stephen-hardy
Copy link
Author

Also, just wanted to confirm that this is fixed. Finally, TypeScript and ESLint working using the same method. :) Thanks for all your help!

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants