eslint-plugin-yml
eslint-plugin-yml copied to clipboard
[improvement request] detect template strings
Many templating frameworks that interpolate yaml depend on {{ foo }} syntax to define directives, e.g.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
finalizers:
- resources-finalizer.argocd.argoproj.io
name: contra-web-review-storybook-$DEPLOYMENT_SLUG
namespace: argocd
spec:
destination:
namespace: default
server: {{ .Values.spec.destination.server | quote }}
In these cases, eslint-plugin-yml will produce the following errors:
/Users/gajus/Documents/dev/contra/contra-web-app/bin/contra-web-app-review-template.yaml
11:14 error Empty mapping values are forbidden yml/no-empty-mapping-value
11:14 error The key must be a string yml/require-string-key
11:15 error Empty mapping values are forbidden yml/no-empty-mapping-value
It would be desirable to have an option to recognize this special syntax and treat it as a string literal.
I think it's good if it's possible, but I think it's difficult if there is no parser that can parse it well.
This specific problem is a non-issue b/c I can replace
server: {{ .Values.spec.destination.server | quote }}
with
server: '{{ .Values.spec.destination.server }}'
However, the one that I cannot figure out a workaround for is this one:
apiVersion: v1
kind: Service
metadata:
labels:
{{- include "app.resource_labels" . | indent 4}}
name: '{{.Release.Name}}'
spec:
ports:
- name: industry-report-2021-web-app
port: 80
protocol: TCP
targetPort: 80
selector:
{{- include "app.selector_labels" . | indent 4}}