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

How to check code inside php files? #965

Closed
wowcut opened this issue Aug 7, 2017 · 4 comments

Comments

@wowcut
Copy link

commented Aug 7, 2017

I found the hint about eslint-plugin-html in the readme, however I would like to check code inside some php files and did not find anything similar - using eslint-plugin-html does not work for php files, it unfortunately produces parsing errors.

Yes, I know JS in PHP files is a very bad practice - this is a legacy code base and that is why I would love to fix all the JS inside all files with standard --fix *.php.

@bcomnes

This comment has been minimized.

Copy link
Member

commented Aug 7, 2017

Not sure, but I would broaden the search to see if anyone has gotten eslint looking inside PHP files.

@wowcut

This comment has been minimized.

Copy link
Author

commented Aug 8, 2017

Yes, I see there are overlapping responsibilities with this use case and it is not totally clear where it should be handled - why should a JS linter take care of PHP tags? Also PHP tags in JS are simply syntax errors, so eslint does the right thing to report them as syntax errors.

But fixing things is sometimes done in situations where people did not care about standards or even correct syntax (unfortunately), so I feel like a solution for this kind of problem might have a place here, but I am not sure - I am just asking, not arguing.

I just found eslint-plugin-exclude-php-tags and will try to use this with standard - I will report back if it helps me in my specific case which involves fixing that bad practice of 'PHP tags inside JS inside PHP files with HTML and JS' - a horrible scenario, believe me! But ignoring PHP tags is not what I really want - I would like to have it fixed.

Otherwise I will try some sed to fix that mess, but it would be really nice to have stabdard handle it .

@bcomnes

This comment has been minimized.

Copy link
Member

commented Aug 8, 2017

Unfortunately you might have to put a custom eslint stack together, using the shareable configs directly. But yeah, if you find a way to do it we could add it to the FAQ.

@Flet

This comment has been minimized.

Copy link
Member

commented Nov 7, 2017

I think @bcomnes is right; This will need to be done with eslint directly (with eslint-config-standard) since its such a particular use case.

I'm closing this issue for now. If you have questions on or need further advice please feel free to reply to the thread!

@Flet Flet closed this Nov 7, 2017

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
3 participants
You can’t perform that action at this time.