WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
'use strict';
|
||||
|
||||
const {Transform} = require('stream');
|
||||
const Assembler = require('../Assembler');
|
||||
|
||||
class Counter {
|
||||
constructor(initialDepth) {
|
||||
this.depth = initialDepth;
|
||||
}
|
||||
startObject() {
|
||||
++this.depth;
|
||||
}
|
||||
endObject() {
|
||||
--this.depth;
|
||||
}
|
||||
startArray() {
|
||||
++this.depth;
|
||||
}
|
||||
endArray() {
|
||||
--this.depth;
|
||||
}
|
||||
}
|
||||
|
||||
class StreamBase extends Transform {
|
||||
constructor(options) {
|
||||
super(Object.assign({}, options, {writableObjectMode: true, readableObjectMode: true}));
|
||||
if (options) {
|
||||
this.objectFilter = options.objectFilter;
|
||||
this.includeUndecided = options.includeUndecided;
|
||||
}
|
||||
if (typeof this.objectFilter != 'function') {
|
||||
this._filter = this._transform;
|
||||
}
|
||||
this._transform = this._wait || this._filter;
|
||||
this._assembler = new Assembler(options);
|
||||
}
|
||||
|
||||
_transform(chunk, encoding, callback) {
|
||||
if (this._assembler[chunk.name]) {
|
||||
this._assembler[chunk.name](chunk.value);
|
||||
if (this._assembler.depth === this._level) {
|
||||
this._push();
|
||||
}
|
||||
}
|
||||
callback(null);
|
||||
}
|
||||
|
||||
_filter(chunk, encoding, callback) {
|
||||
if (this._assembler[chunk.name]) {
|
||||
this._assembler[chunk.name](chunk.value);
|
||||
const result = this.objectFilter(this._assembler);
|
||||
if (result) {
|
||||
if (this._assembler.depth === this._level) {
|
||||
this._push();
|
||||
this._transform = this._filter;
|
||||
}
|
||||
this._transform = this._accept;
|
||||
return callback(null);
|
||||
}
|
||||
if (result === false) {
|
||||
this._saved_assembler = this._assembler;
|
||||
this._assembler = new Counter(this._saved_assembler.depth);
|
||||
this._saved_assembler.dropToLevel(this._level);
|
||||
if (this._assembler.depth === this._level) {
|
||||
this._assembler = this._saved_assembler;
|
||||
this._transform = this._filter;
|
||||
}
|
||||
this._transform = this._reject;
|
||||
return callback(null);
|
||||
}
|
||||
if (this._assembler.depth === this._level) {
|
||||
this._push(!this.includeUndecided);
|
||||
}
|
||||
}
|
||||
callback(null);
|
||||
}
|
||||
|
||||
_accept(chunk, encoding, callback) {
|
||||
if (this._assembler[chunk.name]) {
|
||||
this._assembler[chunk.name](chunk.value);
|
||||
if (this._assembler.depth === this._level) {
|
||||
this._push();
|
||||
this._transform = this._filter;
|
||||
}
|
||||
}
|
||||
callback(null);
|
||||
}
|
||||
|
||||
_reject(chunk, encoding, callback) {
|
||||
if (this._assembler[chunk.name]) {
|
||||
this._assembler[chunk.name](chunk.value);
|
||||
if (this._assembler.depth === this._level) {
|
||||
this._assembler = this._saved_assembler;
|
||||
this._transform = this._filter;
|
||||
}
|
||||
}
|
||||
callback(null);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = StreamBase;
|
||||
@@ -0,0 +1,41 @@
|
||||
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.7 BLOCK -->
|
||||
|
||||
## Security
|
||||
|
||||
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
|
||||
|
||||
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
|
||||
|
||||
## Reporting Security Issues
|
||||
|
||||
**Please do not report security vulnerabilities through public GitHub issues.**
|
||||
|
||||
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
|
||||
|
||||
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
|
||||
|
||||
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
|
||||
|
||||
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
|
||||
|
||||
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
||||
* Full paths of source file(s) related to the manifestation of the issue
|
||||
* The location of the affected source code (tag/branch/commit or direct URL)
|
||||
* Any special configuration required to reproduce the issue
|
||||
* Step-by-step instructions to reproduce the issue
|
||||
* Proof-of-concept or exploit code (if possible)
|
||||
* Impact of the issue, including how an attacker might exploit the issue
|
||||
|
||||
This information will help us triage your report more quickly.
|
||||
|
||||
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
|
||||
|
||||
## Preferred Languages
|
||||
|
||||
We prefer all communications to be in English.
|
||||
|
||||
## Policy
|
||||
|
||||
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
|
||||
|
||||
<!-- END MICROSOFT SECURITY.MD BLOCK -->
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bls12-381.d.ts","sourceRoot":"","sources":["../src/bls12-381.ts"],"names":[],"mappings":"AAgFA,OAAO,EAAO,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAS,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAmE3D,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,CAGtC,CAAC;AAuTH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,EAAE,OA8HtB,CAAC"}
|
||||
@@ -0,0 +1,121 @@
|
||||
# minimist <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
||||
|
||||
[![github actions][actions-image]][actions-url]
|
||||
[![coverage][codecov-image]][codecov-url]
|
||||
[![License][license-image]][license-url]
|
||||
[![Downloads][downloads-image]][downloads-url]
|
||||
|
||||
[![npm badge][npm-badge-png]][package-url]
|
||||
|
||||
parse argument options
|
||||
|
||||
This module is the guts of optimist's argument parser without all the
|
||||
fanciful decoration.
|
||||
|
||||
# example
|
||||
|
||||
``` js
|
||||
var argv = require('minimist')(process.argv.slice(2));
|
||||
console.log(argv);
|
||||
```
|
||||
|
||||
```
|
||||
$ node example/parse.js -a beep -b boop
|
||||
{ _: [], a: 'beep', b: 'boop' }
|
||||
```
|
||||
|
||||
```
|
||||
$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
|
||||
{
|
||||
_: ['foo', 'bar', 'baz'],
|
||||
x: 3,
|
||||
y: 4,
|
||||
n: 5,
|
||||
a: true,
|
||||
b: true,
|
||||
c: true,
|
||||
beep: 'boop'
|
||||
}
|
||||
```
|
||||
|
||||
# security
|
||||
|
||||
Previous versions had a prototype pollution bug that could cause privilege
|
||||
escalation in some circumstances when handling untrusted user input.
|
||||
|
||||
Please use version 1.2.6 or later:
|
||||
|
||||
* https://security.snyk.io/vuln/SNYK-JS-MINIMIST-2429795 (version <=1.2.5)
|
||||
* https://snyk.io/vuln/SNYK-JS-MINIMIST-559764 (version <=1.2.3)
|
||||
|
||||
# methods
|
||||
|
||||
``` js
|
||||
var parseArgs = require('minimist')
|
||||
```
|
||||
|
||||
## var argv = parseArgs(args, opts={})
|
||||
|
||||
Return an argument object `argv` populated with the array arguments from `args`.
|
||||
|
||||
`argv._` contains all the arguments that didn't have an option associated with
|
||||
them.
|
||||
|
||||
Numeric-looking arguments will be returned as numbers unless `opts.string` or
|
||||
`opts.boolean` is set for that argument name.
|
||||
|
||||
Any arguments after `'--'` will not be parsed and will end up in `argv._`.
|
||||
|
||||
options can be:
|
||||
|
||||
* `opts.string` - a string or array of strings argument names to always treat as
|
||||
strings
|
||||
* `opts.boolean` - a boolean, string or array of strings to always treat as
|
||||
booleans. if `true` will treat all double hyphenated arguments without equal signs
|
||||
as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
|
||||
* `opts.alias` - an object mapping string names to strings or arrays of string
|
||||
argument names to use as aliases
|
||||
* `opts.default` - an object mapping string argument names to default values
|
||||
* `opts.stopEarly` - when true, populate `argv._` with everything after the
|
||||
first non-option
|
||||
* `opts['--']` - when true, populate `argv._` with everything before the `--`
|
||||
and `argv['--']` with everything after the `--`. Here's an example:
|
||||
|
||||
```
|
||||
> require('./')('one two three -- four five --six'.split(' '), { '--': true })
|
||||
{
|
||||
_: ['one', 'two', 'three'],
|
||||
'--': ['four', 'five', '--six']
|
||||
}
|
||||
```
|
||||
|
||||
Note that with `opts['--']` set, parsing for arguments still stops after the
|
||||
`--`.
|
||||
|
||||
* `opts.unknown` - a function which is invoked with a command line parameter not
|
||||
defined in the `opts` configuration object. If the function returns `false`, the
|
||||
unknown option is not added to `argv`.
|
||||
|
||||
# install
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install minimist
|
||||
```
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
||||
|
||||
[package-url]: https://npmjs.org/package/minimist
|
||||
[npm-version-svg]: https://versionbadg.es/minimistjs/minimist.svg
|
||||
[npm-badge-png]: https://nodei.co/npm/minimist.png?downloads=true&stars=true
|
||||
[license-image]: https://img.shields.io/npm/l/minimist.svg
|
||||
[license-url]: LICENSE
|
||||
[downloads-image]: https://img.shields.io/npm/dm/minimist.svg
|
||||
[downloads-url]: https://npm-stat.com/charts.html?package=minimist
|
||||
[codecov-image]: https://codecov.io/gh/minimistjs/minimist/branch/main/graphs/badge.svg
|
||||
[codecov-url]: https://app.codecov.io/gh/minimistjs/minimist/
|
||||
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/minimistjs/minimist
|
||||
[actions-url]: https://github.com/minimistjs/minimist/actions
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"i128.d.ts","sourceRoot":"","sources":["../../src/i128.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvG,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG7C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,cAAc,GAAI,SAAQ,iBAAsB,KAAG,gBAAgB,CAAC,MAAM,GAAG,MAAM,EAAE,EAAE,CAa9F,CAAC;AAEP;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,cAAc,GAAI,SAAQ,iBAAsB,KAAG,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAYrF,CAAC;AAEP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,YAAY,GAAI,SAAQ,iBAAsB,KAAG,cAAc,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,EAAE,CACxC,CAAC"}
|
||||
@@ -0,0 +1,128 @@
|
||||
// Generated by LiveScript 1.6.0
|
||||
(function(){
|
||||
var ref$, any, all, isItNaN, types, defaultType, toString$ = {}.toString;
|
||||
ref$ = require('prelude-ls'), any = ref$.any, all = ref$.all, isItNaN = ref$.isItNaN;
|
||||
types = {
|
||||
Number: {
|
||||
typeOf: 'Number',
|
||||
validate: function(it){
|
||||
return !isItNaN(it);
|
||||
}
|
||||
},
|
||||
NaN: {
|
||||
typeOf: 'Number',
|
||||
validate: isItNaN
|
||||
},
|
||||
Int: {
|
||||
typeOf: 'Number',
|
||||
validate: function(it){
|
||||
return !isItNaN(it) && it % 1 === 0;
|
||||
}
|
||||
},
|
||||
Float: {
|
||||
typeOf: 'Number',
|
||||
validate: function(it){
|
||||
return !isItNaN(it);
|
||||
}
|
||||
},
|
||||
Date: {
|
||||
typeOf: 'Date',
|
||||
validate: function(it){
|
||||
return !isItNaN(it.getTime());
|
||||
}
|
||||
}
|
||||
};
|
||||
defaultType = {
|
||||
array: 'Array',
|
||||
tuple: 'Array'
|
||||
};
|
||||
function checkArray(input, type, options){
|
||||
return all(function(it){
|
||||
return checkMultiple(it, type.of, options);
|
||||
}, input);
|
||||
}
|
||||
function checkTuple(input, type, options){
|
||||
var i, i$, ref$, len$, types;
|
||||
i = 0;
|
||||
for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) {
|
||||
types = ref$[i$];
|
||||
if (!checkMultiple(input[i], types, options)) {
|
||||
return false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return input.length <= i;
|
||||
}
|
||||
function checkFields(input, type, options){
|
||||
var inputKeys, numInputKeys, k, numOfKeys, key, ref$, types;
|
||||
inputKeys = {};
|
||||
numInputKeys = 0;
|
||||
for (k in input) {
|
||||
inputKeys[k] = true;
|
||||
numInputKeys++;
|
||||
}
|
||||
numOfKeys = 0;
|
||||
for (key in ref$ = type.of) {
|
||||
types = ref$[key];
|
||||
if (!checkMultiple(input[key], types, options)) {
|
||||
return false;
|
||||
}
|
||||
if (inputKeys[key]) {
|
||||
numOfKeys++;
|
||||
}
|
||||
}
|
||||
return type.subset || numInputKeys === numOfKeys;
|
||||
}
|
||||
function checkStructure(input, type, options){
|
||||
if (!(input instanceof Object)) {
|
||||
return false;
|
||||
}
|
||||
switch (type.structure) {
|
||||
case 'fields':
|
||||
return checkFields(input, type, options);
|
||||
case 'array':
|
||||
return checkArray(input, type, options);
|
||||
case 'tuple':
|
||||
return checkTuple(input, type, options);
|
||||
}
|
||||
}
|
||||
function check(input, typeObj, options){
|
||||
var type, structure, setting, that;
|
||||
type = typeObj.type, structure = typeObj.structure;
|
||||
if (type) {
|
||||
if (type === '*') {
|
||||
return true;
|
||||
}
|
||||
setting = options.customTypes[type] || types[type];
|
||||
if (setting) {
|
||||
return (setting.typeOf === void 8 || setting.typeOf === toString$.call(input).slice(8, -1)) && setting.validate(input);
|
||||
} else {
|
||||
return type === toString$.call(input).slice(8, -1) && (!structure || checkStructure(input, typeObj, options));
|
||||
}
|
||||
} else if (structure) {
|
||||
if (that = defaultType[structure]) {
|
||||
if (that !== toString$.call(input).slice(8, -1)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return checkStructure(input, typeObj, options);
|
||||
} else {
|
||||
throw new Error("No type defined. Input: " + input + ".");
|
||||
}
|
||||
}
|
||||
function checkMultiple(input, types, options){
|
||||
if (toString$.call(types).slice(8, -1) !== 'Array') {
|
||||
throw new Error("Types must be in an array. Input: " + input + ".");
|
||||
}
|
||||
return any(function(it){
|
||||
return check(input, it, options);
|
||||
}, types);
|
||||
}
|
||||
module.exports = function(parsedType, input, options){
|
||||
options == null && (options = {});
|
||||
if (options.customTypes == null) {
|
||||
options.customTypes = {};
|
||||
}
|
||||
return checkMultiple(input, parsedType, options);
|
||||
};
|
||||
}).call(this);
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "../../cjs/_class_apply_descriptor_update.cjs",
|
||||
"module": "../../esm/_class_apply_descriptor_update.js"
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// Code generated by _scripts/generate-encoder.ts. DO NOT EDIT.
|
||||
import { SyntaxKind } from "../../ast/index.js";
|
||||
import { NODE_DATA_TYPE_CHILDREN, NODE_DATA_TYPE_EXTENDED, NODE_DATA_TYPE_STRING, } from "./protocol.js";
|
||||
export function getNodeDataType(kind) {
|
||||
switch (kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.PrivateIdentifier:
|
||||
case SyntaxKind.JsxText:
|
||||
case SyntaxKind.JSDocText:
|
||||
case SyntaxKind.JSDocLink:
|
||||
case SyntaxKind.JSDocLinkPlain:
|
||||
case SyntaxKind.JSDocLinkCode:
|
||||
return NODE_DATA_TYPE_STRING;
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.BigIntLiteral:
|
||||
case SyntaxKind.RegularExpressionLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
case SyntaxKind.TemplateHead:
|
||||
case SyntaxKind.TemplateMiddle:
|
||||
case SyntaxKind.TemplateTail:
|
||||
case SyntaxKind.SourceFile:
|
||||
return NODE_DATA_TYPE_EXTENDED;
|
||||
default:
|
||||
return NODE_DATA_TYPE_CHILDREN;
|
||||
}
|
||||
}
|
||||
export function getNodeCommonData(node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Block:
|
||||
return (node.multiLine ? 1 : 0) << 24;
|
||||
case SyntaxKind.HeritageClause:
|
||||
return (node.token === SyntaxKind.ImplementsKeyword ? 1 : 0) << 24;
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return (node.isExportEquals ? 1 : 0) << 24;
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
return (node.isTypeOnly ? 1 : 0) << 24;
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
return (node.operator === SyntaxKind.MinusToken ? 1 : node.operator === SyntaxKind.TildeToken ? 2 : node.operator === SyntaxKind.ExclamationToken ? 3 : node.operator === SyntaxKind.PlusPlusToken ? 4 : node.operator === SyntaxKind.MinusMinusToken ? 5 : 0) << 24;
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
return (node.operator === SyntaxKind.MinusMinusToken ? 1 : 0) << 24;
|
||||
case SyntaxKind.MetaProperty:
|
||||
return (node.keywordToken === SyntaxKind.NewKeyword ? 1 : 0) << 24;
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
return (node.multiLine ? 1 : 0) << 24;
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
return (node.multiLine ? 1 : 0) << 24;
|
||||
case SyntaxKind.TypeOperator:
|
||||
return (node.operator === SyntaxKind.ReadonlyKeyword ? 1 : node.operator === SyntaxKind.UniqueKeyword ? 2 : 0) << 24;
|
||||
case SyntaxKind.ImportAttributes:
|
||||
return (node.multiLine ? 1 : 0) << 24 | (node.token === SyntaxKind.AssertKeyword ? 1 : 0) << 25;
|
||||
case SyntaxKind.JsxText:
|
||||
return (node.containsOnlyTriviaWhiteSpaces ? 1 : 0) << 24;
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return (node.keyword === SyntaxKind.NamespaceKeyword ? 1 : 0) << 24;
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return (node.isTypeOnly ? 1 : 0) << 24;
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return (node.isTypeOnly ? 1 : 0) << 24;
|
||||
case SyntaxKind.ImportType:
|
||||
return (node.isTypeOf ? 1 : 0) << 24;
|
||||
case SyntaxKind.ImportClause:
|
||||
return (node.phaseModifier === SyntaxKind.TypeKeyword ? 1 : node.phaseModifier === SyntaxKind.DeferKeyword ? 2 : 0) << 24;
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
return (node.isTypeOnly ? 1 : 0) << 24;
|
||||
case SyntaxKind.JSDocTypeLiteral:
|
||||
return (node.isArrayType ? 1 : 0) << 24;
|
||||
case SyntaxKind.JSDocParameterTag:
|
||||
case SyntaxKind.JSDocPropertyTag:
|
||||
return (node.isBracketed ? 1 : 0) << 24 | (node.isNameFirst ? 1 : 0) << 25;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//# sourceMappingURL=encoder.generated.js.map
|
||||
@@ -0,0 +1,8 @@
|
||||
coverage: true
|
||||
coverage-map: 'coverage-map.js'
|
||||
|
||||
reporter: terse
|
||||
|
||||
files:
|
||||
- 'lib/**/*.test.js'
|
||||
- 'test/**/*.test.js'
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "../../cjs/_apply_decs_2203_r.cjs",
|
||||
"module": "../../esm/_apply_decs_2203_r.js"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
function _instanceof(left, right) {
|
||||
"@swc/helpers - instanceof";
|
||||
|
||||
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
||||
return !!right[Symbol.hasInstance](left);
|
||||
} else return left instanceof right;
|
||||
}
|
||||
exports._ = _instanceof;
|
||||
@@ -0,0 +1,134 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util_1 = require("../util");
|
||||
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
||||
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('no-empty-function');
|
||||
const defaultOptions = [
|
||||
{
|
||||
allow: [],
|
||||
},
|
||||
];
|
||||
const schema = (0, util_1.deepMerge)(
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- https://github.com/microsoft/TypeScript/issues/17002
|
||||
Array.isArray(baseRule.meta.schema)
|
||||
? baseRule.meta.schema[0]
|
||||
: baseRule.meta.schema, {
|
||||
properties: {
|
||||
allow: {
|
||||
description: 'Locations and kinds of functions that are allowed to be empty.',
|
||||
items: {
|
||||
type: 'string',
|
||||
enum: [
|
||||
'functions',
|
||||
'arrowFunctions',
|
||||
'generatorFunctions',
|
||||
'methods',
|
||||
'generatorMethods',
|
||||
'getters',
|
||||
'setters',
|
||||
'constructors',
|
||||
'private-constructors',
|
||||
'protected-constructors',
|
||||
'asyncFunctions',
|
||||
'asyncMethods',
|
||||
'decoratedFunctions',
|
||||
'overrideMethods',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'no-empty-function',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
defaultOptions,
|
||||
docs: {
|
||||
description: 'Disallow empty functions',
|
||||
extendsBaseRule: true,
|
||||
recommended: 'stylistic',
|
||||
},
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
messages: baseRule.meta.messages,
|
||||
schema: [schema],
|
||||
},
|
||||
defaultOptions,
|
||||
create(context, [{ allow = [] }]) {
|
||||
const rules = baseRule.create(context);
|
||||
const isAllowedProtectedConstructors = allow.includes('protected-constructors');
|
||||
const isAllowedPrivateConstructors = allow.includes('private-constructors');
|
||||
const isAllowedDecoratedFunctions = allow.includes('decoratedFunctions');
|
||||
const isAllowedOverrideMethods = allow.includes('overrideMethods');
|
||||
/**
|
||||
* Check if the method body is empty
|
||||
* @param node the node to be validated
|
||||
* @returns true if the body is empty
|
||||
* @private
|
||||
*/
|
||||
function isBodyEmpty(node) {
|
||||
return node.body.body.length === 0;
|
||||
}
|
||||
/**
|
||||
* Check if method has parameter properties
|
||||
* @param node the node to be validated
|
||||
* @returns true if the body has parameter properties
|
||||
* @private
|
||||
*/
|
||||
function hasParameterProperties(node) {
|
||||
return node.params.some(param => param.type === utils_1.AST_NODE_TYPES.TSParameterProperty);
|
||||
}
|
||||
/**
|
||||
* @param node the node to be validated
|
||||
* @returns true if the constructor is allowed to be empty
|
||||
* @private
|
||||
*/
|
||||
function isAllowedEmptyConstructor(node) {
|
||||
const parent = node.parent;
|
||||
if (isBodyEmpty(node) &&
|
||||
parent.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
|
||||
parent.kind === 'constructor') {
|
||||
const { accessibility } = parent;
|
||||
return (
|
||||
// allow protected constructors
|
||||
(accessibility === 'protected' && isAllowedProtectedConstructors) ||
|
||||
// allow private constructors
|
||||
(accessibility === 'private' && isAllowedPrivateConstructors) ||
|
||||
// allow constructors which have parameter properties
|
||||
hasParameterProperties(node));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @param node the node to be validated
|
||||
* @returns true if a function has decorators
|
||||
* @private
|
||||
*/
|
||||
function isAllowedEmptyDecoratedFunctions(node) {
|
||||
if (isAllowedDecoratedFunctions && isBodyEmpty(node)) {
|
||||
const decorators = node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition
|
||||
? node.parent.decorators
|
||||
: undefined;
|
||||
return !!decorators && !!decorators.length;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isAllowedEmptyOverrideMethod(node) {
|
||||
return (isAllowedOverrideMethods &&
|
||||
isBodyEmpty(node) &&
|
||||
node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
|
||||
node.parent.override);
|
||||
}
|
||||
return {
|
||||
...rules,
|
||||
FunctionExpression(node) {
|
||||
if (isAllowedEmptyConstructor(node) ||
|
||||
isAllowedEmptyDecoratedFunctions(node) ||
|
||||
isAllowedEmptyOverrideMethod(node)) {
|
||||
return;
|
||||
}
|
||||
rules.FunctionExpression(node);
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
import type { LibDefinition } from '../variable';
|
||||
export declare const es2022: LibDefinition;
|
||||
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./isArray"), exports);
|
||||
__exportStar(require("./NoInfer"), exports);
|
||||
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* @fileoverview Rule to flag use of a leading/trailing decimal point in a numeric literal
|
||||
* @author James Allardice
|
||||
* @deprecated in ESLint v8.53.0
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: {
|
||||
message: "Formatting rules are being moved out of ESLint core.",
|
||||
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
||||
deprecatedSince: "8.53.0",
|
||||
availableUntil: "11.0.0",
|
||||
replacedBy: [
|
||||
{
|
||||
message:
|
||||
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
||||
url: "https://eslint.style/guide/migration",
|
||||
plugin: {
|
||||
name: "@stylistic/eslint-plugin",
|
||||
url: "https://eslint.style",
|
||||
},
|
||||
rule: {
|
||||
name: "no-floating-decimal",
|
||||
url: "https://eslint.style/rules/no-floating-decimal",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Disallow leading or trailing decimal points in numeric literals",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-floating-decimal",
|
||||
},
|
||||
|
||||
schema: [],
|
||||
fixable: "code",
|
||||
messages: {
|
||||
leading: "A leading decimal point can be confused with a dot.",
|
||||
trailing: "A trailing decimal point can be confused with a dot.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
return {
|
||||
Literal(node) {
|
||||
if (typeof node.value === "number") {
|
||||
if (node.raw.startsWith(".")) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "leading",
|
||||
fix(fixer) {
|
||||
const tokenBefore =
|
||||
sourceCode.getTokenBefore(node);
|
||||
const needsSpaceBefore =
|
||||
tokenBefore &&
|
||||
tokenBefore.range[1] === node.range[0] &&
|
||||
!astUtils.canTokensBeAdjacent(
|
||||
tokenBefore,
|
||||
`0${node.raw}`,
|
||||
);
|
||||
|
||||
return fixer.insertTextBefore(
|
||||
node,
|
||||
needsSpaceBefore ? " 0" : "0",
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
if (node.raw.indexOf(".") === node.raw.length - 1) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "trailing",
|
||||
fix: fixer => fixer.insertTextAfter(node, "0"),
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
var arrayLikeToArray = require("./arrayLikeToArray.js");
|
||||
function _maybeArrayLike(r, a, e) {
|
||||
if (a && !Array.isArray(a) && "number" == typeof a.length) {
|
||||
var y = a.length;
|
||||
return arrayLikeToArray(a, void 0 !== e && e < y ? e : y);
|
||||
}
|
||||
return r(a, e);
|
||||
}
|
||||
module.exports = _maybeArrayLike, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
@@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
|
||||
const jayson = require('../../');
|
||||
|
||||
/**
|
||||
* Constructor for a Jayson Promise Method
|
||||
* @see Method
|
||||
* @class PromiseMethod
|
||||
* @extends Method
|
||||
* @return {PromiseMethod}
|
||||
*/
|
||||
const PromiseMethod = module.exports = function(handler, options) {
|
||||
if(!(this instanceof PromiseMethod)) {
|
||||
return new PromiseMethod(handler, options);
|
||||
}
|
||||
jayson.Method.apply(this, arguments);
|
||||
};
|
||||
require('util').inherits(PromiseMethod, jayson.Method);
|
||||
|
||||
module.exports = PromiseMethod;
|
||||
|
||||
/**
|
||||
* @summary Executes this method in the context of a server
|
||||
* @param {Server} server
|
||||
* @param {Array|Object} requestParams
|
||||
* @param {Object} [context] Optional context object passed to methods
|
||||
* @param {Function} outerCallback
|
||||
* @return {Promise}
|
||||
*/
|
||||
PromiseMethod.prototype.execute = function(server, requestParams, context, outerCallback) {
|
||||
let wasPromised = false;
|
||||
|
||||
if(typeof(context) === 'function') {
|
||||
outerCallback = context;
|
||||
context = {};
|
||||
}
|
||||
|
||||
const promise = jayson.Method.prototype.execute.call(this, server, requestParams, context, function() {
|
||||
if(wasPromised) {
|
||||
return; // ignore any invocations of the callback if a promise was returned
|
||||
}
|
||||
outerCallback.apply(null, arguments);
|
||||
});
|
||||
|
||||
wasPromised = promise && typeof promise.then === 'function';
|
||||
|
||||
// if the handler returned a promise, call the callback when it resolves
|
||||
if(wasPromised) {
|
||||
return promise.then(
|
||||
function(fulfilled) { outerCallback(null, fulfilled); },
|
||||
function(rejected) { outerCallback(rejected); }
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @fileoverview Rule to flag references to undeclared variables.
|
||||
* @author Mark Macdonald
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Checks if the given node is the argument of a typeof operator.
|
||||
* @param {ASTNode} node The AST node being checked.
|
||||
* @returns {boolean} Whether or not the node is the argument of a typeof operator.
|
||||
*/
|
||||
function hasTypeOfOperator(node) {
|
||||
const parent = node.parent;
|
||||
|
||||
return parent.type === "UnaryExpression" && parent.operator === "typeof";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "problem",
|
||||
|
||||
defaultOptions: [
|
||||
{
|
||||
typeof: false,
|
||||
},
|
||||
],
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Disallow the use of undeclared variables unless mentioned in `/*global */` comments",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-undef",
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
typeof: {
|
||||
type: "boolean",
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
messages: {
|
||||
undef: "'{{name}}' is not defined.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const [{ typeof: considerTypeOf }] = context.options;
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
return {
|
||||
"Program:exit"(node) {
|
||||
const globalScope = sourceCode.getScope(node);
|
||||
|
||||
globalScope.through.forEach(ref => {
|
||||
const identifier = ref.identifier;
|
||||
|
||||
if (!considerTypeOf && hasTypeOfOperator(identifier)) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.report({
|
||||
node: identifier,
|
||||
messageId: "undef",
|
||||
data: identifier,
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @deprecated
|
||||
* @module
|
||||
*/
|
||||
import { pallas as pn, vesta as vn } from './misc.ts';
|
||||
/** @deprecated */
|
||||
export declare const pallas: typeof pn;
|
||||
/** @deprecated */
|
||||
export declare const vesta: typeof vn;
|
||||
//# sourceMappingURL=pasta.d.ts.map
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @fileoverview Rule to enforce description with the `Symbol` object
|
||||
* @author Jarek Rencz
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Require symbol descriptions",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/symbol-description",
|
||||
},
|
||||
fixable: null,
|
||||
schema: [],
|
||||
messages: {
|
||||
expected: "Expected Symbol to have a description.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Reports if node does not conform the rule in case rule is set to
|
||||
* report missing description
|
||||
* @param {ASTNode} node A CallExpression node to check.
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkArgument(node) {
|
||||
if (node.arguments.length === 0) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "expected",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
"Program:exit"(node) {
|
||||
const scope = sourceCode.getScope(node);
|
||||
const variable = astUtils.getVariableByName(scope, "Symbol");
|
||||
|
||||
if (variable && variable.defs.length === 0) {
|
||||
variable.references.forEach(reference => {
|
||||
const idNode = reference.identifier;
|
||||
|
||||
if (astUtils.isCallee(idNode)) {
|
||||
checkArgument(idNode.parent);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user