summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/string-width
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/string-width')
-rw-r--r--tools/node_modules/eslint/node_modules/string-width/index.js17
-rw-r--r--tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/index.js4
-rw-r--r--tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/license9
-rw-r--r--tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/package.json61
-rw-r--r--tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/readme.md39
-rw-r--r--tools/node_modules/eslint/node_modules/string-width/package.json21
-rw-r--r--tools/node_modules/eslint/node_modules/string-width/readme.md8
7 files changed, 27 insertions, 132 deletions
diff --git a/tools/node_modules/eslint/node_modules/string-width/index.js b/tools/node_modules/eslint/node_modules/string-width/index.js
index bbc49d29b1..a348067f03 100644
--- a/tools/node_modules/eslint/node_modules/string-width/index.js
+++ b/tools/node_modules/eslint/node_modules/string-width/index.js
@@ -1,18 +1,21 @@
'use strict';
const stripAnsi = require('strip-ansi');
const isFullwidthCodePoint = require('is-fullwidth-code-point');
+const emojiRegex = require('emoji-regex');
-module.exports = str => {
- if (typeof str !== 'string' || str.length === 0) {
+const stringWidth = string => {
+ string = string.replace(emojiRegex(), ' ');
+
+ if (typeof string !== 'string' || string.length === 0) {
return 0;
}
- str = stripAnsi(str);
+ string = stripAnsi(string);
let width = 0;
- for (let i = 0; i < str.length; i++) {
- const code = str.codePointAt(i);
+ for (let i = 0; i < string.length; i++) {
+ const code = string.codePointAt(i);
// Ignore control characters
if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) {
@@ -34,3 +37,7 @@ module.exports = str => {
return width;
};
+
+module.exports = stringWidth;
+// TODO: remove this in the next major version
+module.exports.default = stringWidth;
diff --git a/tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/index.js b/tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/index.js
deleted file mode 100644
index 96e0292c8e..0000000000
--- a/tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/index.js
+++ /dev/null
@@ -1,4 +0,0 @@
-'use strict';
-const ansiRegex = require('ansi-regex');
-
-module.exports = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input;
diff --git a/tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/license b/tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/license
deleted file mode 100644
index e7af2f7710..0000000000
--- a/tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/license
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.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.
diff --git a/tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/package.json b/tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/package.json
deleted file mode 100644
index 472b3021ed..0000000000
--- a/tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/package.json
+++ /dev/null
@@ -1,61 +0,0 @@
-{
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
- },
- "bugs": {
- "url": "https://github.com/chalk/strip-ansi/issues"
- },
- "bundleDependencies": false,
- "dependencies": {
- "ansi-regex": "^3.0.0"
- },
- "deprecated": false,
- "description": "Strip ANSI escape codes",
- "devDependencies": {
- "ava": "*",
- "xo": "*"
- },
- "engines": {
- "node": ">=4"
- },
- "files": [
- "index.js"
- ],
- "homepage": "https://github.com/chalk/strip-ansi#readme",
- "keywords": [
- "strip",
- "trim",
- "remove",
- "ansi",
- "styles",
- "color",
- "colour",
- "colors",
- "terminal",
- "console",
- "string",
- "tty",
- "escape",
- "formatting",
- "rgb",
- "256",
- "shell",
- "xterm",
- "log",
- "logging",
- "command-line",
- "text"
- ],
- "license": "MIT",
- "name": "strip-ansi",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/chalk/strip-ansi.git"
- },
- "scripts": {
- "test": "xo && ava"
- },
- "version": "4.0.0"
-} \ No newline at end of file
diff --git a/tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/readme.md b/tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/readme.md
deleted file mode 100644
index dc76f0cb1a..0000000000
--- a/tools/node_modules/eslint/node_modules/string-width/node_modules/strip-ansi/readme.md
+++ /dev/null
@@ -1,39 +0,0 @@
-# strip-ansi [![Build Status](https://travis-ci.org/chalk/strip-ansi.svg?branch=master)](https://travis-ci.org/chalk/strip-ansi)
-
-> Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
-
-
-## Install
-
-```
-$ npm install strip-ansi
-```
-
-
-## Usage
-
-```js
-const stripAnsi = require('strip-ansi');
-
-stripAnsi('\u001B[4mUnicorn\u001B[0m');
-//=> 'Unicorn'
-```
-
-
-## Related
-
-- [strip-ansi-cli](https://github.com/chalk/strip-ansi-cli) - CLI for this module
-- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
-- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
-- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
-
-
-## Maintainers
-
-- [Sindre Sorhus](https://github.com/sindresorhus)
-- [Josh Junon](https://github.com/qix-)
-
-
-## License
-
-MIT
diff --git a/tools/node_modules/eslint/node_modules/string-width/package.json b/tools/node_modules/eslint/node_modules/string-width/package.json
index f076208ad3..9ef5253e54 100644
--- a/tools/node_modules/eslint/node_modules/string-width/package.json
+++ b/tools/node_modules/eslint/node_modules/string-width/package.json
@@ -9,27 +9,28 @@
},
"bundleDependencies": false,
"dependencies": {
- "is-fullwidth-code-point": "^2.0.0",
- "strip-ansi": "^4.0.0"
+ "emoji-regex": "^8.0.0",
+ "is-fullwidth-code-point": "^3.0.0",
+ "strip-ansi": "^5.2.0"
},
"deprecated": false,
"description": "Get the visual width of a string - the number of columns required to display it",
"devDependencies": {
- "ava": "*",
- "xo": "*"
+ "ava": "^1.4.1",
+ "tsd": "^0.7.1",
+ "xo": "^0.24.0"
},
"engines": {
- "node": ">=4"
+ "node": ">=8"
},
"files": [
- "index.js"
+ "index.js",
+ "index.d.ts"
],
"homepage": "https://github.com/sindresorhus/string-width#readme",
"keywords": [
"string",
- "str",
"character",
- "char",
"unicode",
"width",
"visual",
@@ -58,7 +59,7 @@
"url": "git+https://github.com/sindresorhus/string-width.git"
},
"scripts": {
- "test": "xo && ava"
+ "test": "xo && ava && tsd"
},
- "version": "2.1.1"
+ "version": "4.1.0"
} \ No newline at end of file
diff --git a/tools/node_modules/eslint/node_modules/string-width/readme.md b/tools/node_modules/eslint/node_modules/string-width/readme.md
index df5b7199f9..35a0c0377a 100644
--- a/tools/node_modules/eslint/node_modules/string-width/readme.md
+++ b/tools/node_modules/eslint/node_modules/string-width/readme.md
@@ -19,14 +19,14 @@ $ npm install string-width
```js
const stringWidth = require('string-width');
+stringWidth('a');
+//=> 1
+
stringWidth('古');
//=> 2
-stringWidth('\u001b[1m古\u001b[22m');
+stringWidth('\u001B[1m古\u001B[22m');
//=> 2
-
-stringWidth('a');
-//=> 1
```