New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flow-annotation-check

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flow-annotation-check - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

67

lib/cli.js

@@ -8,4 +8,10 @@ 'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _findPackageJson = require('find-package-json');
var _findPackageJson2 = _interopRequireDefault(_findPackageJson);
var _flowAnnotationCheck = require('./flow-annotation-check');
var _flowAnnotationCheck2 = _interopRequireDefault(_flowAnnotationCheck);
var _package = require('../package.json');

@@ -21,7 +27,16 @@

var _flowAnnotationCheck = require('./flow-annotation-check');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _flowAnnotationCheck2 = _interopRequireDefault(_flowAnnotationCheck);
var DEFAULT_FLAGS = {
absolute: false,
allow_weak: false,
exclude: ['+(node_modules|build|flow-typed)/**/*.js'],
flow_path: 'flow',
include: ['**/*.js'],
root: '.'
};
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function printDefault(value) {
return '(default: `' + JSON.stringify(value) + '`)';
}

@@ -36,19 +51,19 @@ function getParser() {

action: 'store',
help: 'The path to the flow command. (default: `flow`)'
help: 'The path to the flow command. ' + printDefault(DEFAULT_FLAGS.flow_path)
});
parser.addArgument(['-a', '--absolute'], {
action: 'storeTrue',
help: 'Report absolute path names. (default: false)'
help: 'Report absolute path names. ' + printDefault(DEFAULT_FLAGS.absolute)
});
parser.addArgument(['--allow-weak'], {
action: 'storeTrue',
help: 'Consider `@flow weak` as a accepable annotation. See https://flowtype.org/docs/existing.html#weak-mode for reasons why this should only be used temporarily. (default: false)'
help: 'Consider `@flow weak` as a accepable annotation. See https://flowtype.org/docs/existing.html#weak-mode for reasons why this should only be used temporarily. ' + printDefault(DEFAULT_FLAGS.allow_weak)
});
parser.addArgument(['-i', '--include'], {
action: 'append',
help: 'Glob for files to include. Can be set multiple times. (default: `**/*.js`)'
help: 'Glob for files to include. Can be set multiple times. ' + printDefault(DEFAULT_FLAGS.include)
});
parser.addArgument(['-x', '--exclude'], {
action: 'append',
help: 'Glob for files to exclude. Can be set multiple times. (default: `node_modules/**/*.js`)'
help: 'Glob for files to exclude. Can be set multiple times. ' + printDefault(DEFAULT_FLAGS.exclude)
});

@@ -61,3 +76,3 @@ parser.addArgument(['--validate'], {

defaultValue: '.',
help: 'The root directory to glob files from. (default: `.`)',
help: 'The root directory to glob files from. ' + printDefault(DEFAULT_FLAGS.root),
nargs: '?'

@@ -69,11 +84,26 @@ });

function resolveArgs(args) {
return _extends({}, args, {
exclude: args.exclude || ['node_modules/**/*.js'],
flow_path: args.flow_path || 'flow',
include: args.include || ['**/*.js'],
root: _path2.default.resolve(args.root || '.')
});
function getPackageJsonArgs(root, defaults) {
var finder = (0, _findPackageJson2.default)(_path2.default.resolve(root || defaults.root));
var it = finder.next();
while (!it.done) {
var pkg = it.value;
if (pkg && pkg['flow-annotation-check']) {
return resolveArgs(pkg['flow-annotation-check'], defaults);
}
it = finder.next();
}
return defaults;
}
function resolveArgs(args, defaults) {
return {
absolute: args.absolute || defaults.absolute,
allow_weak: args.allow_weak || defaults.allow_weak,
exclude: args.exclude || defaults.exclude,
flow_path: args.flow_path || defaults.flow_path,
include: args.include || defaults.include,
root: _path2.default.resolve(args.root || defaults.root)
};
}
function main(flags) {

@@ -144,3 +174,4 @@ var command = flags.validate ? 'validate' : 'report';

function run() {
main(resolveArgs(getParser().parseArgs()));
var parsed = getParser().parseArgs();
main(resolveArgs(parsed, getPackageJsonArgs(parsed.root, DEFAULT_FLAGS)));
}

@@ -147,0 +178,0 @@

@@ -95,3 +95,3 @@ 'use strict';

stderr = _ref3.stderr;
return JSON.parse(stdout);
return JSON.parse(String(stdout));
});

