【问题标题】:Running prettier via eslint vs standalone will result in different outcomes通过 eslint 与独立运行更漂亮会导致不同的结果
【发布时间】:2021-11-13 03:39:56
【问题描述】:

我已将我的 eslint 配置为在我的 .eslintrc.js 中使用这样的 prettier:

  extends: [
    'plugin:@typescript-eslint/recommended',
    'plugin:prettier/recommended',
  ],

但是当我运行命令./node_modules/.bin/prettier -w src/ 时,它会重新格式化./node_modules/.bin/eslint --fix 没有更改它们的三个文件,或者在没有--fix 的情况下运行时,它不会抱怨它们的格式错误。

其中一个区别是独立运行prettier 会在一个文件的末尾添加一个空行,而 eslint 不是。

另一个区别是独立运行prettier会中断:

    await knex.raw(changeSequenceToRandom({ column: 'id', lowerBound: 1, higherBound: 25 }));

     await knex.raw(
             changeSequenceToRandom({ column: 'id', lowerBound: 1, higherBound: 25 }),
     );

在另外两个文件中,eslint 并没有抱怨它们再次被错误格式化。这是为什么?我是不是做错了什么?

【问题讨论】:

    标签: typescript eslint prettier


    【解决方案1】:

    似乎您缺少目标文件/文件夹。试试eslint ./src --fix

    【讨论】:

    • 同样只运行eslint --fix 对项目没有任何作用。
    猜你喜欢
    • 2018-05-13
    • 2021-04-08
    • 2019-08-06
    • 2020-12-24
    • 2020-12-05
    • 2020-10-19
    • 2019-01-23
    • 2020-02-13
    • 2021-06-02
    相关资源
    最近更新 更多