filetype

package
v2.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package filetype defines the supported file types and their validators.

KnownFiles are populated at init time from three sources:

  1. LinguistKnownFiles (generated from GitHub Linguist's languages.yml)
  2. extraKnownFiles (manual entries not in Linguist, e.g. .shellcheckrc)
  3. excludeKnownFiles (auto-detected conflicts with dedicated validators)

Filenames in excludeKnownFiles are skipped during population. A conflict is detected when a Linguist filename has an extension that belongs to a file type outside fileTypeRegistry (e.g. .editorconfig → EditorConfig).

Index

Constants

This section is empty.

Variables

View Source
var CsvFileType = FileType{
	Name:       "csv",
	Extensions: arrToMap("csv"),
	Validator:  validator.CsvValidator{},
}

Instance of the FileType object to represent a CSV file

View Source
var EditorConfigFileType = FileType{
	Name:       "editorconfig",
	Extensions: arrToMap("editorconfig"),
	Validator:  validator.EditorConfigValidator{},
}

Instance of the FileType object to represent an EDITORCONFIG file

View Source
var EnvFileType = FileType{
	Name:       "env",
	Extensions: arrToMap("env"),
	Validator:  validator.EnvValidator{},
}

Instance of the FileType object to represent a ENV file

View Source
var FileTypes []FileType

FileTypes contains all file types supported by the validator. Populated in init() after KnownFiles are merged from Linguist data.

View Source
var HclFileType = FileType{
	Name:       "hcl",
	Extensions: arrToMap("hcl", "tf", "tfvars"),
	Validator:  validator.HclValidator{},
}

Instance of the FileType object to represent a HCL file

View Source
var HoconFileType = FileType{
	Name:       "hocon",
	Extensions: arrToMap("hocon"),
	Validator:  validator.HoconValidator{},
}

Instance of the FileType object to represent a HOCON file

View Source
var IniFileType = FileType{
	Name:       "ini",
	Extensions: arrToMap("ini"),
	Validator:  validator.IniValidator{},
}

Instance of FileType object to represent a Ini file

View Source
var JSONCFileType = FileType{
	Name:       "jsonc",
	Extensions: arrToMap("jsonc"),
	Validator:  validator.JSONCValidator{},
}
View Source
var JSONFileType = FileType{
	Name:       "json",
	Extensions: arrToMap("json"),
	Validator:  validator.JSONValidator{},
}

Instance of the FileType object to represent a JSON file

View Source
var JustfileFileType = FileType{
	Name:       "justfile",
	Extensions: arrToMap("just"),
	KnownFiles: map[string]struct{}{
		"justfile":  {},
		"Justfile":  {},
		".justfile": {},
	},
	Validator: validator.JustfileValidator{},
}
View Source
var LinguistKnownFiles = map[string][]string{
	"ini": {
		".buckconfig",
		".coveragerc",
		".curlrc",
		".editorconfig",
		".flake8",
		".gitconfig",
		".gitmodules",
		".inputrc",
		".nanorc",
		".npmrc",
		".pylintrc",
		".wgetrc",
		"HOSTS",
		"_curlrc",
		"buildozer.spec",
		"hosts",
		"inputrc",
		"nanorc",
		"pylintrc",
		"ssh-config",
		"ssh_config",
		"sshconfig",
		"sshconfig.snip",
		"sshd-config",
		"sshd_config",
		"suite.rc",
		"vlcrc",
	},
	"json": {
		".all-contributorsrc",
		".arcconfig",
		".auto-changelog",
		".c8rc",
		".htmlhintrc",
		".imgbotconfig",
		".nycrc",
		".tern-config",
		".tern-project",
		".watchmanconfig",
		"MODULE.bazel.lock",
		"Notebook",
		"Package.resolved",
		"Pipfile.lock",
		"bun.lock",
		"composer.lock",
		"deno.lock",
		"flake.lock",
		"mcmod.info",
	},
	"jsonc": {
		".babelrc",
		".devcontainer.json",
		".eslintrc.json",
		".jscsrc",
		".jshintrc",
		".jslintrc",
		".oxlintrc.json",
		".swcrc",
		"api-extractor.json",
		"devcontainer.json",
		"jsconfig.json",
		"language-configuration.json",
		"tsconfig.json",
		"tslint.json",
	},
	"toml": {
		"Cargo.lock",
		"Cargo.toml.orig",
		"Gopkg.lock",
		"Pipfile",
		"mise.local.lock",
		"mise.lock",
		"pdm.lock",
		"poetry.lock",
		"uv.lock",
	},
	"xml": {
		".classpath",
		".cproject",
		".project",
		"App.config",
		"NuGet.config",
		"Settings.StyleCop",
		"Web.Debug.config",
		"Web.Release.config",
		"Web.config",
		"ant.xml",
		"build.xml",
		"packages.config",
		"pom.xml",
	},
	"yaml": {
		".clang-format",
		".clang-tidy",
		".clangd",
		".gemrc",
		"CITATION.cff",
		"MANIFEST.MF",
		"glide.lock",
		"pixi.lock",
		"yarn.lock",
	},
}

LinguistKnownFiles maps file type names to known filenames sourced from GitHub Linguist's languages.yml.

View Source
var PlistFileType = FileType{
	Name:       "plist",
	Extensions: arrToMap("plist"),
	Validator:  validator.PlistValidator{},
}

Instance of the FileType object to represent a Plist file

View Source
var PropFileType = FileType{
	Name:       "properties",
	Extensions: arrToMap("properties"),
	Validator:  validator.PropValidator{},
}

Instance of FileType object to represent a Properties file

View Source
var SarifFileType = FileType{
	Name:       "sarif",
	Extensions: arrToMap("sarif"),
	Validator:  validator.SarifValidator{},
}

Instance of the FileType object to represent a Sarif file

View Source
var TomlFileType = FileType{
	Name:       "toml",
	Extensions: arrToMap("toml"),
	Validator:  validator.TomlValidator{},
}

Instance of FileType object to represent a Toml file

View Source
var ToonFileType = FileType{
	Name:       "toon",
	Extensions: arrToMap("toon"),
	Validator:  validator.ToonValidator{},
}

Instance of the FileType object to represent a TOON file

View Source
var XMLFileType = FileType{
	Name:       "xml",
	Extensions: arrToMap("xml"),
	Validator:  validator.XMLValidator{},
}

Instance of FileType object to represent a XML file

View Source
var YAMLFileType = FileType{
	Name:       "yaml",
	Extensions: arrToMap("yml", "yaml"),
	Validator:  validator.YAMLValidator{},
}

Instance of the FileType object to represent a YAML file

Functions

This section is empty.

Types

type FileType

type FileType struct {
	Name       string
	Extensions map[string]struct{}
	KnownFiles map[string]struct{}
	Validator  validator.Validator
}

The FileType object stores information about a file type including name, extensions, as well as an instance of the file type's validator to be able to validate the file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL