way_of_working-code_linting-hdi 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,70 +10,73 @@ The following tables detail the linters that we are currently using:
10
10
 
11
11
  ## Languages
12
12
 
13
- | Language | Linter | Details |
14
- |:-------------|:--------------------------------------|:--------------------------------------------------------------------------------|
15
- | Bash | BASH_EXEC | [bash-exec](https://megalinter.io/latest/descriptors/bash_bash_exec/) |
16
- | Bash | BASH_SHELLCHECK | [shellcheck](https://megalinter.io/latest/descriptors/bash_shellcheck/) |
17
- | Bash | BASH_SHFMT | [shfmt](https://megalinter.io/latest/descriptors/bash_shfmt/) |
18
- | C | C_CLANG_FORMAT | [clang-format](https://megalinter.io/latest/descriptors/c_clang_format/) |
19
- | C | C_CPPLINT | [cpplint](https://megalinter.io/latest/descriptors/c_cpplint/) |
20
- | C# | CSHARP_CSHARPIER | [csharpier](https://megalinter.io/latest/descriptors/csharp_csharpier/) |
21
- | C# | CSHARP_DOTNET_FORMAT | [dotnet-format](https://megalinter.io/latest/descriptors/csharp_dotnet_format/) |
22
- | C# | CSHARP_ROSLYNATOR | [roslynator](https://megalinter.io/latest/descriptors/csharp_roslynator/) |
23
- | C++ | CPP_CLANG_FORMAT | [clang-format](https://megalinter.io/latest/descriptors/cpp_clang_format/) |
24
- | C++ | CPP_CPPLINT | [cpplint](https://megalinter.io/latest/descriptors/cpp_cpplint/) |
25
- | Clojure | ~~CLOJURE_CLJSTYLE~~ | Not Used |
26
- | Clojure | ~~CLOJURE_CLJ_KONDO~~ | Not Used |
27
- | CoffeeScript | COFFEE_COFFEELINT | [coffeelint](https://megalinter.io/latest/descriptors/coffee_coffeelint/) |
28
- | Dart | DART_DARTANALYZER | [dartanalyzer](https://megalinter.io/latest/descriptors/dart_dartanalyzer/) |
29
- | Go | GO_GOLANGCI_LINT | [golangci-lint](https://megalinter.io/latest/descriptors/go_golangci_lint/) |
30
- | Go | GO_REVIVE | [revive](https://megalinter.io/latest/descriptors/go_revive/) |
31
- | Groovy | ~~GROOVY_NPM_GROOVY_LINT~~ | Not Used |
32
- | Java | JAVA_CHECKSTYLE | [checkstyle](https://megalinter.io/latest/descriptors/java_checkstyle/) |
33
- | Java | JAVA_PMD | [pmd](https://megalinter.io/latest/descriptors/java_pmd/) |
34
- | JavaScript | JAVASCRIPT_ES | [eslint](https://megalinter.io/latest/descriptors/javascript_eslint/) |
35
- | JavaScript | ~~JAVASCRIPT_PRETTIER~~ | Not Used |
36
- | JavaScript | JAVASCRIPT_STANDARD | [standard](https://megalinter.io/latest/descriptors/javascript_standard/) |
37
- | JSX | JSX_ESLINT | [eslint](https://megalinter.io/latest/descriptors/jsx_eslint/) |
38
- | Kotlin | KOTLIN_DETEKT | [detekt](https://megalinter.io/latest/descriptors/kotlin_detekt/) |
39
- | Kotlin | KOTLIN_KTLINT | [ktlint](https://megalinter.io/latest/descriptors/kotlin_ktlint/) |
40
- | Lua | ~~LUA_LUACHECK~~ | Not Used |
41
- | Lua | ~~LUA_SELENE~~ | Not Used |
42
- | Lua | ~~LUA_STYLUA~~ | Not Used |
43
- | Makefile | MAKEFILE_CHECKMAKE | [checkmake](https://megalinter.io/latest/descriptors/makefile_checkmake/) |
44
- | Perl | ~~PERL_PERLCRITIC~~ | Not Used |
45
- | PHP | ~~PHP_PHPCS~~ | Not Used |
46
- | PHP | ~~PHP_PHPCSFIXER~~ | Not Used |
47
- | PHP | ~~PHP_PHPLINT~~ | Not Used |
48
- | PHP | ~~PHP_PHPSTAN~~ | Not Used |
49
- | PHP | ~~PHP_PSALM~~ | Not Used |
50
- | Powershell | ~~POWERSHELL_POWERSHELL~~ | Not Used |
51
- | Powershell | ~~POWERSHELL_POWERSHELL_FORMATTER~~ | Not Used |
52
- | Python | PYTHON_BANDIT | [bandit](https://megalinter.io/latest/descriptors/python_bandit/) |
53
- | Python | PYTHON_BLACK | [black](https://megalinter.io/latest/descriptors/python_black/) |
54
- | Python | PYTHON_FLAKE8 | [flake8](https://megalinter.io/latest/descriptors/python_flake8/) |
55
- | Python | PYTHON_ISORT | [isort](https://megalinter.io/latest/descriptors/python_isort/) |
56
- | Python | PYTHON_MYPY | [mypy](https://megalinter.io/latest/descriptors/python_mypy/) |
57
- | Python | PYTHON_PYLINT | [pylint](https://megalinter.io/latest/descriptors/python_pylint/) |
58
- | Python | PYTHON_PYRIGHT | [pyright](https://megalinter.io/latest/descriptors/python_pyright/) |
59
- | Python | PYTHON_RUFF | [ruff](https://megalinter.io/latest/descriptors/python_ruff/) |
60
- | R | R_LINTR | [lintr](https://megalinter.io/latest/descriptors/r_lintr/) |
61
- | Raku | ~~RAKU_RAKU~~ | Not Used |
62
- | Ruby | ~~RUBY_RUBOCOP~~ | Not Used (RuboCop is used directly) |
63
- | Rust | RUST_CLIPPY | [clippy](https://megalinter.io/latest/descriptors/rust_clippy/) |
64
- | Salesforce | ~~SALESFORCE_LIGHTNING_FLOW_SCANNER~~ | Not Used |
65
- | Salesforce | ~~SALESFORCE_SFDX_SCANNER_APEX~~ | Not Used |
66
- | Salesforce | ~~SALESFORCE_SFDX_SCANNER_AURA~~ | Not Used |
67
- | Salesforce | ~~SALESFORCE_SFDX_SCANNER_LWC~~ | Not Used |
68
- | Scala | SCALA_SCALAFIX | [scalafix](https://megalinter.io/latest/descriptors/scala_scalafix/) |
69
- | SQL | SQL_SQLFLUFF | [sqlfluff](https://megalinter.io/latest/descriptors/sql_sqlfluff/) |
70
- | SQL | SQL_TSQLLINT | [tsqllint](https://megalinter.io/latest/descriptors/sql_tsqllint/) |
71
- | Swift | SWIFT_SWIFTLINT | [swiftlint](https://megalinter.io/latest/descriptors/swift_swiftlint/) |
72
- | TSX | TSX_ESLINT | [eslint](https://megalinter.io/latest/descriptors/tsx_eslint/) |
73
- | TypeScript | TYPESCRIPT_ES | [eslint](https://megalinter.io/latest/descriptors/typescript_eslint/) |
74
- | TypeScript | ~~TYPESCRIPT_PRETTIER~~ | Not Used |
75
- | TypeScript | TYPESCRIPT_STANDARD | [ts-standard](https://megalinter.io/latest/descriptors/typescript_ts_standard/) |
76
- | VB.Net | ~~VBDOTNET_DOTNET_FORMAT~~ | Not Used |
13
+ | Language | Linter | Details |
14
+ |:-------------|:--------------------------------------|:----------------------------------------------------------------------------|
15
+ | Bash | BASH_EXEC | [bash-exec](https://megalinter.io/latest/descriptors/bash_bash_exec/) |
16
+ | Bash | BASH_SHELLCHECK | [shellcheck](https://megalinter.io/latest/descriptors/bash_shellcheck/) |
17
+ | Bash | BASH_SHFMT | [shfmt](https://megalinter.io/latest/descriptors/bash_shfmt/) |
18
+ | C | C_CLANG_FORMAT | [clang-format](https://megalinter.io/latest/descriptors/c_clang_format/) |
19
+ | C | C_CPPCHECK | [cppcheck](https://megalinter.io/latest/descriptors/c_cppcheck/) |
20
+ | C | C_CPPLINT | [cpplint](https://megalinter.io/latest/descriptors/c_cpplint/) |
21
+ | C# | ~~CSHARP_CSHARPIER~~ | Not Used |
22
+ | C# | ~~CSHARP_DOTNET_FORMAT~~ | Not Used |
23
+ | C# | ~~CSHARP_ROSLYNATOR~~ | Not Used |
24
+ | C++ | CPP_CLANG_FORMAT | [clang-format](https://megalinter.io/latest/descriptors/cpp_clang_format/) |
25
+ | C++ | CPP_CPPCHECK | [cppcheck](https://megalinter.io/latest/descriptors/cpp_cppcheck/) |
26
+ | C++ | CPP_CPPLINT | [cpplint](https://megalinter.io/latest/descriptors/cpp_cpplint/) |
27
+ | Clojure | ~~CLOJURE_CLJSTYLE~~ | Not Used |
28
+ | Clojure | ~~CLOJURE_CLJ_KONDO~~ | Not Used |
29
+ | CoffeeScript | ~~COFFEE_COFFEELINT~~ | Not Used |
30
+ | Dart | ~~DART_DARTANALYZER~~ | Not Used |
31
+ | Go | ~~GO_GOLANGCI_LINT~~ | Not Used |
32
+ | Go | ~~GO_REVIVE~~ | Not Used |
33
+ | Groovy | ~~GROOVY_NPM_GROOVY_LINT~~ | Not Used |
34
+ | Java | ~~JAVA_CHECKSTYLE~~ | Not Used |
35
+ | Java | ~~JAVA_PMD~~ | Not Used |
36
+ | JavaScript | JAVASCRIPT_ES | [eslint](https://megalinter.io/latest/descriptors/javascript_eslint/) |
37
+ | JavaScript | ~~JAVASCRIPT_PRETTIER~~ | Not Used |
38
+ | JavaScript | ~~JAVASCRIPT_STANDARD~~ | Not Used |
39
+ | JSX | ~~JSX_ESLINT~~ | Not Used |
40
+ | Kotlin | KOTLIN_DETEKT | [detekt](https://megalinter.io/latest/descriptors/kotlin_detekt/) |
41
+ | Kotlin | KOTLIN_KTLINT | [ktlint](https://megalinter.io/latest/descriptors/kotlin_ktlint/) |
42
+ | Lua | ~~LUA_LUACHECK~~ | Not Used |
43
+ | Lua | ~~LUA_SELENE~~ | Not Used |
44
+ | Lua | ~~LUA_STYLUA~~ | Not Used |
45
+ | Makefile | MAKEFILE_CHECKMAKE | [checkmake](https://megalinter.io/latest/descriptors/makefile_checkmake/) |
46
+ | Perl | ~~PERL_PERLCRITIC~~ | Not Used |
47
+ | PHP | ~~PHP_PHPCS~~ | Not Used |
48
+ | PHP | ~~PHP_PHPCSFIXER~~ | Not Used |
49
+ | PHP | ~~PHP_PHPLINT~~ | Not Used |
50
+ | PHP | ~~PHP_PHPSTAN~~ | Not Used |
51
+ | PHP | ~~PHP_PSALM~~ | Not Used |
52
+ | Powershell | ~~POWERSHELL_POWERSHELL~~ | Not Used |
53
+ | Powershell | ~~POWERSHELL_POWERSHELL_FORMATTER~~ | Not Used |
54
+ | Python | PYTHON_BANDIT | [bandit](https://megalinter.io/latest/descriptors/python_bandit/) |
55
+ | Python | PYTHON_BLACK | [black](https://megalinter.io/latest/descriptors/python_black/) |
56
+ | Python | PYTHON_FLAKE8 | [flake8](https://megalinter.io/latest/descriptors/python_flake8/) |
57
+ | Python | PYTHON_ISORT | [isort](https://megalinter.io/latest/descriptors/python_isort/) |
58
+ | Python | PYTHON_MYPY | [mypy](https://megalinter.io/latest/descriptors/python_mypy/) |
59
+ | Python | PYTHON_PYLINT | [pylint](https://megalinter.io/latest/descriptors/python_pylint/) |
60
+ | Python | PYTHON_PYRIGHT | [pyright](https://megalinter.io/latest/descriptors/python_pyright/) |
61
+ | Python | PYTHON_RUFF | [ruff](https://megalinter.io/latest/descriptors/python_ruff/) |
62
+ | Python | PYTHON_RUFF_FORMAT | [ruff-format](https://megalinter.io/latest/descriptors/python_ruff_format/) |
63
+ | R | R_LINTR | [lintr](https://megalinter.io/latest/descriptors/r_lintr/) |
64
+ | Raku | ~~RAKU_RAKU~~ | Not Used |
65
+ | Ruby | ~~RUBY_RUBOCOP~~ | Not Used (RuboCop is used directly) |
66
+ | Rust | ~~RUST_CLIPPY~~ | Not Used |
67
+ | Salesforce | ~~SALESFORCE_LIGHTNING_FLOW_SCANNER~~ | Not Used |
68
+ | Salesforce | ~~SALESFORCE_SFDX_SCANNER_APEX~~ | Not Used |
69
+ | Salesforce | ~~SALESFORCE_SFDX_SCANNER_AURA~~ | Not Used |
70
+ | Salesforce | ~~SALESFORCE_SFDX_SCANNER_LWC~~ | Not Used |
71
+ | Scala | ~~SCALA_SCALAFIX~~ | Not Used |
72
+ | SQL | SQL_SQLFLUFF | [sqlfluff](https://megalinter.io/latest/descriptors/sql_sqlfluff/) |
73
+ | SQL | SQL_TSQLLINT | [tsqllint](https://megalinter.io/latest/descriptors/sql_tsqllint/) |
74
+ | Swift | SWIFT_SWIFTLINT | [swiftlint](https://megalinter.io/latest/descriptors/swift_swiftlint/) |
75
+ | TSX | ~~TSX_ESLINT~~ | Not Used |
76
+ | TypeScript | ~~TYPESCRIPT_ES~~ | Not Used |
77
+ | TypeScript | ~~TYPESCRIPT_PRETTIER~~ | Not Used |
78
+ | TypeScript | ~~TYPESCRIPT_STANDARD~~ | Not Used |
79
+ | VB.Net | ~~VBDOTNET_DOTNET_FORMAT~~ | Not Used |
77
80
 
78
81
  ## Formats
79
82
 
@@ -81,52 +84,52 @@ The following tables detail the linters that we are currently using:
81
84
  |:-----------------|:----------------------------------|:--------------------------------------------------------------------------------------------------------|
82
85
  | CSS | CSS_STYLELINT | [stylelint](https://megalinter.io/latest/descriptors/css_stylelint/) |
83
86
  | ENV | ENV_DOTENV_LINTER | [dotenv-linter](https://megalinter.io/latest/descriptors/env_dotenv_linter/) |
84
- | GraphQL | ~~GRAPHQL_GRAPHQL_SCHEMA_LINTER~~ | Not Used |
85
- | HTML | ~~HTML_DJLINT~~ | Not Used (Refuses to see config file) |
87
+ | GraphQL | GRAPHQL_GRAPHQL_SCHEMA_LINTER | [graphql-schema-linter](https://megalinter.io/latest/descriptors/graphql_graphql_schema_linter/) |
88
+ | HTML | HTML_DJLINT | [djlint](https://megalinter.io/latest/descriptors/html_djlint/) |
86
89
  | HTML | HTML_HTMLHINT | [htmlhint](https://megalinter.io/latest/descriptors/html_htmlhint/) |
87
90
  | JSON | JSON_ESLINT_PLUGIN_JSONC | [eslint-plugin-jsonc](https://megalinter.io/latest/descriptors/json_eslint_plugin_jsonc/) |
88
91
  | JSON | JSON_JSONLINT | [jsonlint](https://megalinter.io/latest/descriptors/json_jsonlint/) |
89
92
  | JSON | JSON_NPM_PACKAGE_JSON_LINT | [npm-package-json-lint](https://megalinter.io/latest/descriptors/json_npm_package_json_lint/) |
90
- | JSON | ~~JSON_PRETTIER~~ | Not Used |
93
+ | JSON | JSON_PRETTIER | [prettier](https://megalinter.io/latest/descriptors/json_prettier/) |
91
94
  | JSON | JSON_V8R | [v8r](https://megalinter.io/latest/descriptors/json_v8r/) |
92
95
  | LaTeX | ~~LATEX_CHKTEX~~ | Not Used |
93
96
  | Markdown | MARKDOWN_MARKDOWNLINT | [markdownlint](https://megalinter.io/latest/descriptors/markdown_markdownlint/) |
94
- | Markdown | MARKDOWN_MARKDOWN_LINK_CHECK | [markdown-link-check](https://megalinter.io/latest/descriptors/markdown_markdown_link_check/) |
95
97
  | Markdown | MARKDOWN_MARKDOWN_TABLE_FORMATTER | [markdown-table-formatter](https://megalinter.io/latest/descriptors/markdown_markdown_table_formatter/) |
96
98
  | Markdown | MARKDOWN_REMARK_LINT | [remark-lint](https://megalinter.io/latest/descriptors/markdown_remark_lint/) |
97
- | Protocol Buffers | ~~PROTOBUF_PROTOLINT~~ | Not Used |
99
+ | Protocol Buffers | PROTOBUF_PROTOLINT | [protolint](https://megalinter.io/latest/descriptors/protobuf_protolint/) |
98
100
  | reStructuredText | ~~RST_RSTCHECK~~ | Not Used |
99
101
  | reStructuredText | ~~RST_RSTFMT~~ | Not Used |
100
102
  | reStructuredText | ~~RST_RST_LINT~~ | Not Used |
101
103
  | XML | XML_XMLLINT | [xmllint](https://megalinter.io/latest/descriptors/xml_xmllint/) |
102
- | YAML | ~~YAML_PRETTIER~~ | Not Used |
104
+ | YAML | YAML_PRETTIER | [prettier](https://megalinter.io/latest/descriptors/yaml_prettier/) |
103
105
  | YAML | YAML_V8R | [v8r](https://megalinter.io/latest/descriptors/yaml_v8r/) |
104
106
  | YAML | YAML_YAMLLINT | [yamllint](https://megalinter.io/latest/descriptors/yaml_yamllint/) |
105
107
 
106
108
  ## Tooling formats
107
109
 
108
- | Tooling format | Linter | Details |
109
- |:---------------|:----------------------------------|:----------------------------------------------------------------------------------------------------|
110
- | GitHub Action | ACTION_ACTIONLINT | [actionlint](https://megalinter.io/latest/descriptors/action_actionlint/) |
111
- | Ansible | ANSIBLE_ANSIBLE_LINT | [ansible-lint](https://megalinter.io/latest/descriptors/ansible_ansible_lint/) |
112
- | Api | API_SPECTRAL | [spectral](https://megalinter.io/latest/descriptors/api_spectral/) |
113
- | ARM Templates | ARM_ARM_TTK | [arm-ttk](https://megalinter.io/latest/descriptors/arm_arm_ttk/) |
114
- | Bicep | ~~BICEP_BICEP_LINTER~~ | Not Used |
115
- | CloudFormation | CLOUDFORMATION_CFN_LINT | [cfn-lint](https://megalinter.io/latest/descriptors/cloudformation_cfn_lint/) |
116
- | Dockerfile | DOCKERFILE_HADOLINT | [hadolint](https://megalinter.io/latest/descriptors/dockerfile_hadolint/) |
117
- | EditorConfig | EDITORCONFIG_EDITORCONFIG_CHECKER | [editorconfig-checker](https://megalinter.io/latest/descriptors/editorconfig_editorconfig_checker/) |
118
- | Gherkin | ~~GHERKIN_GHERKIN_LINT~~ | Not Used |
119
- | Kubernetes | KUBERNETES_HELM | [helm](https://megalinter.io/latest/descriptors/kubernetes_helm/) |
120
- | Kubernetes | KUBERNETES_KUBECONFORM | [kubeconform](https://megalinter.io/latest/descriptors/kubernetes_kubeconform/) |
121
- | Kubernetes | KUBERNETES_KUBESCAPE | [kubescape](https://megalinter.io/latest/descriptors/kubernetes_kubescape/) |
122
- | Puppet | PUPPET_PUPPET_LINT | [puppet-lint](https://megalinter.io/latest/descriptors/puppet_puppet_lint/) |
123
- | Snakemake | ~~SNAKEMAKE_LINT~~ | Not Used |
124
- | Snakemake | ~~SNAKEMAKE_SNAKEFMT~~ | Not Used |
125
- | Tekton | ~~TEKTON_TEKTON_LINT~~ | Not Used |
126
- | Terraform | TERRAFORM_TERRAFORM_FMT | [terraform-fmt](https://megalinter.io/latest/descriptors/terraform_terraform_fmt/) |
127
- | Terraform | TERRAFORM_TERRAGRUNT | [terragrunt](https://megalinter.io/latest/descriptors/terraform_terragrunt/) |
128
- | Terraform | TERRAFORM_TERRASCAN | [terrascan](https://megalinter.io/latest/descriptors/terraform_terrascan/) |
129
- | Terraform | TERRAFORM_TFLINT | [tflint](https://megalinter.io/latest/descriptors/terraform_tflint/) |
110
+ | Tooling format | Linter | Details |
111
+ |:---------------|:--------------------------------------|:-----------------------------------------------------------------------------------|
112
+ | GitHub Action | ACTION_ACTIONLINT | [actionlint](https://megalinter.io/latest/descriptors/action_actionlint/) |
113
+ | Ansible | ~~ANSIBLE_ANSIBLE_LINT~~ | Not Used |
114
+ | Api | API_SPECTRAL | [spectral](https://megalinter.io/latest/descriptors/api_spectral/) |
115
+ | ARM Templates | ARM_ARM_TTK | [arm-ttk](https://megalinter.io/latest/descriptors/arm_arm_ttk/) |
116
+ | Bicep | BICEP_BICEP_LINTER | [bicep_linter](https://megalinter.io/latest/descriptors/bicep_bicep_linter/) |
117
+ | CloudFormation | CLOUDFORMATION_CFN_LINT | [cfn-lint](https://megalinter.io/latest/descriptors/cloudformation_cfn_lint/) |
118
+ | Dockerfile | DOCKERFILE_HADOLINT | [hadolint](https://megalinter.io/latest/descriptors/dockerfile_hadolint/) |
119
+ | EditorConfig | ~~EDITORCONFIG_EDITORCONFIG_CHECKER~~ | Not Used |
120
+ | Gherkin | GHERKIN_GHERKIN_LINT | [gherkin-lint](https://megalinter.io/latest/descriptors/gherkin_gherkin_lint/) |
121
+ | Kubernetes | ~~KUBERNETES_HELM~~ | Not Used |
122
+ | Kubernetes | ~~KUBERNETES_KUBECONFORM~~ | Not Used |
123
+ | Kubernetes | ~~KUBERNETES_KUBESCAPE~~ | Not Used |
124
+ | Puppet | ~~PUPPET_PUPPET_LINT~~ | Not Used |
125
+ | Robotframework | ~~ROBOTFRAMEWORK_ROBOCOP~~ | Not Used |
126
+ | Snakemake | ~~SNAKEMAKE_LINT~~ | Not Used |
127
+ | Snakemake | ~~SNAKEMAKE_SNAKEFMT~~ | Not Used |
128
+ | Tekton | ~~TEKTON_TEKTON_LINT~~ | Not Used |
129
+ | Terraform | TERRAFORM_TERRAFORM_FMT | [terraform-fmt](https://megalinter.io/latest/descriptors/terraform_terraform_fmt/) |
130
+ | Terraform | TERRAFORM_TERRAGRUNT | [terragrunt](https://megalinter.io/latest/descriptors/terraform_terragrunt/) |
131
+ | Terraform | TERRAFORM_TERRASCAN | [terrascan](https://megalinter.io/latest/descriptors/terraform_terrascan/) |
132
+ | Terraform | TERRAFORM_TFLINT | [tflint](https://megalinter.io/latest/descriptors/terraform_tflint/) |
130
133
 
131
134
  ## Other
132
135
 
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support'
4
+
5
+ module WayOfWorking
6
+ module CodeLinting
7
+ module Hdi
8
+ module Generators
9
+ # This concern provides methods to get GitHub metadata
10
+ module GithubMetadata
11
+ extend ActiveSupport::Concern
12
+
13
+ private
14
+
15
+ def code_standards_team
16
+ 'code-standards-team'
17
+ end
18
+
19
+ def github_organisation
20
+ @github_organisation ||= begin
21
+ remote_url = `git -C #{destination_root} remote get-url origin`.strip
22
+ matchdata = remote_url.match(%r{github\.com[:/]([^/]+)/})
23
+ matchdata[1] if matchdata
24
+ end
25
+ end
26
+
27
+ def github_repo_name
28
+ @github_repo_name ||= begin
29
+ remote_url = `git -C #{destination_root} remote get-url origin`.strip
30
+ matchdata = remote_url.match(%r{github\.com[:/][^/]+/([^/]+?)(\.git)?$})
31
+ matchdata[1] if matchdata
32
+ end
33
+ end
34
+
35
+ def github_full_repo_name
36
+ "#{github_organisation}/#{github_repo_name}" if github_organisation && github_repo_name
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -14,6 +14,7 @@ module WayOfWorking
14
14
  # This class is responsible for generating linter documentation
15
15
  class DocumentLinters < Thor::Group
16
16
  include Thor::Actions # Mixin for action methods provided by Thor
17
+ include GithubMetadata
17
18
 
18
19
  # Set the source root for the templates
19
20
  source_root ::WayOfWorking::CodeLinting::Hdi.source_root
@@ -41,7 +42,7 @@ module WayOfWorking
41
42
  # Method to create the linter documentation using a template
42
43
  def create_linters_documentation
43
44
  template 'docs/way_of_working/code-linting/linters.md'
44
- copy_file 'docs/way_of_working/code-linting/index.md'
45
+ template 'docs/way_of_working/code-linting/index.md'
45
46
  end
46
47
 
47
48
  private
@@ -72,7 +73,8 @@ module WayOfWorking
72
73
 
73
74
  # Load enabled linters from the YAML config file
74
75
  def enabled_linters
75
- @enabled_linters ||= YAML.load_file('.mega-linter.yml')['ENABLE_LINTERS']
76
+ config_file = File.join(destination_root, '.mega-linter.yml')
77
+ @enabled_linters ||= File.exist?(config_file) ? YAML.safe_load_file(config_file)['ENABLE_LINTERS'] : []
76
78
  end
77
79
  end
78
80
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'thor'
4
4
  require 'way_of_working/paths'
5
+ require 'octokit'
5
6
 
6
7
  module WayOfWorking
7
8
  module CodeLinting
@@ -10,6 +11,7 @@ module WayOfWorking
10
11
  # This generator initialises the linter
11
12
  class InitLinters < Thor::Group
12
13
  include Thor::Actions
14
+ include GithubMetadata
13
15
 
14
16
  source_root ::WayOfWorking::CodeLinting::Hdi.source_root
15
17
 
@@ -38,7 +40,28 @@ module WayOfWorking
38
40
 
39
41
  CONFIG
40
42
 
41
- # TODO: copy_rubocop_github_workflow_action
43
+ def give_code_standards_team_rw_access_to_repo
44
+ return unless github_organisation && github_full_repo_name
45
+
46
+ client = octokit_client
47
+
48
+ say "Adding #{code_standards_team} team with write access to #{github_full_repo_name}..."
49
+
50
+ client.add_team_repository(
51
+ "#{github_organisation}/#{code_standards_team}",
52
+ github_full_repo_name,
53
+ permission: 'push'
54
+ )
55
+
56
+ say "Successfully granted write access to #{code_standards_team} team", :green
57
+ rescue Octokit::Error => e
58
+ say "Warning: Could not add team to repository: #{e.message}", :yellow
59
+ say 'You may need to configure this manually or ensure you have proper GitHub permissions', :yellow
60
+ end
61
+
62
+ def protect_github_linters_directory
63
+ protect_files_in_codeowners '/.github/linters/'
64
+ end
42
65
 
43
66
  def copy_github_linters_rubocop_config_file
44
67
  copy_file '.github/linters/rubocop_defaults.yml'
@@ -48,12 +71,40 @@ module WayOfWorking
48
71
  copy_file '.github/linters/.markdown-link-check.json'
49
72
  end
50
73
 
74
+ def configure_markdownlint
75
+ # We don't have these files in the repo, but we want to protect them in CODEOWNERS
76
+ protect_files_in_codeowners '.markdownlintignore', '.markdownlint.*'
77
+
78
+ prepend_to_file_if_exists 'CHANGELOG.md', "<!-- markdownlint-disable-file MD024 -->\n"
79
+ end
80
+
81
+ def configure_eslint
82
+ if javascript_files_present?
83
+ protect_and_copy_file '.eslintrc.js'
84
+
85
+ # We don't have an eslintignore file in the repo, but we want to protect it in CODEOWNERS
86
+ append_foldername_to_file_if_folder_exists '.eslintignore', 'coverage'
87
+ append_to_file '.eslintignore', "megalinter-reports/\n"
88
+ append_foldername_to_file_if_folder_exists '.eslintignore', 'node_modules'
89
+ append_foldername_to_file_if_folder_exists '.eslintignore', 'public'
90
+ append_foldername_to_file_if_folder_exists '.eslintignore', 'vendor'
91
+ protect_files_in_codeowners '.eslintignore'
92
+
93
+ run 'npm install --save-dev ' \
94
+ 'eslint-config-standard@^17.1.0 ' \
95
+ 'eslint-plugin-cypress@^3.6.0 ' \
96
+ 'eslint-plugin-jasmine@^4.2.2'
97
+ else
98
+ say 'No JavaScript files found, skipping ESLint configuration'
99
+ end
100
+ end
101
+
51
102
  def copy_megalinter_github_workflow_action
52
- copy_file '.github/workflows/mega-linter.yml'
103
+ protect_and_copy_file '.github/workflows/mega-linter.yml'
53
104
  end
54
105
 
55
106
  def copy_megalinter_dot_file
56
- copy_file '.mega-linter.yml'
107
+ protect_and_copy_file '.mega-linter.yml'
57
108
  end
58
109
 
59
110
  def create_gitignore_if_missing
@@ -69,7 +120,7 @@ module WayOfWorking
69
120
  end
70
121
 
71
122
  def copy_rubocop_options_file
72
- copy_file '.rubocop'
123
+ protect_and_copy_file '.rubocop'
73
124
  end
74
125
 
75
126
  def inject_swiftlint_into_xcode_project_build_process
@@ -86,6 +137,38 @@ module WayOfWorking
86
137
 
87
138
  private
88
139
 
140
+ def octokit_client
141
+ @octokit_client ||= begin
142
+ # Try to use GITHUB_TOKEN environment variable, or let Octokit use netrc
143
+ token = ENV.fetch('GITHUB_TOKEN', nil)
144
+ Octokit::Client.new(access_token: token)
145
+ end
146
+ end
147
+
148
+ def prepend_to_file_if_exists(file, content)
149
+ file_path = File.join(destination_root, file)
150
+
151
+ prepend_to_file file, content if File.exist?(file_path)
152
+ end
153
+
154
+ def append_foldername_to_file_if_folder_exists(file, foldername)
155
+ folder_path = File.join(destination_root, foldername)
156
+
157
+ append_to_file file, "#{foldername}\n" if File.directory?(folder_path)
158
+ end
159
+
160
+ def protect_and_copy_file(file)
161
+ protect_files_in_codeowners(file)
162
+ copy_file(file)
163
+ end
164
+
165
+ def javascript_files_present?
166
+ Dir.glob(File.join(destination_root, '**/*.{js,jsx,mjs,cjs}')).
167
+ reject { |file| file.end_with?('.eslintrc.js') }.
168
+ reject { |file| file.include?('/megalinter-reports/') }.
169
+ any?
170
+ end
171
+
89
172
  def xcode_project_file
90
173
  Dir.glob(File.join(destination_root, '*.xcodeproj/project.pbxproj')).first
91
174
  end
@@ -96,6 +179,27 @@ module WayOfWorking
96
179
 
97
180
  File.open(path, 'w', &:write)
98
181
  end
182
+
183
+ def codeowners_file_path
184
+ ['.github/CODEOWNERS', 'CODEOWNERS', 'docs/CODEOWNERS'].each do |path|
185
+ full_path = File.join(destination_root, path)
186
+ return full_path if File.exist?(full_path)
187
+ end
188
+ File.join(destination_root, '.github/CODEOWNERS')
189
+ end
190
+
191
+ def protect_files_in_codeowners(*files)
192
+ return unless github_organisation
193
+
194
+ codeowners_path = codeowners_file_path
195
+ create_file(codeowners_path) unless File.exist?(codeowners_path)
196
+
197
+ owner = "@#{github_organisation}/#{code_standards_team}"
198
+
199
+ files.each do |file|
200
+ append_to_file codeowners_path, "#{file} #{owner}\n"
201
+ end
202
+ end
99
203
  end
100
204
  end
101
205
  end
@@ -1 +1,13 @@
1
1
  require 'way_of_working/code_linting/hdi'
2
+
3
+ # Add any plug specific code here
4
+
5
+ module WayOfWorking
6
+ module CodeLinting
7
+ module Hdi
8
+ # This makes zeitwerk happy, which makes us happy too
9
+ module Plugin
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ module.exports = {
2
+ extends: ['standard'],
3
+ plugins: ['cypress', 'jasmine'],
4
+ overrides: [
5
+ {
6
+ // Cypress test files
7
+ files: ['**/*.cy.js'],
8
+ env: {
9
+ 'cypress/globals': true
10
+ }
11
+ },
12
+ {
13
+ // Jasmine test files
14
+ files: ['**/*_spec.js'],
15
+ env: {
16
+ jasmine: true
17
+ }
18
+ }
19
+ ]
20
+ }
@@ -1,13 +1,13 @@
1
1
  {
2
- "ignorePatterns": [
3
- {
4
- "pattern": "^0005-example.md"
5
- },
6
- {
7
- "pattern": "^adr-template.md"
8
- }
9
- ],
10
- "retryOn429": true,
11
- "retryCount": 5,
12
- "aliveStatusCodes": [ 200, 203 ]
2
+ "ignorePatterns": [
3
+ {
4
+ "pattern": "^0005-example.md"
5
+ },
6
+ {
7
+ "pattern": "^adr-template.md"
8
+ }
9
+ ],
10
+ "retryOn429": true,
11
+ "retryCount": 5,
12
+ "aliveStatusCodes": [200, 203]
13
13
  }