Skip to content
This repository was archived by the owner on Aug 7, 2023. It is now read-only.

Commit 747d7df

Browse files
authored
Merge pull request #1371 from aminya/global-eslint-fallback
2 parents 1676b9b + 748e8c4 commit 747d7df

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

.github/workflows/CI.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,16 @@ jobs:
7171
node-version: "12.x"
7272
- name: NPM install
7373
run: npm install
74-
- name: Build and Commit
75-
run: npm run build-commit
76-
# NOTE: uncomment when ready
77-
# - name: Release 🎉
78-
# uses: cycjimmy/semantic-release-action@v2
79-
# with:
80-
# extends: |
81-
# @semantic-release/apm-config
82-
# env:
83-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84-
# ATOM_ACCESS_TOKEN: ${{ secrets.ATOM_ACCESS_TOKEN }}
74+
# - name: Build and Commit
75+
# run: npm run build-commit
76+
- name: Release 🎉
77+
uses: cycjimmy/semantic-release-action@v2
78+
with:
79+
extends: |
80+
@semantic-release/apm-config
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
ATOM_ACCESS_TOKEN: ${{ secrets.ATOM_ACCESS_TOKEN }}
8584

8685
Skip:
8786
if: contains(github.event.head_commit.message, '[skip ci]')

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@
6565
},
6666
"global": {
6767
"type": "object",
68+
"collapsed": true,
6869
"order": 4,
6970
"title": "Global ESLint",
7071
"properties": {
7172
"useGlobalEslint": {
7273
"title": "Use global ESLint installation",
73-
"description": "Make sure you have it in your $PATH",
74+
"description": "Make sure you have it in your $PATH. ⚠️ Using the global ESLint install is heavily discouraged. If the installation is not found, linter-eslint will not work.",
7475
"type": "boolean",
7576
"default": false,
7677
"order": 1

spec/worker-helpers-spec.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@ describe('Worker Helpers', () => {
120120
})
121121

122122
it('cries if global eslint is not found', () => {
123-
expect(() => {
124-
const config = createConfig({
125-
global: { useGlobalEslint: true, globalNodePath: getFixturesPath('files') }
126-
})
127-
Helpers.getESLintInstance(getFixturesPath('local-eslint'), config)
128-
}).toThrow()
123+
const config = createConfig({
124+
global: { useGlobalEslint: true, globalNodePath: getFixturesPath('files') }
125+
})
126+
spyOn(console, 'error')
127+
Helpers.getESLintInstance(getFixturesPath('local-eslint'), config)
128+
expect(console.error).toHaveBeenCalledWith(`Global ESLint is not found, please ensure the global Node path is set correctly.
129+
If you wanted to use a local installation of Eslint, disable Global Eslint option in the linter-eslint config.`)
129130
})
130131

131132
it('tries to find a local eslint with nested node_modules', () => {

src/worker-helpers.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ function isDirectory(dirPath) {
4747
return isDir
4848
}
4949

50-
export function findESLintDirectory(modulesDir, config, projectPath) {
50+
export function findESLintDirectory(modulesDir, config, projectPath, fallback = false) {
5151
let eslintDir = null
5252
let locationType = null
53-
if (config.global.useGlobalEslint) {
53+
if (config.global.useGlobalEslint && !fallback) {
5454
locationType = 'global'
5555
const configGlobal = cleanPath(config.global.globalNodePath)
5656
const prefixPath = configGlobal || getNodePrefixPath()
@@ -79,7 +79,10 @@ export function findESLintDirectory(modulesDir, config, projectPath) {
7979
}
8080

8181
if (config.global.useGlobalEslint) {
82-
throw new Error('ESLint not found, please ensure the global Node path is set correctly.')
82+
// TODO push the error to the user
83+
console.error(`Global ESLint is not found, please ensure the global Node path is set correctly.
84+
If you wanted to use a local installation of Eslint, disable Global Eslint option in the linter-eslint config.`)
85+
findESLintDirectory(modulesDir, config, projectPath, true)
8386
}
8487

8588
return {

0 commit comments

Comments
 (0)