Coder Social home page Coder Social logo

sean529 / vscode-console-helper Goto Github PK

View Code? Open in Web Editor NEW
59.0 1.0 6.0 5.68 MB

15k+ 开发者正在使用的,一键输出 console.log 的 vscode 插件

License: BSD 3-Clause "New" or "Revised" License

TypeScript 100.00%
vscode-extension vscode vscode-plugin

vscode-console-helper's Introduction

 _   _  _____  _____     
| | | ||_   _|/  __ \  _ 
| | | |  | |  | /  \/ (_)
| | | |  | |  | |        
| |_| |  | |  | \__/\  _ 
 \___/   \_/   \____/ (_)
                         
                         
 _____  _____  _____    ___          _____    ___          _____  _____ 
/ __  \|  _  |/ __  \  /   |        |  _  |  /   |        |  _  ||  _  |
`' / /'| |/' |`' / /' / /| | ______ | |/' | / /| | ______ | |/' || |_| |
  / /  |  /| |  / /  / /_| ||______||  /| |/ /_| ||______||  /| |\____ |
./ /___\ |_/ /./ /___\___  |        \ |_/ /\___  |        \ |_/ /.___/ /
\_____/ \___/ \_____/    |_/         \___/     |_/         \___/ \____/

vscode-console-helper's People

Contributors

kang8 avatar sean529 avatar shine0917 avatar wchenonly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vscode-console-helper's Issues

[bug?]在选中的变量内容包含双引号时,应替换其中的双引号为单引号

Bug Report

在选中的变量内容包含双引号时,没有替换其中的双引号为单引号。进而代码报错,需要手动修改。

image

Current Behavior?

在选中的变量内容包含双引号时,没有替换其中的双引号为单引号。

Expected Behavior?

在选中的变量内容包含双引号时,应该替换其中的双引号为单引号。

Steps to reproduce [Optional]

Your Environment [Optional]

在选中变量上一行增加日志。

例如循环数组前,打印cols,目前只能打印在循环里面,会多次打印,不合理。期望在上一行打印日志
cols.forEach((item: any) => {

});

打印文件名添加相对路径的方式

image

如图,希望打印文件名的功能添加打印【相对路径的方式】,因为很多文件以index的方式命名,只显示文件名提示的信息不够,但是选择完整路径的话又显得累赘。

或者添加【文件+文件上级目录】的打印方式。

[feature]支持配置不需要一键移除的 console 类型

Feature Request

因为插件目前是默认移除了所有的 console 类型

const logRegex = /console.(log|debug|info|warn|error|assert|dir|dirxml|trace|group|groupEnd|time|timeEnd|profile|profileEnd|count)\(([\s\S]*?)\);?/g

但实际的代码业务中,部分 console 类型是需要被保留的。比如 console.error。

直接一键移除所有 console 有点太彻底了。

What does the proposed API examples?

英文逗号间隔的配置不需要被一键移除的 console(并且允许逗号后存在空格😜)

error, info, ...

Other reference [Optional]

Show Semi option doesn't work

As I understand the option "Show Semi" should display the semicolon symbol (;) at the end of console.log.
It doesn't work in my case.

VSCode: v1.63.0
console-helper: v2.4.14

新功能:自定义前缀插入所选变量上级函数或者类名

Feature Request

是否能添加两个配置项,这样便于区分这个变量从哪来的:

  1. 在日志消息中插入所选变量的外围类;
  2. 在日志消息中插入所选变量的封闭函数名;

参考 turbo-console-log

const onMessage = (type: string, data: any) => {
    console.log('[log]: onMessage -> data', data);
    console.log('[log]: onMessage -> type', type);
};

删除页面上所有 log 时不删除通过 window.console.log 方式调试的语句,增加这个配置选项

Feature Request

很不错的插件,赞一个~!

我在使用时有个需求希望作者考虑一下:

ESLint no-console 一样,我在项目中进行了下述配置:

'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off'

这可以让我避免在生产环境出现 console.log,但有某些情况需要在生产环境使用 log ,虽然可以用 configuration comments 禁止某行语法检查,但为了保持良好的编码习惯我会尽量避免使用 configuration comments ,转而用 window.console.log() 的语法,这样在项目当中可以更加明确表示我需要在生产环境输出的意思,并且这样使用也符合上面我写的 ESLint 规则,不会产生报错。

另外,如果有些代码是用的我上面所述的 configuration comments 方式,例如:

// eslint-disable-next-line
console.log('hello')
doSomeThing()

在删除所有 log 后会是这样:

// eslint-disable-next-line
doSomeThing()

这样的结果 ESLint 会忽略下面这行代码,如果这行代码有错误,将无法第一时间发现,严重的可能会将错误带到生产环境影响业务,所以除了保持良好编码习惯和风格之外,这也是我避免使用 configuration comments 的原因之一。

所以为了避免部分开发者使用了这种 comments 方式,也许上面这种情况作者也可以考虑处理一下。

What does the proposed API examples?

希望增加一个配置项,控制插件在删除时是否包含 window.console 语法。

考虑到不同项目有不同的需要,有些项目需要删除全部 console.log 而有些不需要,所以建议通过增加配置项的方式提供可选项。

同时考虑到旧版默认删除全部的行为,新增的配置项可以默认删除全部 console.log

使用ANSI 转义码(ANSI escape code)方式显示颜色

Feature Request

建议使用ANSI 转义码(ANSI escape code)方式显示颜色,在浏览器和Nodejs控制台都可以正确显示,当前颜色方案只能在浏览器中起作用。

What does the proposed API examples?

Other reference [Optional]

例如:下列代码在浏览器和控制台都可以显示:
console.info("\u001b[45m A \u001b[41m B \u001b[42m C \u001b[43m D \u001b[0m");

image

日志折行后无法删除

格式化代码后,格式类似如下,使用删除快捷键无法删除。
console.log(
"%c [ newDimensions ]",
"font-size:13px; background:pink; color:#bf2c9f;",
newDimensions
);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.