質問編集履歴

2

詳細

2017/05/08 07:43

投稿

goforward
goforward

スコア705

test CHANGED
@@ -1 +1 @@
1
- atom エラーメッセージの削除及びlinterの再復活
1
+ atom エラーメッセージの削除及び
test CHANGED
@@ -1,4 +1,4 @@
1
- atom エラーメッセージの削除及びlinterの再復活をしたいです。最近動画の再生が遅いのでデフォルトのpackageを少し削除したのが原因かもしれません。別のウイルスバスターが原因でした。毎回毎回エラーメッセージが出てきて鬱陶しく、前進どころか大きな後退ですのでよろしくお願いします。
1
+ atom エラーメッセージの削除及びlinterの再復活をしたいです。最近動画の再生が遅いのでデフォルトのpackageを少し削除したのが原因かもしれません。別のウイルスバスターが原因でした。毎回毎回エラーメッセージが出てきて鬱陶しく、前進どころか大きな後退ですのでよろしくお願いします。ちなみにほかの拡張子jsなのではエラーメッセージは出ません
2
2
 
3
3
  ![イメージ説明](fde8576ca8c408cd88e72209357acbc2.png)
4
4
 

1

詳細

2017/05/08 07:43

投稿

goforward
goforward

スコア705

test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,341 @@
1
1
  atom エラーメッセージの削除及びlinterの再復活をしたいです。最近動画の再生が遅いのでデフォルトのpackageを少し削除したのが原因かもしれません。別のウイルスバスターが原因でした。毎回毎回エラーメッセージが出てきて鬱陶しく、前進どころか大きな後退ですのでよろしくお願いします。
2
2
 
3
3
  ![イメージ説明](fde8576ca8c408cd88e72209357acbc2.png)
