What could cause eslint-plugin-prettier to report error on CircleCI but be silent locally?

Ole*_*hai 6 circleci eslint prettier

I have to migrate from CircleCI 1.0 to 2.0. After I have changed the old configuration to the new one, build failed because of eslint-plugin-prettier reported prettier spacing violations.

MyProject - is my GitHub repo and it contains a folder client which has all front-end code which I want to build on CI. In client folder there are

.eslintrc.json

...
"extends": ["airbnb", "prettier"],
"plugins": ["prettier"],
...
Run Code Online (Sandbox Code Playgroud)

.prettierrc

{
    "tabWidth": 4,
    "trailingComma": "all",
    "singleQuote": true
}
Run Code Online (Sandbox Code Playgroud)

.gitattributes (I work on Windows 10) with the following code:

*.js text eol=crlf
*.jsx text eol=crlf
Run Code Online (Sandbox Code Playgroud)

and of course package.json

在此处输入图片说明

New CircleCI configuration:

version: 2

jobs:
  build:
    working_directory: ~/MyProject
    docker:
      - image: circleci/node:6.14.3-jessie-browsers
    steps:
      - checkout
      - run:
          name: Install Packages
          command: npm install
          working_directory: client
      - run:
          name: Test
          command: npm run validate
          working_directory: client
Run Code Online (Sandbox Code Playgroud)

Old CircleCI configuration:

## Customize dependencies
machine:
  node:
    version: 6.1.0

 # Remove cache before new build. It takes much time
 # but fixing a build which is broken long time ago (and not detected because of cache)  
 # is even more time consuming
dependencies:
  post:
   - rm -r ~/.npm 

## Customize test commands
test:
  override:
    - npm run validate

general:
  build_dir: client
Run Code Online (Sandbox Code Playgroud)

The build fails due to linting problems (all are about the number of spaces):

在此处输入图片说明

So, what could cause these errors? I am out of ideas here. I first thought it might be because .prettierrc was not found. However, when I deleted it for an experiment and run locally I got errors in all files in total more than 1000. While on CI with .prettierrc in place there are were only 188 in few files.

Ole*_*hai 9

我终于想通了。

我的package.json文件包含以下对 Prettier 的依赖: "prettier": "^1.11.1".

我不得不努力学习这个小符号的含义^。它允许安装与1.11.1. 就我而言,它安装在 CircleCI 2.0 上,为 Prettier1.14.2添加了新功能。

我相信它没有在 CircleCI 1.0 版和本地中断,因为缓存的 node_modules 包含与兼容的早期 Prettier 版本 1.11.1

这是关于语义版本控制的精彩视频