You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+73-20Lines changed: 73 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,18 @@ Or install `eslint` locally in your project folder (**you must have package.json
21
21
npm install eslint
22
22
```
23
23
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
+
24
36
Reopen your project next (or restart ST) to make sure local `eslint` will be used.
25
37
26
38
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
31
43
32
44
Once you have installed `eslint` you can proceed to install the SublimeLinter-eslint plugin if it is not yet installed.
33
45
34
-
**Note:** This plugin requires `eslint`0.20.0 or later.
46
+
**Note:** This plugin requires `eslint` 1.0.0 or later.
35
47
36
48
### Plugin installation
37
49
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
49
61
50
62
## FAQ and Troubleshooting
51
63
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:
##### I've got 'SublimeLinter: ERROR: eslint cannot locate 'eslint' in ST console when I try to use locally installed `eslint`.
53
78
54
79
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
62
87
63
88
Update `eslint` instance, probably you use outdated version and SublimeLinter does not check it properly sometimes.
64
89
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
+
65
98
##### I want plugin to use my `.eslintignore` settings.
66
99
67
-
It does it now.
100
+
~~It does it now.~~
68
101
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
70
103
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):
72
105
73
-
```
106
+
```json
74
107
{
75
108
"linters": {
76
109
"eslint": {
77
110
"args": [
78
-
"--reset"
111
+
"--stdin-filename", "__RELATIVE_TO_FOLDER__"
79
112
]
80
113
}
81
114
}
82
115
}
83
116
```
84
117
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).
86
119
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
88
121
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.
90
123
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
+
}
92
135
93
136
```
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
94
147
{
95
148
"linters": {
96
149
"eslint": {
97
150
"args": [
98
-
"--ignore-path", "~/eslint_ignore",
99
-
"--rulesdir", "~/rules"
151
+
"--reset"
100
152
]
101
153
}
102
154
}
103
155
}
104
156
```
105
157
106
-
##### `context.getFilename()` in rule returns relative path.
158
+
##### I want to use global `.eslintrc` config.
107
159
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.
109
161
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
111
167
{
112
168
"linters": {
113
169
"eslint": {
114
170
"args": [
115
-
"--stdin-filename", "@"
171
+
"--ignore-path", "~/eslint_ignore",
172
+
"--rulesdir", "~/rules"
116
173
]
117
174
}
118
175
}
119
176
}
120
177
```
121
178
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
-
126
179
##### There is no `SublimeLinter-contrib-eslint` package to install in Package Control packages list.
0 commit comments