Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>univalNew to Visual Studio Code? Get it now.
unival

unival

pubsrc

|
502 installs
| (0) | Free
Detect duplicate keys, values, or lines on the fly within a file or a group of files.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Unival

Sanitize key-value or string files for consistency by detecting duplicate keys, values, or lines on the fly within a file or across a group of files. You can validate a file for duplicate keys, values, both keys and values or duplicate lines

Sample

sample

Documentation

Unival is a configurable extension. You can customize the default configurations by adding a unival.json file at the root directory.

To add a config file by command:

  • Open the Command Palette (Ctrl+Shift+P)
  • Enter Unival: Init command or add a unival.json file manually.

sample

A sample unival.json file is shown below

{
  "target": [
    ".properties"
  ],
  "src": ["./"],
  "delimiter": "=",
  "testBy": "keyvalue",
  "groups": [],
  "encoding": "utf-8",
  "skipLinePrefix": [
    "#"
  ],
  "whitelist":[],
  "caseSensitive": false
}

The contents of this file are explained below under documentation.

target

Here you can specify all files extensions in an array which you want to be validated by unival.
For example, to allow unival to validated .properties and .txt files, you can specify them in target array ash shown below.

"target": [
    ".properties",
    ".txt"
  ]

To validate all files set target to .*.

src

This is an array of files or directories that unival will validate.

"src": [
  "src/",
  "messages.properties"
  ]

delimiter

To validate keys, values, or both key and value for duplicates, here you can specify the delimiter. For example, if you key values are delimited by an = symbol, like: greet_guest = Welcome Guest You need to specify the delimiter as below:

"delimiter": "="

testBy

Here you can specify, if the validation for duplicates is based on key, value, both, or entire line For example to find only duplicate values in a file, you can set testBy to key as shown below

  "testBy": "value",

Other possible values for testBy are as follows: key finds duplicate keys in a file keyvalue finds duplicate keys or values in a file line finds duplicate lines in a file

groups

This property is used to group two or more files and validate them for duplicates. That means unival will validate a file for duplication if no duplicates were found it will then try to find the duplicates across all files within the same group. For example, assuming the testBy value it set to “value” and we have two files within the same group as shown below: File 1 make_payment = Make payment

File 2 pay = Make payment unival will consider Make payment as duplicate because this is same value in two files within the same group.

The groups property is an array of arrays. Each array inside the group array is list of files to be grouped together. For example To group file1.txt and file2.txt within the same group, you can specify this as shown below:

"groups": [["file.txt", "file.txt"] ] 

To group all files in directory g1 in one group and all files in directory g2 in another group, you can set groups as shown below:

"groups": [["g1/", "g2/"] ] 

Any files within the subdirectories of g1 will be considered in same group as g1

encoding

Here you can specify the encoding of your target files. The default value is utf-8

"encoding": "utf-8" 

Skip lines

You probably are going to have comments in your files or you might want to ignoring files beginning with certain strings and to do so, you can use skipLinePrefix For example to skip validation of a line that start with a # or //, you can set the skipLinePrefix property as shown below:

"skipLinePrefix": [
    "#",
    "//"
  ]

whitelist

To whitelist a set of keys or values (value or line) so that they are considered as duplicate, simply add them to whitelist. A whitelist is an array of WhiteListItem which is explained below:

{
  "src": [
    "common.properties",
    "directory/"
  ],
  "keySet": [
    "make_payment"
  ],
  "valueSet": [
    "Make payment"
  ]
}

src is an array of distinct directories or files in which we want to whitelist keys or values or lines. keySet is an array of distinct keys we want to whitelist. keySet is an array of distinct values or lines we want to whitelist.

Case sensitivity

Unival by default compares strings ignoring the case. To make unival to make case-sensitive comparisons while finding duplicates, simply set caseSensitive property to true as below.

"caseSensitive": true

License

Copyright (c) 2020-2020. Licensed under Apache License 2.0.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft