update
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_isNativeReflectConstruct","require","_setPrototypeOf","_construct","Parent","args","Class","isNativeReflectConstruct","Reflect","construct","apply","arguments","a","push","instance","bind","setPrototypeOf","prototype"],"sources":["../../src/helpers/construct.ts"],"sourcesContent":["/* @minVersion 7.0.0-beta.0 */\n\nimport isNativeReflectConstruct from \"./isNativeReflectConstruct.ts\";\nimport setPrototypeOf from \"./setPrototypeOf.ts\";\n\nexport default function _construct(\n Parent: Function,\n args: any[],\n Class: Function,\n): any {\n if (isNativeReflectConstruct()) {\n // Avoid issues with Class being present but undefined when it wasn't\n // present in the original call.\n return Reflect.construct.apply(null, arguments as any);\n }\n // NOTE: If Parent !== Class, the correct __proto__ is set *after*\n // calling the constructor.\n var a: [any, ...any[]] = [null];\n a.push.apply(a, args);\n var instance = new (Parent.bind.apply(Parent, a))();\n if (Class) setPrototypeOf(instance, Class.prototype);\n return instance;\n}\n"],"mappings":";;;;;;AAEA,IAAAA,yBAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAEe,SAASE,UAAUA,CAChCC,MAAgB,EAChBC,IAAW,EACXC,KAAe,EACV;EACL,IAAI,IAAAC,iCAAwB,EAAC,CAAC,EAAE;IAG9B,OAAOC,OAAO,CAACC,SAAS,CAACC,KAAK,CAAC,IAAI,EAAEC,SAAgB,CAAC;EACxD;EAGA,IAAIC,CAAkB,GAAG,CAAC,IAAI,CAAC;EAC/BA,CAAC,CAACC,IAAI,CAACH,KAAK,CAACE,CAAC,EAAEP,IAAI,CAAC;EACrB,IAAIS,QAAQ,GAAG,KAAKV,MAAM,CAACW,IAAI,CAACL,KAAK,CAACN,MAAM,EAAEQ,CAAC,CAAC,EAAE,CAAC;EACnD,IAAIN,KAAK,EAAE,IAAAU,uBAAc,EAACF,QAAQ,EAAER,KAAK,CAACW,SAAS,CAAC;EACpD,OAAOH,QAAQ;AACjB","ignoreList":[]}
|
||||
@@ -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 @@
|
||||
module.exports={A:{A:{"1":"F A B","2":"K D E mC"},B:{"1":"0 9 C L M G N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I"},C:{"1":"0 1 2 3 4 5 6 7 8 9 LC J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC qC rC","4":"nC"},D:{"1":"0 1 2 3 4 5 6 7 8 9 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC"},E:{"1":"J PB K D E F A B C L M G sC SC tC uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C"},F:{"1":"0 1 2 3 4 5 6 7 8 B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 5C 6C 7C FC kC 8C GC","2":"F","4":"4C"},G:{"1":"E SC 9C lC AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC"},H:{"1":"WD"},I:{"1":"LC J I XD YD ZD aD lC bD cD"},J:{"1":"D A"},K:{"1":"A B C H FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"1":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"qD rD"}},B:2,C:"CSS3 Colors",D:true};
|
||||
@@ -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,457 @@
|
||||
#include "BMPParser.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace std;
|
||||
using namespace BMPParser;
|
||||
|
||||
#define MAX_IMG_SIZE 10000
|
||||
|
||||
#define E(cond, msg) if(cond) return setErr(msg)
|
||||
#define EU(cond, msg) if(cond) return setErrUnsupported(msg)
|
||||
#define EX(cond, msg) if(cond) return setErrUnknown(msg)
|
||||
|
||||
#define I1() get<char>()
|
||||
#define U1() get<uint8_t>()
|
||||
#define I2() get<int16_t>()
|
||||
#define U2() get<uint16_t>()
|
||||
#define I4() get<int32_t>()
|
||||
#define U4() get<uint32_t>()
|
||||
|
||||
#define I1UC() get<char, false>()
|
||||
#define U1UC() get<uint8_t, false>()
|
||||
#define I2UC() get<int16_t, false>()
|
||||
#define U2UC() get<uint16_t, false>()
|
||||
#define I4UC() get<int32_t, false>()
|
||||
#define U4UC() get<uint32_t, false>()
|
||||
|
||||
#define CHECK_OVERRUN(ptr, size, type) \
|
||||
if((ptr) + (size) - data > len){ \
|
||||
setErr("unexpected end of file"); \
|
||||
return type(); \
|
||||
}
|
||||
|
||||
Parser::~Parser(){
|
||||
data = nullptr;
|
||||
ptr = nullptr;
|
||||
|
||||
if(imgd){
|
||||
delete[] imgd;
|
||||
imgd = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::parse(uint8_t *buf, int bufSize, uint8_t *format){
|
||||
assert(status == Status::EMPTY);
|
||||
|
||||
data = ptr = buf;
|
||||
len = bufSize;
|
||||
|
||||
// Start parsing file header
|
||||
setOp("file header");
|
||||
|
||||
// File header signature
|
||||
string fhSig = getStr(2);
|
||||
string temp = "file header signature";
|
||||
EU(fhSig == "BA", temp + " \"BA\"");
|
||||
EU(fhSig == "CI", temp + " \"CI\"");
|
||||
EU(fhSig == "CP", temp + " \"CP\"");
|
||||
EU(fhSig == "IC", temp + " \"IC\"");
|
||||
EU(fhSig == "PT", temp + " \"PT\"");
|
||||
EX(fhSig != "BM", temp); // BM
|
||||
|
||||
// Length of the file should not be larger than `len`
|
||||
E(U4() > static_cast<uint32_t>(len), "inconsistent file size");
|
||||
|
||||
// Skip unused values
|
||||
skip(4);
|
||||
|
||||
// Offset where the pixel array (bitmap data) can be found
|
||||
auto imgdOffset = U4();
|
||||
|
||||
// Start parsing DIB header
|
||||
setOp("DIB header");
|
||||
|
||||
// Prepare some variables in case they are needed
|
||||
uint32_t compr = 0;
|
||||
uint32_t redShift = 0, greenShift = 0, blueShift = 0, alphaShift = 0;
|
||||
uint32_t redMask = 0, greenMask = 0, blueMask = 0, alphaMask = 0;
|
||||
double redMultp = 0, greenMultp = 0, blueMultp = 0, alphaMultp = 0;
|
||||
|
||||
/**
|
||||
* Type of the DIB (device-independent bitmap) header
|
||||
* is determined by its size. Most BMP files use BITMAPINFOHEADER.
|
||||
*/
|
||||
auto dibSize = U4();
|
||||
temp = "DIB header";
|
||||
EU(dibSize == 64, temp + " \"OS22XBITMAPHEADER\"");
|
||||
EU(dibSize == 16, temp + " \"OS22XBITMAPHEADER\"");
|
||||
|
||||
uint32_t infoHeader = dibSize == 40 ? 1 :
|
||||
dibSize == 52 ? 2 :
|
||||
dibSize == 56 ? 3 :
|
||||
dibSize == 108 ? 4 :
|
||||
dibSize == 124 ? 5 : 0;
|
||||
|
||||
// BITMAPCOREHEADER, BITMAP*INFOHEADER, BITMAP*HEADER
|
||||
auto isDibValid = dibSize == 12 || infoHeader;
|
||||
EX(!isDibValid, temp);
|
||||
|
||||
// Image width
|
||||
w = dibSize == 12 ? U2() : I4();
|
||||
E(!w, "image width is 0");
|
||||
E(w < 0, "negative image width");
|
||||
E(w > MAX_IMG_SIZE, "too large image width");
|
||||
|
||||
// Image height (specification allows negative values)
|
||||
h = dibSize == 12 ? U2() : I4();
|
||||
E(!h, "image height is 0");
|
||||
E(h > MAX_IMG_SIZE, "too large image height");
|
||||
|
||||
bool isHeightNegative = h < 0;
|
||||
if(isHeightNegative) h = -h;
|
||||
|
||||
// Number of color planes (must be 1)
|
||||
E(U2() != 1, "number of color planes must be 1");
|
||||
|
||||
// Bits per pixel (color depth)
|
||||
auto bpp = U2();
|
||||
auto isBppValid = bpp == 1 || bpp == 4 || bpp == 8 || bpp == 16 || bpp == 24 || bpp == 32;
|
||||
EU(!isBppValid, "color depth");
|
||||
|
||||
// Calculate image data size and padding
|
||||
uint32_t expectedImgdSize = (((w * bpp + 31) >> 5) << 2) * h;
|
||||
uint32_t rowPadding = (-w * bpp & 31) >> 3;
|
||||
uint32_t imgdSize = 0;
|
||||
|
||||
// Color palette data
|
||||
uint8_t* paletteStart = nullptr;
|
||||
uint32_t palColNum = 0;
|
||||
|
||||
if(infoHeader){
|
||||
// Compression type
|
||||
compr = U4();
|
||||
temp = "compression type";
|
||||
EU(compr == 1, temp + " \"BI_RLE8\"");
|
||||
EU(compr == 2, temp + " \"BI_RLE4\"");
|
||||
EU(compr == 4, temp + " \"BI_JPEG\"");
|
||||
EU(compr == 5, temp + " \"BI_PNG\"");
|
||||
EU(compr == 6, temp + " \"BI_ALPHABITFIELDS\"");
|
||||
EU(compr == 11, temp + " \"BI_CMYK\"");
|
||||
EU(compr == 12, temp + " \"BI_CMYKRLE8\"");
|
||||
EU(compr == 13, temp + " \"BI_CMYKRLE4\"");
|
||||
|
||||
// BI_RGB and BI_BITFIELDS
|
||||
auto isComprValid = compr == 0 || compr == 3;
|
||||
EX(!isComprValid, temp);
|
||||
|
||||
// Ensure that BI_BITFIELDS appears only with 16-bit or 32-bit color
|
||||
E(compr == 3 && !(bpp == 16 || bpp == 32), "compression BI_BITFIELDS can be used only with 16-bit and 32-bit color depth");
|
||||
|
||||
// Size of the image data
|
||||
imgdSize = U4();
|
||||
|
||||
// Horizontal and vertical resolution (ignored)
|
||||
skip(8);
|
||||
|
||||
// Number of colors in the palette or 0 if no palette is present
|
||||
palColNum = U4();
|
||||
EU(palColNum && bpp > 8, "color palette and bit depth combination");
|
||||
if(palColNum) paletteStart = data + dibSize + 14;
|
||||
|
||||
// Number of important colors used or 0 if all colors are important (generally ignored)
|
||||
skip(4);
|
||||
|
||||
if(infoHeader >= 2){
|
||||
// If BI_BITFIELDS are used, calculate masks, otherwise ignore them
|
||||
if(compr == 3){
|
||||
calcMaskShift(redShift, redMask, redMultp);
|
||||
calcMaskShift(greenShift, greenMask, greenMultp);
|
||||
calcMaskShift(blueShift, blueMask, blueMultp);
|
||||
if(infoHeader >= 3) calcMaskShift(alphaShift, alphaMask, alphaMultp);
|
||||
if(status == Status::ERROR) return;
|
||||
}else{
|
||||
skip(16);
|
||||
}
|
||||
|
||||
// Ensure that the color space is LCS_WINDOWS_COLOR_SPACE or sRGB
|
||||
if(infoHeader >= 4 && !palColNum){
|
||||
string colSpace = getStr(4, 1);
|
||||
EU(colSpace != "Win " && colSpace != "sRGB", "color space \"" + colSpace + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Skip to the image data (there may be other chunks between, but they are optional)
|
||||
E(ptr - data > imgdOffset, "image data overlaps with another structure");
|
||||
ptr = data + imgdOffset;
|
||||
|
||||
// Start parsing image data
|
||||
setOp("image data");
|
||||
|
||||
if(!imgdSize){
|
||||
// Value 0 is allowed only for BI_RGB compression type
|
||||
E(compr != 0, "missing image data size");
|
||||
imgdSize = expectedImgdSize;
|
||||
}else{
|
||||
E(imgdSize < expectedImgdSize, "invalid image data size");
|
||||
}
|
||||
|
||||
// Ensure that all image data is present
|
||||
E(ptr - data + imgdSize > len, "not enough image data");
|
||||
|
||||
// Direction of reading rows
|
||||
int yStart = h - 1;
|
||||
int yEnd = -1;
|
||||
int dy = isHeightNegative ? 1 : -1;
|
||||
|
||||
// In case of negative height, read rows backward
|
||||
if(isHeightNegative){
|
||||
yStart = 0;
|
||||
yEnd = h;
|
||||
}
|
||||
|
||||
// Allocate output image data array
|
||||
int buffLen = w * h << 2;
|
||||
imgd = new (nothrow) uint8_t[buffLen];
|
||||
E(!imgd, "unable to allocate memory");
|
||||
|
||||
// Prepare color values
|
||||
uint8_t color[4] = {0};
|
||||
uint8_t &red = color[0];
|
||||
uint8_t &green = color[1];
|
||||
uint8_t &blue = color[2];
|
||||
uint8_t &alpha = color[3];
|
||||
|
||||
// Check if pre-multiplied alpha is used
|
||||
bool premul = format ? format[4] : 0;
|
||||
|
||||
// Main loop
|
||||
for(int y = yStart; y != yEnd; y += dy){
|
||||
// Use in-byte offset for bpp < 8
|
||||
uint8_t colOffset = 0;
|
||||
uint8_t cval = 0;
|
||||
uint32_t val = 0;
|
||||
|
||||
for(int x = 0; x != w; x++){
|
||||
// Index in the output image data
|
||||
int i = (x + y * w) << 2;
|
||||
|
||||
switch(compr){
|
||||
case 0: // BI_RGB
|
||||
switch(bpp){
|
||||
case 1:
|
||||
if(colOffset) ptr--;
|
||||
cval = (U1UC() >> (7 - colOffset)) & 1;
|
||||
|
||||
if(palColNum){
|
||||
uint8_t* entry = paletteStart + (cval << 2);
|
||||
blue = get<uint8_t>(entry);
|
||||
green = get<uint8_t>(entry + 1);
|
||||
red = get<uint8_t>(entry + 2);
|
||||
if(status == Status::ERROR) return;
|
||||
}else{
|
||||
red = green = blue = cval ? 255 : 0;
|
||||
}
|
||||
|
||||
alpha = 255;
|
||||
colOffset = (colOffset + 1) & 7;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if(colOffset) ptr--;
|
||||
cval = (U1UC() >> (4 - colOffset)) & 15;
|
||||
|
||||
if(palColNum){
|
||||
uint8_t* entry = paletteStart + (cval << 2);
|
||||
blue = get<uint8_t>(entry);
|
||||
green = get<uint8_t>(entry + 1);
|
||||
red = get<uint8_t>(entry + 2);
|
||||
if(status == Status::ERROR) return;
|
||||
}else{
|
||||
red = green = blue = cval << 4;
|
||||
}
|
||||
|
||||
alpha = 255;
|
||||
colOffset = (colOffset + 4) & 7;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
cval = U1UC();
|
||||
|
||||
if(palColNum){
|
||||
uint8_t* entry = paletteStart + (cval << 2);
|
||||
blue = get<uint8_t>(entry);
|
||||
green = get<uint8_t>(entry + 1);
|
||||
red = get<uint8_t>(entry + 2);
|
||||
if(status == Status::ERROR) return;
|
||||
}else{
|
||||
red = green = blue = cval;
|
||||
}
|
||||
|
||||
alpha = 255;
|
||||
break;
|
||||
|
||||
case 16:
|
||||
// RGB555
|
||||
val = U1UC();
|
||||
val |= U1UC() << 8;
|
||||
red = (val >> 10) << 3;
|
||||
green = (val >> 5) << 3;
|
||||
blue = val << 3;
|
||||
alpha = 255;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
blue = U1UC();
|
||||
green = U1UC();
|
||||
red = U1UC();
|
||||
alpha = 255;
|
||||
break;
|
||||
|
||||
case 32:
|
||||
blue = U1UC();
|
||||
green = U1UC();
|
||||
red = U1UC();
|
||||
|
||||
if(infoHeader >= 3){
|
||||
alpha = U1UC();
|
||||
}else{
|
||||
alpha = 255;
|
||||
skip(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3: // BI_BITFIELDS
|
||||
uint32_t col = bpp == 16 ? U2UC() : U4UC();
|
||||
red = ((col >> redShift) & redMask) * redMultp + .5;
|
||||
green = ((col >> greenShift) & greenMask) * greenMultp + .5;
|
||||
blue = ((col >> blueShift) & blueMask) * blueMultp + .5;
|
||||
alpha = alphaMask ? ((col >> alphaShift) & alphaMask) * alphaMultp + .5 : 255;
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pixel format:
|
||||
* red,
|
||||
* green,
|
||||
* blue,
|
||||
* alpha,
|
||||
* is alpha pre-multiplied
|
||||
* Default is [0, 1, 2, 3, 0]
|
||||
*/
|
||||
|
||||
if(premul && alpha != 255){
|
||||
double a = alpha / 255.;
|
||||
red = static_cast<uint8_t>(red * a + .5);
|
||||
green = static_cast<uint8_t>(green * a + .5);
|
||||
blue = static_cast<uint8_t>(blue * a + .5);
|
||||
}
|
||||
|
||||
if(format){
|
||||
imgd[i] = color[format[0]];
|
||||
imgd[i + 1] = color[format[1]];
|
||||
imgd[i + 2] = color[format[2]];
|
||||
imgd[i + 3] = color[format[3]];
|
||||
}else{
|
||||
imgd[i] = red;
|
||||
imgd[i + 1] = green;
|
||||
imgd[i + 2] = blue;
|
||||
imgd[i + 3] = alpha;
|
||||
}
|
||||
}
|
||||
|
||||
// Skip unused bytes in the current row
|
||||
skip(rowPadding);
|
||||
}
|
||||
|
||||
if(status == Status::ERROR) return;
|
||||
status = Status::OK;
|
||||
};
|
||||
|
||||
void Parser::clearImgd(){ imgd = nullptr; }
|
||||
int32_t Parser::getWidth() const{ return w; }
|
||||
int32_t Parser::getHeight() const{ return h; }
|
||||
uint8_t *Parser::getImgd() const{ return imgd; }
|
||||
Status Parser::getStatus() const{ return status; }
|
||||
|
||||
string Parser::getErrMsg() const{
|
||||
return "Error while processing " + getOp() + " - " + err;
|
||||
}
|
||||
|
||||
template <typename T, bool check> inline T Parser::get(){
|
||||
if(check)
|
||||
CHECK_OVERRUN(ptr, sizeof(T), T);
|
||||
T val = *(T*)ptr;
|
||||
ptr += sizeof(T);
|
||||
return val;
|
||||
}
|
||||
|
||||
template <typename T, bool check> inline T Parser::get(uint8_t* pointer){
|
||||
if(check)
|
||||
CHECK_OVERRUN(pointer, sizeof(T), T);
|
||||
T val = *(T*)pointer;
|
||||
return val;
|
||||
}
|
||||
|
||||
string Parser::getStr(int size, bool reverse){
|
||||
CHECK_OVERRUN(ptr, size, string);
|
||||
string val = "";
|
||||
|
||||
while(size--){
|
||||
if(reverse) val = string(1, static_cast<char>(*ptr++)) + val;
|
||||
else val += static_cast<char>(*ptr++);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
inline void Parser::skip(int size){
|
||||
CHECK_OVERRUN(ptr, size, void);
|
||||
ptr += size;
|
||||
}
|
||||
|
||||
void Parser::calcMaskShift(uint32_t& shift, uint32_t& mask, double& multp){
|
||||
mask = U4();
|
||||
shift = 0;
|
||||
|
||||
if(mask == 0) return;
|
||||
|
||||
while(~mask & 1){
|
||||
mask >>= 1;
|
||||
shift++;
|
||||
}
|
||||
|
||||
E(mask & (mask + 1), "invalid color mask");
|
||||
|
||||
multp = 255. / mask;
|
||||
}
|
||||
|
||||
void Parser::setOp(string val){
|
||||
if(status != Status::EMPTY) return;
|
||||
op = val;
|
||||
}
|
||||
|
||||
string Parser::getOp() const{
|
||||
return op;
|
||||
}
|
||||
|
||||
void Parser::setErrUnsupported(string msg){
|
||||
setErr("unsupported " + msg);
|
||||
}
|
||||
|
||||
void Parser::setErrUnknown(string msg){
|
||||
setErr("unknown " + msg);
|
||||
}
|
||||
|
||||
void Parser::setErr(string msg){
|
||||
if(status != Status::EMPTY) return;
|
||||
err = msg;
|
||||
status = Status::ERROR;
|
||||
}
|
||||
|
||||
string Parser::getErr() const{
|
||||
return err;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_taggedTemplateLiteralLoose","strings","raw","slice"],"sources":["../../src/helpers/taggedTemplateLiteralLoose.ts"],"sourcesContent":["/* @minVersion 7.0.0-beta.0 */\n\nexport default function _taggedTemplateLiteralLoose(\n strings: readonly string[],\n raw?: readonly string[],\n): TemplateStringsArray {\n if (!raw) {\n raw = strings.slice(0);\n }\n // Loose: TemplateStringsArray['raw'] is readonly, so we have to cast it to any before assigning\n (strings as any).raw = raw;\n return strings as TemplateStringsArray;\n}\n"],"mappings":";;;;;;AAEe,SAASA,2BAA2BA,CACjDC,OAA0B,EAC1BC,GAAuB,EACD;EACtB,IAAI,CAACA,GAAG,EAAE;IACRA,GAAG,GAAGD,OAAO,CAACE,KAAK,CAAC,CAAC,CAAC;EACxB;EAECF,OAAO,CAASC,GAAG,GAAGA,GAAG;EAC1B,OAAOD,OAAO;AAChB","ignoreList":[]}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,325 @@
|
||||
/**
|
||||
* @fileoverview enforce or disallow capitalization of the first letter of a comment
|
||||
* @author Kevin Partington
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const DEFAULT_IGNORE_PATTERN = astUtils.COMMENTS_IGNORE_PATTERN,
|
||||
WHITESPACE = /\s/gu,
|
||||
MAYBE_URL = /^\s*[^:/?#\s]+:\/\/[^?#]/u, // TODO: Combine w/ max-len pattern?
|
||||
LETTER_PATTERN = /\p{L}/u;
|
||||
|
||||
/*
|
||||
* Base schema body for defining the basic capitalization rule, ignorePattern,
|
||||
* and ignoreInlineComments values.
|
||||
* This can be used in a few different ways in the actual schema.
|
||||
*/
|
||||
const SCHEMA_BODY = {
|
||||
type: "object",
|
||||
properties: {
|
||||
ignorePattern: {
|
||||
type: "string",
|
||||
},
|
||||
ignoreInlineComments: {
|
||||
type: "boolean",
|
||||
},
|
||||
ignoreConsecutiveComments: {
|
||||
type: "boolean",
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
};
|
||||
const DEFAULTS = {
|
||||
ignorePattern: "",
|
||||
ignoreInlineComments: false,
|
||||
ignoreConsecutiveComments: false,
|
||||
};
|
||||
|
||||
/**
|
||||
* Get normalized options for either block or line comments from the given
|
||||
* user-provided options.
|
||||
* - If the user-provided options is just a string, returns a normalized
|
||||
* set of options using default values for all other options.
|
||||
* - If the user-provided options is an object, then a normalized option
|
||||
* set is returned. Options specified in overrides will take priority
|
||||
* over options specified in the main options object, which will in
|
||||
* turn take priority over the rule's defaults.
|
||||
* @param {Object|string} rawOptions The user-provided options.
|
||||
* @param {string} which Either "line" or "block".
|
||||
* @returns {Object} The normalized options.
|
||||
*/
|
||||
function getNormalizedOptions(rawOptions, which) {
|
||||
return Object.assign({}, DEFAULTS, rawOptions[which] || rawOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get normalized options for block and line comments.
|
||||
* @param {Object|string} rawOptions The user-provided options.
|
||||
* @returns {Object} An object with "Line" and "Block" keys and corresponding
|
||||
* normalized options objects.
|
||||
*/
|
||||
function getAllNormalizedOptions(rawOptions = {}) {
|
||||
return {
|
||||
Line: getNormalizedOptions(rawOptions, "line"),
|
||||
Block: getNormalizedOptions(rawOptions, "block"),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a regular expression for each ignorePattern defined in the rule
|
||||
* options.
|
||||
*
|
||||
* This is done in order to avoid invoking the RegExp constructor repeatedly.
|
||||
* @param {Object} normalizedOptions The normalized rule options.
|
||||
* @returns {void}
|
||||
*/
|
||||
function createRegExpForIgnorePatterns(normalizedOptions) {
|
||||
Object.keys(normalizedOptions).forEach(key => {
|
||||
const ignorePatternStr = normalizedOptions[key].ignorePattern;
|
||||
|
||||
if (ignorePatternStr) {
|
||||
const regExp = RegExp(`^\\s*(?:${ignorePatternStr})`, "u");
|
||||
|
||||
normalizedOptions[key].ignorePatternRegExp = regExp;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Enforce or disallow capitalization of the first letter of a comment",
|
||||
recommended: false,
|
||||
frozen: true,
|
||||
url: "https://eslint.org/docs/latest/rules/capitalized-comments",
|
||||
},
|
||||
|
||||
fixable: "code",
|
||||
|
||||
schema: [
|
||||
{ enum: ["always", "never"] },
|
||||
{
|
||||
oneOf: [
|
||||
SCHEMA_BODY,
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
line: SCHEMA_BODY,
|
||||
block: SCHEMA_BODY,
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
messages: {
|
||||
unexpectedLowercaseComment:
|
||||
"Comments should not begin with a lowercase character.",
|
||||
unexpectedUppercaseComment:
|
||||
"Comments should not begin with an uppercase character.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const capitalize = context.options[0] || "always",
|
||||
normalizedOptions = getAllNormalizedOptions(context.options[1]),
|
||||
sourceCode = context.sourceCode;
|
||||
|
||||
createRegExpForIgnorePatterns(normalizedOptions);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helpers
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Checks whether a comment is an inline comment.
|
||||
*
|
||||
* For the purpose of this rule, a comment is inline if:
|
||||
* 1. The comment is preceded by a token on the same line; and
|
||||
* 2. The command is followed by a token on the same line.
|
||||
*
|
||||
* Note that the comment itself need not be single-line!
|
||||
*
|
||||
* Also, it follows from this definition that only block comments can
|
||||
* be considered as possibly inline. This is because line comments
|
||||
* would consume any following tokens on the same line as the comment.
|
||||
* @param {ASTNode} comment The comment node to check.
|
||||
* @returns {boolean} True if the comment is an inline comment, false
|
||||
* otherwise.
|
||||
*/
|
||||
function isInlineComment(comment) {
|
||||
const previousToken = sourceCode.getTokenBefore(comment, {
|
||||
includeComments: true,
|
||||
}),
|
||||
nextToken = sourceCode.getTokenAfter(comment, {
|
||||
includeComments: true,
|
||||
});
|
||||
|
||||
return Boolean(
|
||||
previousToken &&
|
||||
nextToken &&
|
||||
comment.loc.start.line === previousToken.loc.end.line &&
|
||||
comment.loc.end.line === nextToken.loc.start.line,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a comment follows another comment.
|
||||
* @param {ASTNode} comment The comment to check.
|
||||
* @returns {boolean} True if the comment follows a valid comment.
|
||||
*/
|
||||
function isConsecutiveComment(comment) {
|
||||
const previousTokenOrComment = sourceCode.getTokenBefore(comment, {
|
||||
includeComments: true,
|
||||
});
|
||||
|
||||
return Boolean(
|
||||
previousTokenOrComment &&
|
||||
["Block", "Line"].includes(previousTokenOrComment.type),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a comment to determine if it is valid for this rule.
|
||||
* @param {ASTNode} comment The comment node to process.
|
||||
* @param {Object} options The options for checking this comment.
|
||||
* @returns {boolean} True if the comment is valid, false otherwise.
|
||||
*/
|
||||
function isCommentValid(comment, options) {
|
||||
// 1. Check for default ignore pattern.
|
||||
if (DEFAULT_IGNORE_PATTERN.test(comment.value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 2. Check for custom ignore pattern.
|
||||
const commentWithoutAsterisks = comment.value.replace(/\*/gu, "");
|
||||
|
||||
if (
|
||||
options.ignorePatternRegExp &&
|
||||
options.ignorePatternRegExp.test(commentWithoutAsterisks)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 3. Check for inline comments.
|
||||
if (options.ignoreInlineComments && isInlineComment(comment)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 4. Is this a consecutive comment (and are we tolerating those)?
|
||||
if (
|
||||
options.ignoreConsecutiveComments &&
|
||||
isConsecutiveComment(comment)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 5. Does the comment start with a possible URL?
|
||||
if (MAYBE_URL.test(commentWithoutAsterisks)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 6. Is the initial word character a letter?
|
||||
const commentWordCharsOnly = commentWithoutAsterisks.replace(
|
||||
WHITESPACE,
|
||||
"",
|
||||
);
|
||||
|
||||
if (commentWordCharsOnly.length === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the first Unicode character (1 or 2 code units).
|
||||
const [firstWordChar] = commentWordCharsOnly;
|
||||
|
||||
if (!LETTER_PATTERN.test(firstWordChar)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 7. Check the case of the initial word character.
|
||||
const isUppercase =
|
||||
firstWordChar !== firstWordChar.toLocaleLowerCase(),
|
||||
isLowercase =
|
||||
firstWordChar !== firstWordChar.toLocaleUpperCase();
|
||||
|
||||
if (capitalize === "always" && isLowercase) {
|
||||
return false;
|
||||
}
|
||||
if (capitalize === "never" && isUppercase) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a comment to determine if it needs to be reported.
|
||||
* @param {ASTNode} comment The comment node to process.
|
||||
* @returns {void}
|
||||
*/
|
||||
function processComment(comment) {
|
||||
const options = normalizedOptions[comment.type],
|
||||
commentValid = isCommentValid(comment, options);
|
||||
|
||||
if (!commentValid) {
|
||||
const messageId =
|
||||
capitalize === "always"
|
||||
? "unexpectedLowercaseComment"
|
||||
: "unexpectedUppercaseComment";
|
||||
|
||||
context.report({
|
||||
node: null, // Intentionally using loc instead
|
||||
loc: comment.loc,
|
||||
messageId,
|
||||
fix(fixer) {
|
||||
const match = comment.value.match(LETTER_PATTERN);
|
||||
const char = match[0];
|
||||
|
||||
// Offset match.index by 2 to account for the first 2 characters that start the comment (// or /*)
|
||||
const charIndex = comment.range[0] + match.index + 2;
|
||||
|
||||
return fixer.replaceTextRange(
|
||||
[charIndex, charIndex + char.length],
|
||||
capitalize === "always"
|
||||
? char.toLocaleUpperCase()
|
||||
: char.toLocaleLowerCase(),
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Public
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
return {
|
||||
Program() {
|
||||
const comments = sourceCode.getAllComments();
|
||||
|
||||
comments
|
||||
.filter(token => token.type !== "Shebang")
|
||||
.forEach(processComment);
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,400 @@
|
||||
/**
|
||||
* @fileoverview This rule should require or disallow spaces before or after unary operations.
|
||||
* @author Marcin Kumorek
|
||||
* @deprecated in ESLint v8.53.0
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
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: "10.0.0",
|
||||
replacedBy: [
|
||||
{
|
||||
message:
|
||||
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
||||
url: "https://eslint.style/guide/migration",
|
||||
plugin: {
|
||||
name: "@stylistic/eslint-plugin-js",
|
||||
url: "https://eslint.style/packages/js",
|
||||
},
|
||||
rule: {
|
||||
name: "space-unary-ops",
|
||||
url: "https://eslint.style/rules/js/space-unary-ops",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "layout",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Enforce consistent spacing before or after unary operators",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/space-unary-ops",
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
words: {
|
||||
type: "boolean",
|
||||
default: true,
|
||||
},
|
||||
nonwords: {
|
||||
type: "boolean",
|
||||
default: false,
|
||||
},
|
||||
overrides: {
|
||||
type: "object",
|
||||
additionalProperties: {
|
||||
type: "boolean",
|
||||
},
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
messages: {
|
||||
unexpectedBefore:
|
||||
"Unexpected space before unary operator '{{operator}}'.",
|
||||
unexpectedAfter:
|
||||
"Unexpected space after unary operator '{{operator}}'.",
|
||||
unexpectedAfterWord:
|
||||
"Unexpected space after unary word operator '{{word}}'.",
|
||||
wordOperator:
|
||||
"Unary word operator '{{word}}' must be followed by whitespace.",
|
||||
operator:
|
||||
"Unary operator '{{operator}}' must be followed by whitespace.",
|
||||
beforeUnaryExpressions:
|
||||
"Space is required before unary expressions '{{token}}'.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const options = context.options[0] || { words: true, nonwords: false };
|
||||
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Check if the node is the first "!" in a "!!" convert to Boolean expression
|
||||
* @param {ASTnode} node AST node
|
||||
* @returns {boolean} Whether or not the node is first "!" in "!!"
|
||||
*/
|
||||
function isFirstBangInBangBangExpression(node) {
|
||||
return (
|
||||
node &&
|
||||
node.type === "UnaryExpression" &&
|
||||
node.argument.operator === "!" &&
|
||||
node.argument &&
|
||||
node.argument.type === "UnaryExpression" &&
|
||||
node.argument.operator === "!"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an override exists for a given operator.
|
||||
* @param {string} operator Operator
|
||||
* @returns {boolean} Whether or not an override has been provided for the operator
|
||||
*/
|
||||
function overrideExistsForOperator(operator) {
|
||||
return (
|
||||
options.overrides && Object.hasOwn(options.overrides, operator)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value that the override was set to for this operator
|
||||
* @param {string} operator Operator
|
||||
* @returns {boolean} Whether or not an override enforces a space with this operator
|
||||
*/
|
||||
function overrideEnforcesSpaces(operator) {
|
||||
return options.overrides[operator];
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify Unary Word Operator has spaces after the word operator
|
||||
* @param {ASTnode} node AST node
|
||||
* @param {Object} firstToken first token from the AST node
|
||||
* @param {Object} secondToken second token from the AST node
|
||||
* @param {string} word The word to be used for reporting
|
||||
* @returns {void}
|
||||
*/
|
||||
function verifyWordHasSpaces(node, firstToken, secondToken, word) {
|
||||
if (secondToken.range[0] === firstToken.range[1]) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "wordOperator",
|
||||
data: {
|
||||
word,
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(firstToken, " ");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify Unary Word Operator doesn't have spaces after the word operator
|
||||
* @param {ASTnode} node AST node
|
||||
* @param {Object} firstToken first token from the AST node
|
||||
* @param {Object} secondToken second token from the AST node
|
||||
* @param {string} word The word to be used for reporting
|
||||
* @returns {void}
|
||||
*/
|
||||
function verifyWordDoesntHaveSpaces(
|
||||
node,
|
||||
firstToken,
|
||||
secondToken,
|
||||
word,
|
||||
) {
|
||||
if (astUtils.canTokensBeAdjacent(firstToken, secondToken)) {
|
||||
if (secondToken.range[0] > firstToken.range[1]) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpectedAfterWord",
|
||||
data: {
|
||||
word,
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([
|
||||
firstToken.range[1],
|
||||
secondToken.range[0],
|
||||
]);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Unary Word Operators for spaces after the word operator
|
||||
* @param {ASTnode} node AST node
|
||||
* @param {Object} firstToken first token from the AST node
|
||||
* @param {Object} secondToken second token from the AST node
|
||||
* @param {string} word The word to be used for reporting
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkUnaryWordOperatorForSpaces(
|
||||
node,
|
||||
firstToken,
|
||||
secondToken,
|
||||
word,
|
||||
) {
|
||||
if (overrideExistsForOperator(word)) {
|
||||
if (overrideEnforcesSpaces(word)) {
|
||||
verifyWordHasSpaces(node, firstToken, secondToken, word);
|
||||
} else {
|
||||
verifyWordDoesntHaveSpaces(
|
||||
node,
|
||||
firstToken,
|
||||
secondToken,
|
||||
word,
|
||||
);
|
||||
}
|
||||
} else if (options.words) {
|
||||
verifyWordHasSpaces(node, firstToken, secondToken, word);
|
||||
} else {
|
||||
verifyWordDoesntHaveSpaces(node, firstToken, secondToken, word);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies YieldExpressions satisfy spacing requirements
|
||||
* @param {ASTnode} node AST node
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkForSpacesAfterYield(node) {
|
||||
const tokens = sourceCode.getFirstTokens(node, 3),
|
||||
word = "yield";
|
||||
|
||||
if (!node.argument || node.delegate) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkUnaryWordOperatorForSpaces(node, tokens[0], tokens[1], word);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies AwaitExpressions satisfy spacing requirements
|
||||
* @param {ASTNode} node AwaitExpression AST node
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkForSpacesAfterAwait(node) {
|
||||
const tokens = sourceCode.getFirstTokens(node, 3);
|
||||
|
||||
checkUnaryWordOperatorForSpaces(
|
||||
node,
|
||||
tokens[0],
|
||||
tokens[1],
|
||||
"await",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies UnaryExpression, UpdateExpression and NewExpression have spaces before or after the operator
|
||||
* @param {ASTnode} node AST node
|
||||
* @param {Object} firstToken First token in the expression
|
||||
* @param {Object} secondToken Second token in the expression
|
||||
* @returns {void}
|
||||
*/
|
||||
function verifyNonWordsHaveSpaces(node, firstToken, secondToken) {
|
||||
if (node.prefix) {
|
||||
if (isFirstBangInBangBangExpression(node)) {
|
||||
return;
|
||||
}
|
||||
if (firstToken.range[1] === secondToken.range[0]) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "operator",
|
||||
data: {
|
||||
operator: firstToken.value,
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextAfter(firstToken, " ");
|
||||
},
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (firstToken.range[1] === secondToken.range[0]) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "beforeUnaryExpressions",
|
||||
data: {
|
||||
token: secondToken.value,
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBefore(secondToken, " ");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies UnaryExpression, UpdateExpression and NewExpression don't have spaces before or after the operator
|
||||
* @param {ASTnode} node AST node
|
||||
* @param {Object} firstToken First token in the expression
|
||||
* @param {Object} secondToken Second token in the expression
|
||||
* @returns {void}
|
||||
*/
|
||||
function verifyNonWordsDontHaveSpaces(node, firstToken, secondToken) {
|
||||
if (node.prefix) {
|
||||
if (secondToken.range[0] > firstToken.range[1]) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpectedAfter",
|
||||
data: {
|
||||
operator: firstToken.value,
|
||||
},
|
||||
fix(fixer) {
|
||||
if (
|
||||
astUtils.canTokensBeAdjacent(
|
||||
firstToken,
|
||||
secondToken,
|
||||
)
|
||||
) {
|
||||
return fixer.removeRange([
|
||||
firstToken.range[1],
|
||||
secondToken.range[0],
|
||||
]);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (secondToken.range[0] > firstToken.range[1]) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpectedBefore",
|
||||
data: {
|
||||
operator: secondToken.value,
|
||||
},
|
||||
fix(fixer) {
|
||||
return fixer.removeRange([
|
||||
firstToken.range[1],
|
||||
secondToken.range[0],
|
||||
]);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies UnaryExpression, UpdateExpression and NewExpression satisfy spacing requirements
|
||||
* @param {ASTnode} node AST node
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkForSpaces(node) {
|
||||
const tokens =
|
||||
node.type === "UpdateExpression" && !node.prefix
|
||||
? sourceCode.getLastTokens(node, 2)
|
||||
: sourceCode.getFirstTokens(node, 2);
|
||||
const firstToken = tokens[0];
|
||||
const secondToken = tokens[1];
|
||||
|
||||
if (
|
||||
(node.type === "NewExpression" || node.prefix) &&
|
||||
firstToken.type === "Keyword"
|
||||
) {
|
||||
checkUnaryWordOperatorForSpaces(
|
||||
node,
|
||||
firstToken,
|
||||
secondToken,
|
||||
firstToken.value,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const operator = node.prefix ? tokens[0].value : tokens[1].value;
|
||||
|
||||
if (overrideExistsForOperator(operator)) {
|
||||
if (overrideEnforcesSpaces(operator)) {
|
||||
verifyNonWordsHaveSpaces(node, firstToken, secondToken);
|
||||
} else {
|
||||
verifyNonWordsDontHaveSpaces(node, firstToken, secondToken);
|
||||
}
|
||||
} else if (options.nonwords) {
|
||||
verifyNonWordsHaveSpaces(node, firstToken, secondToken);
|
||||
} else {
|
||||
verifyNonWordsDontHaveSpaces(node, firstToken, secondToken);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
return {
|
||||
UnaryExpression: checkForSpaces,
|
||||
UpdateExpression: checkForSpaces,
|
||||
NewExpression: checkForSpaces,
|
||||
YieldExpression: checkForSpacesAfterYield,
|
||||
AwaitExpression: checkForSpacesAfterAwait,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"72":0.00121,"101":0.00121,"115":0.04356,"121":0.00121,"122":0.00121,"123":0.00242,"125":0.00121,"128":0.00242,"131":0.00121,"133":0.00242,"134":0.00121,"135":0.02057,"136":0.06776,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 102 103 104 105 106 107 108 109 110 111 112 113 114 116 117 118 119 120 124 126 127 129 130 132 137 138 139 140 3.5 3.6"},D:{"11":0.01452,"21":0.00121,"38":0.00605,"43":0.00484,"47":0.00121,"53":0.00121,"55":0.00121,"56":0.00726,"58":0.00968,"63":0.00121,"64":0.00121,"65":0.00605,"66":0.00242,"68":0.00242,"69":0.00605,"70":0.00605,"71":0.00121,"72":0.00242,"73":0.0121,"74":0.00121,"75":0.00605,"76":0.00121,"77":0.00121,"78":0.00121,"79":0.02783,"80":0.00242,"81":0.00242,"83":0.03025,"85":0.00121,"86":0.00242,"87":0.04356,"88":0.00363,"89":0.00242,"90":0.00242,"91":0.01815,"92":0.00121,"93":0.00242,"94":0.01573,"95":0.02057,"96":0.00242,"97":0.00242,"98":0.05566,"99":0.00121,"100":0.00363,"101":0.00242,"102":0.01089,"103":0.03025,"104":0.00726,"105":0.00363,"106":0.00484,"107":0.00363,"108":0.01694,"109":0.4719,"110":0.02057,"111":0.00726,"113":0.00363,"114":0.01694,"116":0.00726,"118":0.00484,"119":0.03146,"120":0.01452,"121":0.00484,"122":0.00968,"123":0.0121,"124":0.00847,"125":0.04719,"126":0.02057,"127":0.01331,"128":0.01694,"129":0.00484,"130":0.01452,"131":0.0484,"132":0.05203,"133":0.94743,"134":2.13686,"135":0.00847,"136":0.00242,_:"4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 39 40 41 42 44 45 46 48 49 50 51 52 54 57 59 60 61 62 67 84 112 115 117 137 138"},F:{"46":0.00121,"79":0.00121,"85":0.00121,"87":0.00847,"88":0.00605,"95":0.00726,"116":0.02783,"117":0.11132,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 80 81 82 83 84 86 89 90 91 92 93 94 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"18":0.00121,"92":0.00484,"102":0.00121,"109":0.00484,"114":0.00242,"119":0.00121,"122":0.00121,"124":0.00121,"128":0.00121,"130":0.00121,"131":0.00484,"132":0.03388,"133":0.0968,"134":0.23232,_:"12 13 14 15 16 17 79 80 81 83 84 85 86 87 88 89 90 91 93 94 95 96 97 98 99 100 101 103 104 105 106 107 108 110 111 112 113 115 116 117 118 120 121 123 125 126 127 129"},E:{"14":0.00242,_:"0 4 5 6 7 8 9 10 11 12 13 15 3.1 3.2 6.1 7.1 9.1 10.1 11.1 15.2-15.3","5.1":0.00484,"12.1":0.00121,"13.1":0.00363,"14.1":0.00605,"15.1":0.00121,"15.4":0.00121,"15.5":0.00484,"15.6":0.02178,"16.0":0.00242,"16.1":0.00847,"16.2":0.00726,"16.3":0.01694,"16.4":0.00242,"16.5":0.00363,"16.6":0.03751,"17.0":0.00121,"17.1":0.01694,"17.2":0.00363,"17.3":0.00605,"17.4":0.00847,"17.5":0.03025,"17.6":0.06776,"18.0":0.0121,"18.1":0.05687,"18.2":0.01815,"18.3":0.36179,"18.4":0.00484},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00266,"5.0-5.1":0,"6.0-6.1":0.00799,"7.0-7.1":0.00533,"8.1-8.4":0,"9.0-9.2":0.004,"9.3":0.01864,"10.0-10.2":0.00133,"10.3":0.03063,"11.0-11.2":0.14116,"11.3-11.4":0.00932,"12.0-12.1":0.00533,"12.2-12.5":0.13184,"13.0-13.1":0.00266,"13.2":0.004,"13.3":0.00533,"13.4-13.7":0.01864,"14.0-14.4":0.04661,"14.5-14.8":0.05593,"15.0-15.1":0.03063,"15.2-15.3":0.03063,"15.4":0.03729,"15.5":0.04261,"15.6-15.8":0.52468,"16.0":0.07457,"16.1":0.15314,"16.2":0.0799,"16.3":0.1385,"16.4":0.03063,"16.5":0.05726,"16.6-16.7":0.6219,"17.0":0.03729,"17.1":0.06658,"17.2":0.0506,"17.3":0.07058,"17.4":0.14116,"17.5":0.31428,"17.6-17.7":0.9122,"18.0":0.25568,"18.1":0.8363,"18.2":0.3742,"18.3":7.82099,"18.4":0.11586},P:{"4":0.03089,"20":0.0206,"21":0.04119,"22":0.06179,"23":0.11328,"24":0.07209,"25":0.10298,"26":0.31924,"27":3.06883,_:"5.0-5.4 8.2 10.1 12.0","6.2-6.4":0.0103,"7.2-7.4":0.10298,"9.2":0.0103,"11.1-11.2":0.0206,"13.0":0.03089,"14.0":0.0206,"15.0":0.0103,"16.0":0.0206,"17.0":0.03089,"18.0":0.0103,"19.0":0.0206},I:{"0":0.03509,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00001,"4.4":0,"4.4.3-4.4.4":0.00004},K:{"0":0.71199,_:"10 11 12 11.1 11.5 12.1"},A:{"8":0.00156,"11":0.00933,_:"6 7 9 10 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.10548},Q:{_:"14.9"},O:{"0":0.33402},H:{"0":0},L:{"0":75.28855}};
|
||||
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* @fileoverview Rule to flag use of alert, confirm, prompt
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const {
|
||||
getStaticPropertyName: getPropertyName,
|
||||
getVariableByName,
|
||||
skipChainExpression,
|
||||
} = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Checks if the given name is a prohibited identifier.
|
||||
* @param {string} name The name to check
|
||||
* @returns {boolean} Whether or not the name is prohibited.
|
||||
*/
|
||||
function isProhibitedIdentifier(name) {
|
||||
return /^(alert|confirm|prompt)$/u.test(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the eslint-scope reference in the given scope.
|
||||
* @param {Object} scope The scope to search.
|
||||
* @param {ASTNode} node The identifier node.
|
||||
* @returns {Reference|null} Returns the found reference or null if none were found.
|
||||
*/
|
||||
function findReference(scope, node) {
|
||||
const references = scope.references.filter(
|
||||
reference =>
|
||||
reference.identifier.range[0] === node.range[0] &&
|
||||
reference.identifier.range[1] === node.range[1],
|
||||
);
|
||||
|
||||
if (references.length === 1) {
|
||||
return references[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given identifier node is shadowed in the given scope.
|
||||
* @param {Object} scope The current scope.
|
||||
* @param {string} node The identifier node to check
|
||||
* @returns {boolean} Whether or not the name is shadowed.
|
||||
*/
|
||||
function isShadowed(scope, node) {
|
||||
const reference = findReference(scope, node);
|
||||
|
||||
return (
|
||||
reference && reference.resolved && reference.resolved.defs.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given identifier node is a ThisExpression in the global scope or the global window property.
|
||||
* @param {Object} scope The current scope.
|
||||
* @param {string} node The identifier node to check
|
||||
* @returns {boolean} Whether or not the node is a reference to the global object.
|
||||
*/
|
||||
function isGlobalThisReferenceOrGlobalWindow(scope, node) {
|
||||
if (scope.type === "global" && node.type === "ThisExpression") {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
node.type === "Identifier" &&
|
||||
(node.name === "window" ||
|
||||
(node.name === "globalThis" &&
|
||||
getVariableByName(scope, "globalThis")))
|
||||
) {
|
||||
return !isShadowed(scope, node);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Disallow the use of `alert`, `confirm`, and `prompt`",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-alert",
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
unexpected: "Unexpected {{name}}.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
return {
|
||||
CallExpression(node) {
|
||||
const callee = skipChainExpression(node.callee),
|
||||
currentScope = sourceCode.getScope(node);
|
||||
|
||||
// without window.
|
||||
if (callee.type === "Identifier") {
|
||||
const name = callee.name;
|
||||
|
||||
if (
|
||||
!isShadowed(currentScope, callee) &&
|
||||
isProhibitedIdentifier(callee.name)
|
||||
) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpected",
|
||||
data: { name },
|
||||
});
|
||||
}
|
||||
} else if (
|
||||
callee.type === "MemberExpression" &&
|
||||
isGlobalThisReferenceOrGlobalWindow(
|
||||
currentScope,
|
||||
callee.object,
|
||||
)
|
||||
) {
|
||||
const name = getPropertyName(callee);
|
||||
|
||||
if (isProhibitedIdentifier(name)) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "unexpected",
|
||||
data: { name },
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user