4
+
5
+
6
+
7
+ linter-ui-defalutのパッケージを取得したところエラーの数も1/10に減り
8
+
9
+
10
+
11
+ linterのチェックは復活しましたがエラーは消えません。
12
+
13
+
14
+
15
+ おそらく何かのpackageが足りないと思います。コードがまだ読めないのでここから足りないpackageの推測をおねがいいたします。
16
+
17
+
18
+
19
+ 該当箇所は137行目の.error(`[Linter] Error running ${linter.name}`, error)になります
20
+
21
+ ```php
22
+
23
+ /* @flow */
24
+
25
+ /* eslint-disable import/no-duplicates */
26
+
27
+
28
+
29
+ import { Emitter, CompositeDisposable } from 'atom'
30
+
31
+ import type { TextEditor, Disposable } from 'atom'
32
+
33
+
34
+
35
+ import * as Helpers from './helpers'
36
+
37
+ import * as Validate from './validate'
38
+
39
+ import { $version, $activated, $requestLatest, $requestLastReceived } from './helpers'
40
+
41
+ import type { Linter } from './types'
42
+
43
+
44
+
45
+ class LinterRegistry {
46
+
47
+ emitter: Emitter;
48
+
49
+ linters: Set<Linter>;
50
+
51
+ lintOnChange: boolean;
52
+
53
+ ignoreVCS: boolean;
54
+
55
+ ignoreGlob: string;
56
+
57
+ lintPreviewTabs: boolean;
58
+
59
+ subscriptions: CompositeDisposable;
60
+
61
+ disabledProviders: Array<string>;
62
+
63
+
64
+
65
+ constructor() {
66
+
67
+ this.emitter = new Emitter()
68
+
69
+ this.linters = new Set()
70
+
71
+ this.subscriptions = new CompositeDisposable()
72
+
73
+
74
+
75
+ this.subscriptions.add(atom.config.observe('linter.lintOnChange', (lintOnChange) => {
76
+
77
+ this.lintOnChange = lintOnChange
78
+
79
+ }))
80
+
81
+ this.subscriptions.add(atom.config.observe('core.excludeVcsIgnoredPaths', (ignoreVCS) => {
82
+
83
+ this.ignoreVCS = ignoreVCS
84
+
85
+ }))
86
+
87
+ this.subscriptions.add(atom.config.observe('linter.ignoreGlob', (ignoreGlob) => {
88
+
89
+ this.ignoreGlob = ignoreGlob
90
+
91
+ }))
92
+
93
+ this.subscriptions.add(atom.config.observe('linter.lintPreviewTabs', (lintPreviewTabs) => {
94
+
95
+ this.lintPreviewTabs = lintPreviewTabs
96
+
97
+ }))
98
+
99
+ this.subscriptions.add(atom.config.observe('linter.disabledProviders', (disabledProviders) => {
100
+
101
+ this.disabledProviders = disabledProviders
102
+
103
+ }))
104
+
105
+ this.subscriptions.add(this.emitter)
106
+
107
+ }
108
+
109
+ hasLinter(linter: Linter): boolean {
110
+
111
+ return this.linters.has(linter)
112
+
113
+ }
114
+
115
+ addLinter(linter: Linter, legacy: boolean = false) {
116
+
117
+ const version = legacy ? 1 : 2
118
+
119
+ if (!Validate.linter(linter, version)) {
120
+
121
+ return
122
+
123
+ }
124
+
125
+ linter[$activated] = true
126
+
127
+ if (typeof linter[$requestLatest] === 'undefined') {
128
+
129
+ linter[$requestLatest] = 0
130
+
131
+ }
132
+
133
+ if (typeof linter[$requestLastReceived] === 'undefined') {
134
+
135
+ linter[$requestLastReceived] = 0
136
+
137
+ }
138
+
139
+ linter[$version] = version
140
+
141
+ this.linters.add(linter)
142
+
143
+ }
144
+
145
+ getLinters(): Array<Linter> {
146
+
147
+ return Array.from(this.linters)
148
+
149
+ }
150
+
151
+ deleteLinter(linter: Linter) {
152
+
153
+ if (!this.linters.has(linter)) {
154
+
155
+ return
156
+
157
+ }
158
+
159
+ linter[$activated] = false
160
+
161
+ this.linters.delete(linter)
162
+
163
+ }
164
+
165
+ async lint({ onChange, editor } : { onChange: boolean, editor: TextEditor }): Promise<boolean> {
166
+
167
+ const filePath = editor.getPath()
168
+
169
+
170
+
171
+ if (
172
+
173
+ (onChange && !this.lintOnChange) || // Lint-on-change mismatch
174
+
175
+ !filePath || // Not saved anywhere yet
176
+
177
+ Helpers.isPathIgnored(editor.getPath(), this.ignoreGlob, this.ignoreVCS) || // Ignored by VCS or Glob
178
+
179
+ (!this.lintPreviewTabs && atom.workspace.getActivePane().getPendingItem() === editor) // Ignore Preview tabs
180
+
181
+ ) {
182
+
183
+ return false
184
+
185
+ }
186
+
187
+
188
+
189
+ const scopes = Helpers.getEditorCursorScopes(editor)
190
+
191
+
192
+
193
+ const promises = []
194
+
195
+ for (const linter of this.linters) {
196
+
197
+ if (!Helpers.shouldTriggerLinter(linter, onChange, scopes)) {
198
+
199
+ continue
200
+
201
+ }
202
+
203
+ if (this.disabledProviders.includes(linter.name)) {
204
+
205
+ continue
206
+
207
+ }
208
+
209
+ const number = ++linter[$requestLatest]
210
+
211
+ const statusBuffer = linter.scope === 'file' ? editor.getBuffer() : null
212
+
213
+ const statusFilePath = linter.scope === 'file' ? filePath : null
214
+
215
+
216
+
217
+ this.emitter.emit('did-begin-linting', { number, linter, filePath: statusFilePath })
218
+
219
+ promises.push(new Promise(function(resolve) {
220
+
221
+ // $FlowIgnore: Type too complex, duh
222
+
223
+ resolve(linter.lint(editor))
224
+
225
+ }).then((messages) => {
226
+
227
+ this.emitter.emit('did-finish-linting', { number, linter, filePath: statusFilePath })
228
+
229
+ if (linter[$requestLastReceived] >= number || !linter[$activated] || (statusBuffer && !statusBuffer.isAlive())) {
230
+
231
+ return
232
+
233
+ }
234
+
235
+ linter[$requestLastReceived] = number
236
+
237
+ if (statusBuffer && !statusBuffer.isAlive()) {
238
+
239
+ return
240
+
241
+ }
242
+
243
+
244
+
245
+ if (messages === null) {
246
+
247
+ // NOTE: Do NOT update the messages when providers return null
248
+
249
+ return
250
+
251
+ }
252
+
253
+
254
+
255
+ let validity = true
256
+
257
+ // NOTE: We are calling it when results are not an array to show a nice notification
258
+
259
+ if (atom.inDevMode() || !Array.isArray(messages)) {
260
+
261
+ validity = linter[$version] === 2 ? Validate.messages(linter.name, messages) : Validate.messagesLegacy(linter.name, messages)
262
+
263
+ }
264
+
265
+ if (!validity) {
266
+
267
+ return
268
+
269
+ }
270
+
271
+
272
+
273
+ if (linter[$version] === 2) {
274
+
275
+ Helpers.normalizeMessages(linter.name, messages)
276
+
277
+ } else {
278
+
279
+ Helpers.normalizeMessagesLegacy(linter.name, messages)
280
+
281
+ }
282
+
283
+ this.emitter.emit('did-update-messages', { messages, linter, buffer: statusBuffer })
284
+
285
+ }, (error) => {
286
+
287
+ this.emitter.emit('did-finish-linting', { number, linter, filePath: statusFilePath })
288
+
289
+ atom.notifications.addError(`[Linter] Error running ${linter.name}`, {
290
+
291
+ detail: 'See Console for more info. (Open View -> Developer -> Toogle Developer Tools)',
292
+
293
+ })
294
+
295
+ console.error(`[Linter] Error running ${linter.name}`, error)
296
+
297
+ }))
298
+
299
+ }
300
+
301
+
302
+
303
+ await Promise.all(promises)
304
+
305
+ return true
306
+
307
+ }
308
+
309
+ onDidUpdateMessages(callback: Function): Disposable {
310
+
311
+ return this.emitter.on('did-update-messages', callback)
312
+
313
+ }
314
+
315
+ onDidBeginLinting(callback: Function): Disposable {
316
+
317
+ return this.emitter.on('did-begin-linting', callback)
318
+
319
+ }
320
+
321
+ onDidFinishLinting(callback: Function): Disposable {
322
+
323
+ return this.emitter.on('did-finish-linting', callback)
324
+
325
+ }
326
+
327
+ dispose() {
328
+
329
+ this.linters.clear()
330
+
331
+ this.subscriptions.dispose()
332
+
333
+ }
334
+
335
+ }
336
+
337
+
338
+
339
+ module.exports = LinterRegistry
340
+
341
+ ```