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

Throw an error if run on an ignored file #366

Closed

Conversation

Norris1z
Copy link

@Norris1z Norris1z commented Jan 13, 2019

This PR fixes #238 and it throws an error if you call xo on a single file which is ignored.

@Norris1z Norris1z force-pushed the display_an_error_if_run_on_an_ignored_file branch from bf50b0c to 51dcdda Compare January 22, 2019 08:31
@Norris1z
Copy link
Author

@sindresorhus should it throw an error or a console.error with a process.exit

@sindresorhus
Copy link
Member

This change needs tests.

@sindresorhus
Copy link
Member

You're missing #238 (comment)

@sindresorhus
Copy link
Member

The ignore option is also not the only way a file could be ignored. There's also the default ignore patterns and .gitignore.

cli-main.js Outdated
@@ -138,6 +139,22 @@ const log = report => {
process.exit(report.errorCount === 0 ? 0 : 1);
};

const throwIfFileIsIgnored = file => {
if (input.includes(file)) {
throw new Error('You cannot run xo on an ignored file');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error should mention the file path.

@sindresorhus
Copy link
Member

should it throw an error or a console.error with a process.exit

console.error and process.exit

@Norris1z
Copy link
Author

@sindresorhus I had to modify a test to get this to work because this pr changes the behaviour of that test.
ignore explicit files when in .gitgnore was asserting that explicit files ignored in the .gitignore will be ignored silently whereas this pr outputs an error.

Also i think #238 (comment) has already been taken care of because the input array holds all files that match the glob pattern when a glob is specified rather than a direct file.

@sindresorhus sindresorhus force-pushed the master branch 2 times, most recently from 9bbe1bf to 2ab0a69 Compare May 25, 2019 08:31
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit

Base automatically changed from master to main January 24, 2021 05:47
@fregante
Copy link
Member

fregante commented Aug 6, 2022

Given the age I'm going to close this PR, but it's definitely still a welcome change. Please open a new PR if you intend to work on it again ☺️

@fregante fregante closed this Aug 6, 2022
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

Successfully merging this pull request may close these issues.

Show error if run on a single file that's ignored
3 participants