toml-eslint-parser
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -211,3 +211,2 @@ "use strict"; | ||
} | ||
// eslint-disable-next-line complexity -- ignore | ||
DATA(cp) { | ||
@@ -214,0 +213,0 @@ while (code_point_1.isWhitespace(cp) || code_point_1.isEOL(cp)) { |
{ | ||
"name": "toml-eslint-parser", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "A TOML parser that produces output compatible with ESLint", | ||
@@ -42,3 +42,3 @@ "main": "lib/index.js", | ||
"@iarna/toml": "^3.0.0", | ||
"@ota-meshi/eslint-plugin": "^0.0.6", | ||
"@ota-meshi/eslint-plugin": "^0.0.10", | ||
"@types/eslint": "^7.2.0", | ||
@@ -49,2 +49,3 @@ "@types/eslint-visitor-keys": "^1.0.0", | ||
"@types/node": "^14.0.13", | ||
"@types/semver": "^7.3.4", | ||
"@typescript-eslint/eslint-plugin": "^4.9.1", | ||
@@ -56,5 +57,6 @@ "@typescript-eslint/parser": "^4.9.1", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"eslint-plugin-jsonc": "^0.7.1", | ||
"eslint-plugin-jsonc": "^0.8.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^3.2.0", | ||
"eslint-plugin-regexp": "^0.1.1", | ||
"eslint-plugin-vue": "^7.2.0", | ||
@@ -65,2 +67,3 @@ "js-yaml": "^4.0.0", | ||
"prettier": "^2.0.5", | ||
"semver": "^7.3.4", | ||
"ts-node": "^8.10.2", | ||
@@ -67,0 +70,0 @@ "typescript": "^3.9.7", |
@@ -25,2 +25,6 @@ # toml-eslint-parser | ||
> **Requirements** | ||
> | ||
> - Node.js v8.10.0 and above | ||
## Usage | ||
@@ -51,2 +55,90 @@ | ||
## Usage for Directly | ||
Example: | ||
```ts | ||
import type { AST } from "toml-eslint-parser" | ||
import { parseTOML, getStaticTOMLValue } from "toml-eslint-parser" | ||
const code = ` | ||
# This is a TOML document | ||
title = "TOML Example" | ||
[owner] | ||
name = "Tom Preston-Werner" | ||
dob = 1979-05-27T07:32:00-08:00 | ||
[database] | ||
enabled = true | ||
ports = [ 8001, 8001, 8002 ] | ||
data = [ ["delta", "phi"], [3.14] ] | ||
temp_targets = { cpu = 79.5, case = 72.0 } | ||
[servers] | ||
[servers.alpha] | ||
ip = "10.0.0.1" | ||
role = "frontend" | ||
[servers.beta] | ||
ip = "10.0.0.2" | ||
role = "backend" | ||
` | ||
const ast: AST.TOMLProgram = parseTOML(code) | ||
console.log(ast) | ||
// { | ||
// type: 'Program', | ||
// body: [ | ||
// { | ||
// type: 'TOMLTopLevelTable', | ||
// body: [ | ||
// { | ||
// type: 'TOMLKeyValue', | ||
// key: { /* ... */ }, | ||
// value: { /* ... */ }, | ||
// /* ... */ | ||
// }, | ||
// { | ||
// type: 'TOMLTable', | ||
// kind: 'standard', | ||
// key: { /* ... */ }, | ||
// body: [ /* ... */ ], | ||
// /* ... */ | ||
// }, | ||
// /* ... */ | ||
// ] | ||
// /* ... */ | ||
// } | ||
// ], | ||
// tokens: [ /* ... */ ], | ||
// comments: [ | ||
// { | ||
// type: 'Block', | ||
// value: ' This is a TOML document', | ||
// // ... | ||
// } | ||
// ], | ||
// } | ||
const value = getStaticTOMLValue(ast) | ||
console.log(value) | ||
// { | ||
// title: 'TOML Example', | ||
// owner: { name: 'Tom Preston-Werner', dob: 1979-05-27T15:32:00.000Z }, | ||
// database: { | ||
// enabled: true, | ||
// ports: [ 8001, 8001, 8002 ], | ||
// data: [ [ /* ... */ ], [ /* ... */ ] ], | ||
// temp_targets: { cpu: 79.5, case: 72 } | ||
// }, | ||
// servers: { | ||
// alpha: { ip: '10.0.0.1', role: 'frontend' }, | ||
// beta: { ip: '10.0.0.2', role: 'backend' } | ||
// } | ||
// } | ||
``` | ||
## Testing | ||
@@ -53,0 +145,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
113996
153
27
3136