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

No lint results with .tsx files (Refined GitHub) #26

Open
darkred opened this issue Apr 19, 2021 · 7 comments
Open

No lint results with .tsx files (Refined GitHub) #26

darkred opened this issue Apr 19, 2021 · 7 comments

Comments

@darkred
Copy link
Contributor

darkred commented Apr 19, 2021

Greetings

I've been trying to make the plugin work with Refined GitHub's .tsx files without success.

 
First of all, according to this repo, in here it says:

xo will only lint *.js files for standard, vanilla config without further plugins.

and

Using non-JS syntax

Typical plugins for ESLint, for example, for TypeScript or Vue, should just work automatically if they're installed locally in your project (defined in the same package.json).

 
Also, according to the xo repo, in there it says:

TypeScript

XO will automatically lint TypeScript files (.ts, .d.ts and .tsx)
with the rules defined in eslint-config-xo-typescript#use-with-xo.

XO will handle the @typescript-eslint/parser project option automatically
even if you don't have a tsconfig.json in your project.


Here is what I have tried:

  • Regarding Refined GitHub I did:

    git clone https://github.com/sindresorhus/refined-github
    cd refined-github
    npm install
    

    NOTE: xo is contained in Refined GitHub package.json's devDependencies, and so it's installed locally in the npm install step (i.e. besides my global installation of xo)

  • Then I installed locally the TypeScript ESLint Parser via npm i --save-dev typescript @typescript-eslint/parser

  • finally I added the following to the .xo-config.json (located inside the refined-github folder) :

	"parser": "@typescript-eslint/parser",
	"parserOptions": {
		"ecmaVersion": 2021,
		"sourceType": "module",
		"ecmaFeatures": {
			"jsx": true
		}
	},

Unfortunately, no errors are highlighted in any tsx file - I only get No lint results in SublimeLinter' output, e.g.:
2021-04-19_174148

 
My configuration:

  • Sublime Text 3.2.2 build 3211 x64 on Windows 10
  • SublimeLinter 4.16.2
  • SublimeLinter-contrib-xo 3.2.2
  • (SublimeLinter-eslint remains disabled)
  • Node 15.4.0 x64
  • xo 0.38.2 (installed globally)
  • TypeScript 4.2.4 (installed globally)

Thank you

@darkred
Copy link
Contributor Author

darkred commented Apr 20, 2021

Using the selector setting in SublimeLinter fixes the issue:

	"linters": {
		"xo": {
			"selector": "source.tsx, meta.import.tsx, keyword.control.import.tsx"
		}
	}
}

Sorry for the noise.

@darkred darkred closed this as completed Apr 20, 2021
sindresorhus added a commit that referenced this issue Apr 20, 2021
@sindresorhus
Copy link
Member

This is a valid issue. I added support for TSX in bbe02a9, but it seems like it still doesn't work because of

self.ensure_plugin_installed()

When I comment that out, linting works. It seems the project root detection is faulty.

// @kaste

@kaste
Copy link
Contributor

kaste commented Apr 20, 2021

I left a comment on the commit.

@sindresorhus
Copy link
Member

Yeah, I reverted that commit.

@kaste
Copy link
Contributor

kaste commented Apr 20, 2021

Just reverted? Shouldn't this line read

'@typescript-eslint/parser': 'source.ts, source.tsx',

@sindresorhus
Copy link
Member

Shouldn't this line read

Yup, but there's still the issue of

self.ensure_plugin_installed()

@kaste
Copy link
Contributor

kaste commented Apr 20, 2021

Yeah, could be, but then ensure_plugin_installed() is a 30 line method, you sure can tell where it breaks. For example, is project_root defined here...

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

No branches or pull requests

3 participants