@@ -98,0 +98,0 @@ }).then(function (checkResult) {

{
"name": "flow-annotation-check",
"version": "1.1.2",
"version": "1.2.0",
"description": "Check your files for the presence of the `@flow` and `@flow weak` annotations",

@@ -33,2 +33,3 @@ "author": {

"babel-plugin-transform-object-rest-spread": "^6.20.2",
"find-package-json": "^1.0.0",
"glob": "7.1.1"

@@ -40,13 +41,18 @@ },

"babel-preset-latest": "^6.16.0",
"flow-bin": "^0.37.4",
"flow-typed": "^2.0.0",
"jest": "18.0.0"
"flow-bin": "^0.45.0",
"flow-coverage-report": "^0.3.0",
"flow-typed": "^2.1.1",
"jest": "19.0.0"
},
"scripts": {
"preversion": "npm run test && npm run transpile",
"pretest": "npm run flow",
"preversion": "npm run clean && npm run test && npm run transpile",
"postversion": "git push && git push --tags && npm publish",
"pretest": "npm run flow:check && npm run flow:annotations && npm run flow:coverage",
"test": "npm run jest",
"prebuild": "npm run flow && npm run jest",
"prebuild": "npm run clean && npm run test",
"build": "npm run transpile",
"flow": "flow check && flow check ./src/__tests__/fixtures",
"clean": "rm -Rf npm-debug.log lib flow-coverage",
"flow:check": "flow check && flow check ./src/__tests__/fixtures",
"flow:annotations": "npm run transpile && bin/flow-annotation-check.js",
"flow:coverage": "flow-coverage-report report",
"jest": "jest",

@@ -65,4 +71,23 @@ "transpile": "rm -Rf lib/* && babel src --out-dir lib --ignore __tests__",

},
"flow-annotation-check": {
"include": [
"src/**/*.js"
],
"exclude": [
"src/__tests__/fixtures/comment-blocks-10.js",
"src/__tests__/fixtures/comment-statement-10.js",
"src/__tests__/fixtures/no-comments.js"
]
},
"flow-coverage-report": {
"includeGlob": [
"src/**/*.js"
],
"type": [
"text",
"html"
]
},
"jest": {
"testPathDirs": [
"roots": [
"src"

@@ -69,0 +94,0 @@ ],

@@ -1,3 +0,5 @@

# flow-annotation-check [![Build Status](https://travis-ci.org/ryan953/flow-annotation-check.svg?branch=master)](https://travis-ci.org/ryan953/flow-annotation-check)
# flow-annotation-check
[![Build Status](https://travis-ci.org/ryan953/flow-annotation-check.svg?branch=master)](https://travis-ci.org/ryan953/flow-annotation-check) [![Greenkeeper badge](https://badges.greenkeeper.io/ryan953/flow-annotation-check.svg)](https://greenkeeper.io/)
Verify the `@flow` and `@flow weak` annotations in your javascript files.

@@ -87,2 +89,5 @@

{
"dependencies": {
"flow-annotation-check": "^1.0.0"
},
"scripts": {

@@ -114,2 +119,22 @@ "annotations": "flow-annotation-check"

Setting `--exclude` will override the defaults. So don't forget to ignore `node_modules/**/*.js` in addition to project specific folders.
You can also configure cli arguments directly inside your package.json file. Example:
```json
{
"dependencies": {
"flow-annotation-check": "^1.0.0"
},
"flow-annotation-check": {
"absolute": false,
"allow_weak": false
"exclude": ['+(node_modules|build|flow-typed)/**/*.js'],
"flow_path": "flow"
"include": ['**/*.js'],
"root": "."
}
}
```
### Validate mode

@@ -116,0 +141,0 @@

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