From 13502e6a929a1d4f34dba8fa3a6ac9d94ebf51b4 Mon Sep 17 00:00:00 2001 From: Kevin Orlando Date: Thu, 21 Dec 2023 21:51:06 -0500 Subject: [PATCH] change key name to settings --- .../resources/files/configs/javascript.config.yaml | 2 +- .../resources/files/configs/typescript.config.yaml | 2 +- secureli/services/language_support.py | 4 ++-- tests/services/test_language_support.py | 14 +++++++------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/secureli/resources/files/configs/javascript.config.yaml b/secureli/resources/files/configs/javascript.config.yaml index 4d4cf999..7660772b 100644 --- a/secureli/resources/files/configs/javascript.config.yaml +++ b/secureli/resources/files/configs/javascript.config.yaml @@ -1,5 +1,5 @@ filename: ".eslintrc.yaml" -data: +settings: extends: ["google"] env: es6: true diff --git a/secureli/resources/files/configs/typescript.config.yaml b/secureli/resources/files/configs/typescript.config.yaml index e711754d..85978b15 100644 --- a/secureli/resources/files/configs/typescript.config.yaml +++ b/secureli/resources/files/configs/typescript.config.yaml @@ -1,5 +1,5 @@ filename: ".eslintrc.yaml" -data: +settings: extends: ["google", "plugin:@typescript-eslint/recommended", "prettier"] parser: "@typescript-eslint/parser" plugins: ["@typescript-eslint"] diff --git a/secureli/services/language_support.py b/secureli/services/language_support.py index c573ac66..b1f0567e 100644 --- a/secureli/services/language_support.py +++ b/secureli/services/language_support.py @@ -75,7 +75,7 @@ class LinterConfigData(pydantic.BaseModel): """ filename: str - data: Any + settings: Any class LinterConfig(pydantic.BaseModel): @@ -264,7 +264,7 @@ def _write_pre_commit_configs( for config, language in linter_config_data: try: with open(Path(SecureliConfig.FOLDER_PATH / config.filename), "w") as f: - f.write(yaml.dump(config.data)) + f.write(yaml.dump(config.settings)) except: self.echo.warning( f"Failed to write {config.filename} config file for {language}" diff --git a/tests/services/test_language_support.py b/tests/services/test_language_support.py index d7532432..1d6a555d 100644 --- a/tests/services/test_language_support.py +++ b/tests/services/test_language_support.py @@ -247,7 +247,7 @@ def mock_loader_side_effect(resource): version="abc123", linter_config=LoadLinterConfigsResult( successful=True, - linter_data=[{"filename": "test.txt", "data": {}}], + linter_data=[{"filename": "test.txt", "settings": {}}], ), config_data=""" repos: @@ -281,7 +281,7 @@ def test_that_language_support_throws_exception_when_language_config_file_cannot version="abc123", linter_config=LoadLinterConfigsResult( successful=True, - linter_data=[{"filename": "test.txt", "data": {}}], + linter_data=[{"filename": "test.txt", "settings": {}}], ), config_data=""" repos: @@ -314,7 +314,7 @@ def test_that_language_support_handles_invalid_language_config( version="abc123", linter_config=LoadLinterConfigsResult( successful=True, - linter_data=[{"filename": "test.txt", "data": {}}], + linter_data=[{"filename": "test.txt", "settings": {}}], ), config_data="", ) @@ -341,7 +341,7 @@ def test_that_language_support_handles_empty_repos_list( version="abc123", linter_config=LoadLinterConfigsResult( successful=True, - linter_data=[{"filename": "test.txt", "data": {}}], + linter_data=[{"filename": "test.txt", "settings": {}}], ), config_data=""" repos: @@ -368,11 +368,11 @@ def test_write_pre_commit_configs_writes_successfully( configs = [ LinterConfig( language="RadLag", - linter_data=[LinterConfigData(filename="rad-lint.yml", data={})], + linter_data=[LinterConfigData(filename="rad-lint.yml", settings={})], ), LinterConfig( language="CoolLang", - linter_data=[LinterConfigData(filename="cool-lint.yml", data={})], + linter_data=[LinterConfigData(filename="cool-lint.yml", settings={})], ), ] language_support_service._write_pre_commit_configs(configs) @@ -406,7 +406,7 @@ def test_write_pre_commit_configs_handle_exceptions( [ LinterConfig( language=mock_language, - linter_data=[LinterConfigData(filename=mock_filename, data={})], + linter_data=[LinterConfigData(filename=mock_filename, settings={})], ), ] )