Skip to content

Commit 9d543fc

Browse files
committed
Update README
1 parent 3967ca6 commit 9d543fc

File tree

1 file changed

+73
-20
lines changed

1 file changed

+73
-20
lines changed

README.md

Lines changed: 73 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ Or install `eslint` locally in your project folder (**you must have package.json
2121
npm install eslint
2222
```
2323

24+
1. Init `eslint` config if you don't have any. Run in your code folder:
25+
26+
```
27+
eslint --init
28+
```
29+
30+
or if `eslint` is installed locally
31+
32+
```
33+
./node_modules/.bin/eslint --init
34+
```
35+
2436
Reopen your project next (or restart ST) to make sure local `eslint` will be used.
2537
2638
1. If you are using `nvm` and `zsh`, ensure that the line to load `nvm` is in `.zprofile` and not `.zshrc`.
@@ -31,7 +43,7 @@ Once `eslint` is installed, you must ensure it is in your system PATH so that Su
3143
3244
Once you have installed `eslint` you can proceed to install the SublimeLinter-eslint plugin if it is not yet installed.
3345
34-
**Note:** This plugin requires `eslint` 0.20.0 or later.
46+
**Note:** This plugin requires `eslint` 1.0.0 or later.
3547
3648
### Plugin installation
3749
Please use [Package Control][pc] to install the linter plugin. This will ensure that the plugin will be updated when new versions are available. If you want to install from source so you can modify the source code, you probably know what you are doing so we won’t cover that here.
@@ -49,6 +61,19 @@ You can configure `eslint` options in the way you would from the command line, w
4961
5062
## FAQ and Troubleshooting
5163
64+
##### What is my first step to find out what trouble I have?
65+
66+
Use SublimeText console and SublimeLinter debug mode.
67+
68+
1. Check `Tools -> SublimeLinter -> Debug Mode`.
69+
2. Open console `View -> Show Console`.
70+
71+
Then open any JS file and run `Tools -> SublimeLinter -> Lint This View`. It must be an output in console after, something like that:
72+
73+
```
74+
SublimeLinter: eslint: 1.js ['/Projects/sample/node_modules/.bin/eslint', '--format', 'compact', '--stdin', '--stdin-filename', '@']
75+
```
76+
5277
##### I've got 'SublimeLinter: ERROR: eslint cannot locate 'eslint' in ST console when I try to use locally installed `eslint`.
5378
5479
You **must** have `package.json` file if install `eslint` locally. Also, restart project or ST itself after to make sure SublimeLinter uses correct `eslint` instance.
@@ -62,67 +87,95 @@ npm install eslint
6287
6388
Update `eslint` instance, probably you use outdated version and SublimeLinter does not check it properly sometimes.
6489
90+
##### There are no errors in console, but plugin does nothing.
91+
92+
ESLint >2.0.0 does not enable any default rules and you should have config file for your code. Run in your console:
93+
```
94+
eslint --init # if eslint is global
95+
./node_modules/.bin/eslint --init # if eslint is installed locally
96+
```
97+
6598
##### I want plugin to use my `.eslintignore` settings.
6699
67-
It does it now.
100+
~~It does it now.~~
68101
69-
##### I want not to lint files if there is no `.eslintrc` file in project folder (for ESLint <1.0.0).
102+
###### For ESLint <2.0.0
70103
71-
Use `--reset` [ESLint](http://eslint.org/docs/user-guide/command-line-interface#reset) option, add it to your SublimeLinter global settings or project `.sublimelinterrc` file as below. Add `--no-reset` option to project `.sublimelinterrc` to overwrite it back.
104+
Add to your SublimeLinter settings (global or per-project):
72105
73-
```
106+
```json
74107
{
75108
"linters": {
76109
"eslint": {
77110
"args": [
78-
"--reset"
111+
"--stdin-filename", "__RELATIVE_TO_FOLDER__"
79112
]
80113
}
81114
}
82115
}
83116
```
84117

85-
##### I want to use global `.eslintrc` config.
118+
It can limit some rules and probably cause some bugs (i.e. files in symlinked folders can be skipped).
86119

87-
Plugin uses the same [configuration hierarchy](http://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy) as `eslint` itself, so add `.eslintrc` to your home directory or ancestor directory of project.
120+
###### For ESLint >=2.0.0 or if previous solution can't be applied
88121

89-
##### I want to use custom rules, global `.eslintignore` file, etc.
122+
Duplicate ESLint ignore settings to your `.sublimelinterrc` file. Use double stars for correct match.
90123

91-
You can specify **any** [CLI options](http://eslint.org/docs/user-guide/command-line-interface#options) of `eslint` with `args` key in SublimeLinter configs.
124+
```json
125+
{
126+
"linters": {
127+
"eslint": {
128+
"excludes": [
129+
"**/node_modules/**",
130+
"**/vendor/**"
131+
]
132+
}
133+
}
134+
}
92135

93136
```
137+
138+
###### For ESLint >=2.0.0
139+
140+
If you use a SublimeText project and `.sublime-project` file is in project folder, set `chdir` to `${project}` in your SublimeLinter settings. **Warning:** it can cause bugs if your project has more than one root folder.
141+
142+
##### I want not to lint files if there is no `.eslintrc` file in project folder (for ESLint <1.0.0).
143+
144+
Use `--reset` [ESLint](http://eslint.org/docs/user-guide/command-line-interface#reset) option, add it to your SublimeLinter global settings or project `.sublimelinterrc` file as below. Add `--no-reset` option to project `.sublimelinterrc` to overwrite it back.
145+
146+
```json
94147
{
95148
"linters": {
96149
"eslint": {
97150
"args": [
98-
"--ignore-path", "~/eslint_ignore",
99-
"--rulesdir", "~/rules"
151+
"--reset"
100152
]
101153
}
102154
}
103155
}
104156
```
105157

106-
##### `context.getFilename()` in rule returns relative path.
158+
##### I want to use global `.eslintrc` config.
107159

108-
It is a drawback of supporting `.eslintignore` settings. Add to your SublimeLinter settings:
160+
Plugin uses the same [configuration hierarchy](http://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy) as `eslint` itself, so add `.eslintrc` to your home directory or ancestor directory of project.
109161

110-
```
162+
##### I want to use custom rules, global `.eslintignore` file, etc.
163+
164+
You can specify **any** [CLI options](http://eslint.org/docs/user-guide/command-line-interface#options) of `eslint` with `args` key in SublimeLinter configs.
165+
166+
```json
111167
{
112168
"linters": {
113169
"eslint": {
114170
"args": [
115-
"--stdin-filename", "@"
171+
"--ignore-path", "~/eslint_ignore",
172+
"--rulesdir", "~/rules"
116173
]
117174
}
118175
}
119176
}
120177
```
121178

122-
##### Plugin does not lint files in symlinked folders.
123-
124-
It looks like ST/SublimeLinter/ESLint issue. Use solution from previous paragraph, set option `--stdin-filename` to `@`.
125-
126179
##### There is no `SublimeLinter-contrib-eslint` package to install in Package Control packages list.
127180

128181
Check if you already have it installed, please.

0 commit comments

Comments
 (0)