Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@adeira/flow-config-parser

Package Overview
Dependencies
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adeira/flow-config-parser

Permissive Flow config parser.

  • 0.3.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

Permissive Flow config parser.

yarn add @adeira/flow-config-parser

Supported functions

parse

Parse function doesn't do any magic. It simply takes the .flowconfig as a first argument and returns object with the config values:

import { parse } from '@adeira/flow-config-parser';

parse(`
[version]
>=0.138.0 <0.140.0
`);

Returns:

{
  "declarations": [],
  "ignore": [],
  "include": [],
  "libs": [],
  "lints": null,
  "options": null,
  "rollouts": null,
  "strict": [],
  "untyped": [],
  "version": ">=0.138.0 <0.140.0"
}

merge

Merge functions merges two configs together and returns the final config:

const configA = `
  [options]
  emoji=true
  module.file_ext=.foo
  module.file_ext=.bar
`;

const configB = `
  [options]
  emoji=false
  module.file_ext=.baz
  munge_underscores=false
`;

merge(configA, configB);

Returns:

# ...

[options]
emoji=false
module.file_ext=.foo
module.file_ext=.bar
module.file_ext=.baz
munge_underscores=false

# ...

print

Print function takes the parsed config and prints it into .flowconfig format:

const parsedConfig = parse(' … '); // original config
print(parsedConfig);

Caveats

This parser supports [rollouts] parsing only partially. Specifically, it omits rollout annotations when parsing. So for example, this config:

[rollouts]
formed_exports=80% on, 20% off

[options]
(formed_exports=on) experimental.well_formed_exports=true

Returns the following object after being parsed (notice the missing (formed_exports=on)):

{
  "declarations": [],
  "ignore": [],
  "include": [],
  "libs": [],
  "lints": null,
  "options": {
    "experimental.well_formed_exports": true
  },
  "rollouts": {
    "formed_exports": "80% on, 20% off"
  },
  "strict": [],
  "untyped": [],
  "version": null
}

It's because we didn't implement the options merging (on purpose). Rollouts seem to be quite internal and not very often used. However, we might change this if there is a real interest.

FAQs

Package last updated on 20 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc