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

Remove Prettier ignore_patterns_re #223

Merged
merged 1 commit into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion c2cciutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def get_config() -> c2cciutils.configuration.Configuration:
},
"classifiers": ["Typing :: Typed"],
},
"prettier": {"ignore_patterns_re": []},
"prettier": {},
},
"audit": {
"print_versions": {
Expand Down
39 changes: 16 additions & 23 deletions c2cciutils/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,41 +1140,34 @@ def prettier(
Run prettier check on all the supported files.

config is like:
ignore_patterns_re: [] # list of regular expression we should ignore
# Currently empty

Arguments:
config: The config
full_config: The full config
args: The parsed command arguments
"""
del full_config
del config, full_config

ignore_patterns_compiled = [re.compile(p) for p in config.get("ignore_patterns_re", [])]
success = True

with c2cciutils.prettier.Prettier() as prettier_lib:
for filename in subprocess.check_output(["git", "ls-files"]).decode().strip().split("\n"):
if os.path.isfile(filename):
accept = True
for pattern in ignore_patterns_compiled:
if pattern.search(filename):
accept = False
break
if accept:
info = prettier_lib.get_info(filename)
if info.get("info", {}).get("ignored", False):
continue
if not info.get("info", {}).get("inferredParser"):
continue
prettier_config = info["config"]
prettier_config["parser"] = info["info"]["inferredParser"]

if args.fix:
if not prettier_lib.format(filename, prettier_config):
success = False
else:
if not prettier_lib.check(filename, prettier_config):
success = False
info = prettier_lib.get_info(filename)
if info.get("info", {}).get("ignored", False):
continue
if not info.get("info", {}).get("inferredParser"):
continue
prettier_config = info["config"]
prettier_config["parser"] = info["info"]["inferredParser"]

if args.fix:
if not prettier_lib.format(filename, prettier_config):
success = False
else:
if not prettier_lib.check(filename, prettier_config):
success = False
return success


Expand Down
2 changes: 0 additions & 2 deletions c2cciutils/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,6 @@
"ChecksPrettierConfig",
{
"properties": Dict[str, Any],
# List of regular expression that should be ignored
"ignore_patterns_re": List[str],
},
total=False,
)
Expand Down
5 changes: 0 additions & 5 deletions c2cciutils/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@
"properties": {
"properties": {
"type": "object"
},
"ignore_patterns_re": {
"description": "List of regular expression that should be ignored",
"type": "array",
"items": { "type": "string" }
}
}
},
Expand Down