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

Commit 56fa375

Browse files
Merge pull request #5 from AtomLinter/further-tests
Got even more tests working
2 parents 4857d9b + c652974 commit 56fa375

File tree

16 files changed

+748
-477
lines changed

16 files changed

+748
-477
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
},
1717
"plugins": [
18-
"eslint-plugin-import"
18+
"import"
1919
],
2020
"extends": [
2121
"eslint:recommended"

lib/config.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import get from 'lodash.get';
44

55
import console from './console';
66

7+
function configChanged (config, prevConfig) {
8+
return JSON.stringify(config) !== JSON.stringify(prevConfig);
9+
}
10+
711
// Returns config values, but prioritizes anything defined in `.linter-eslint`
812
// as a per-project override for this linter's settings.
913
const Config = {
@@ -14,18 +18,19 @@ const Config = {
1418

1519
initialize () {
1620
if (this.initialized) { return; }
21+
this._currentConfig = null;
1722
this.rescan();
1823
this.initialized = true;
19-
console.log('Config initialized. nodeBin:', this.get('nodeBin'));
2024
},
2125

26+
// Search again for the presence of a .linter-eslint in the project root.
2227
rescan () {
2328
if (this.subscriptions) {
2429
this.subscriptions.dispose();
2530
}
2631
this.subscriptions = new CompositeDisposable();
2732
this.overrides = {};
28-
this._currentConfig = null;
33+
this.configFile = null;
2934

3035
for (let dir of atom.project.getDirectories()) {
3136
let candidate = dir.getFile('.linter-eslint');
@@ -36,6 +41,10 @@ const Config = {
3641
}
3742

3843
if (this.configFile) {
44+
// Changes to config file contents are caught by this subscription. File
45+
// deletion, file creation, or file renaming that involves
46+
// `.linter-eslint` is caught by the main module. We might decide to make
47+
// Config in charge of both in the future.
3948
this.subscriptions.add(
4049
this.configFile.onDidChange(this.update.bind(this))
4150
);
@@ -49,6 +58,7 @@ const Config = {
4958
);
5059
},
5160

61+
// Re-read from .linter-eslint when it updates.
5262
update () {
5363
if (!this.configFile) {
5464
this.overrides = {};
@@ -78,8 +88,11 @@ const Config = {
7888

7989
triggerConfigChange () {
8090
let newConfig = this.get();
81-
for (let handler of this.handlers) {
82-
handler(newConfig, this._currentConfig || {});
91+
if (!configChanged(newConfig, this._currentConfig)) { return; }
92+
if (this._currentConfig) {
93+
for (let handler of this.handlers) {
94+
handler(newConfig, this._currentConfig || {});
95+
}
8396
}
8497
this._currentConfig = newConfig;
8598
},
@@ -94,6 +107,7 @@ const Config = {
94107

95108
dispose () {
96109
this.subscriptions.dispose();
110+
this.initialized = false;
97111
}
98112
};
99113

lib/console.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const CONSOLE = {};
44

5-
const isEnabled = atom.inDevMode();
5+
const isEnabled = atom.inDevMode() && !process.env.SILENCE_LOG;
66

77
function makeConsoleMethod (name) {
88
return (...args) => {

lib/helpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export function generateUserMessage (textEditor, options) {
3333

3434
function configThatMayInvalidateWorkerCache (config) {
3535
let {
36-
advanced: { disableEslintIgnore },
37-
autofix: { rulesToDisableWhileFixing }
36+
advanced: { disableEslintIgnore } = {},
37+
autofix: { rulesToDisableWhileFixing } = {}
3838
} = config;
3939

4040
return {

lib/job-manager.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class JobManager {
4242
}
4343

4444
createWorker () {
45-
console.log('JobManager creating worker at:', nodeBin, this.workerPath);
4645
let nodeBin = Config.get('nodeBin');
46+
console.debug('JobManager creating worker at:', nodeBin, this.workerPath);
4747
this.killWorker();
4848

4949
// We should not try to start the worker without testing the value we have
@@ -101,7 +101,7 @@ class JobManager {
101101

102102
receiveMessage (data) {
103103
if (data.log) {
104-
console.log('WORKER LOG:', data.log);
104+
console.debug('WORKER LOG:', data.log);
105105
return;
106106
}
107107
let key = data.key;
@@ -138,7 +138,7 @@ class JobManager {
138138
async send (bundle) {
139139
let key = generateKey();
140140
bundle.key = key;
141-
console.log('JobManager#send:', bundle);
141+
console.debug('JobManager#send:', bundle);
142142
try {
143143
this.ensureWorker();
144144
} catch (err) {

0 commit comments

Comments
 (0)