Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit c49028d

Browse files
committed
indent the code to two spaces
1 parent b905d60 commit c49028d

File tree

3 files changed

+171
-171
lines changed

3 files changed

+171
-171
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"new-parens": 2,
4444
"no-new-object": 2,
4545
"no-invalid-this": 0,
46-
indent: [0, 4],
46+
indent: [2, 4],
4747

4848
"valid-jsdoc": 0,
4949
"valid-typeof": 2,

src/extensions/default/ESLint/domain.js

Lines changed: 117 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -2,131 +2,131 @@
22
/*global require, exports*/
33

44
(function () {
5-
'use strict';
6-
7-
var fs = require('fs');
8-
var CLIEngine = require('eslint').CLIEngine;
9-
var cli = new CLIEngine();
10-
var currentProjectRoot = null;
11-
var domainName = 'brackets-eslint';
12-
var domainManager = null;
13-
var noop = function () {};
14-
var globalPackagesAvailable = false;
15-
16-
function _setProjectRoot(projectRoot) {
17-
var opts = { useEslintrc: true };
18-
var configPath;
19-
var rulesDirPath;
20-
var ignorePath;
21-
22-
if (projectRoot) {
23-
configPath = projectRoot + '.eslintrc';
24-
try {
25-
if (fs.statSync(configPath).isFile()) {
26-
noop();
5+
'use strict';
6+
7+
var fs = require('fs');
8+
var CLIEngine = require('eslint').CLIEngine;
9+
var cli = new CLIEngine();
10+
var currentProjectRoot = null;
11+
var domainName = 'brackets-eslint';
12+
var domainManager = null;
13+
var noop = function () {};
14+
var globalPackagesAvailable = false;
15+
16+
function _setProjectRoot(projectRoot) {
17+
var opts = { useEslintrc: true };
18+
var configPath;
19+
var rulesDirPath;
20+
var ignorePath;
21+
22+
if (projectRoot) {
23+
configPath = projectRoot + '.eslintrc';
24+
try {
25+
if (fs.statSync(configPath).isFile()) {
26+
noop();
27+
}
28+
} catch (e) {
29+
// config file not found, use default
30+
opts.rules = require('eslint/conf/eslint.json').rules;
31+
}
32+
33+
rulesDirPath = projectRoot + '.eslintrules';
34+
try {
35+
if (fs.statSync(rulesDirPath).isDirectory()) {
36+
opts.rulePaths = [rulesDirPath];
37+
}
38+
} catch (e) {
39+
// no action required
40+
noop(e);
41+
}
42+
43+
ignorePath = projectRoot + '.eslintignore';
44+
try {
45+
if (fs.statSync(ignorePath).isFile()) {
46+
opts.ignore = true;
47+
opts.ignorePath = ignorePath;
48+
}
49+
} catch (e) {
50+
// no action required
51+
noop(e);
52+
}
2753
}
28-
} catch (e) {
29-
// config file not found, use default
30-
opts.rules = require('eslint/conf/eslint.json').rules;
31-
}
32-
33-
rulesDirPath = projectRoot + '.eslintrules';
34-
try {
35-
if (fs.statSync(rulesDirPath).isDirectory()) {
36-
opts.rulePaths = [rulesDirPath];
37-
}
38-
} catch (e) {
39-
// no action required
40-
noop(e);
41-
}
42-
43-
ignorePath = projectRoot + '.eslintignore';
44-
try {
45-
if (fs.statSync(ignorePath).isFile()) {
46-
opts.ignore = true;
47-
opts.ignorePath = ignorePath;
48-
}
49-
} catch (e) {
50-
// no action required
51-
noop(e);
52-
}
53-
}
5454

55-
cli = new CLIEngine(opts);
56-
}
57-
58-
require('enable-global-packages').on('ready', function () {
59-
// global packages are available now
60-
_setProjectRoot(currentProjectRoot);
61-
globalPackagesAvailable = true;
62-
});
63-
64-
function lintFile(fullPath, projectRoot, callback) {
65-
if (!globalPackagesAvailable) {
66-
setTimeout(function () {
67-
lintFile(fullPath, projectRoot, callback);
68-
}, 250);
69-
return;
55+
cli = new CLIEngine(opts);
7056
}
71-
if (projectRoot !== currentProjectRoot) {
72-
_setProjectRoot(projectRoot);
73-
currentProjectRoot = projectRoot;
74-
}
75-
fs.readFile(fullPath, {encoding: 'utf8'}, function (err, text) {
76-
if (err) {
77-
return callback(err);
78-
}
79-
var relativePath = fullPath.indexOf(projectRoot) === 0 ? fullPath.substring(projectRoot.length) : fullPath;
80-
81-
// this is important for ESLint so .eslintrc is properly loaded
82-
// we could go around this by parsing .eslintrc manually but that'd
83-
// bring complexity we don't need here right now
84-
// related: https://github.com/eslint/eslint/issues/4472
85-
process.chdir(projectRoot);
86-
87-
var res;
88-
try {
89-
res = cli.executeOnText(text, relativePath);
90-
} catch (e) {
91-
err = e.toString();
92-
}
93-
callback(err, res);
94-
});
95-
}
9657

97-
exports.init = function (_domainManager) {
98-
domainManager = _domainManager;
58+
require('enable-global-packages').on('ready', function () {
59+
// global packages are available now
60+
_setProjectRoot(currentProjectRoot);
61+
globalPackagesAvailable = true;
62+
});
9963

100-
if (!domainManager.hasDomain(domainName)) {
101-
domainManager.registerDomain(domainName, {
102-
major: 0,
103-
minor: 1
104-
});
64+
function lintFile(fullPath, projectRoot, callback) {
65+
if (!globalPackagesAvailable) {
66+
setTimeout(function () {
67+
lintFile(fullPath, projectRoot, callback);
68+
}, 250);
69+
return;
70+
}
71+
if (projectRoot !== currentProjectRoot) {
72+
_setProjectRoot(projectRoot);
73+
currentProjectRoot = projectRoot;
74+
}
75+
fs.readFile(fullPath, {encoding: 'utf8'}, function (err, text) {
76+
if (err) {
77+
return callback(err);
78+
}
79+
var relativePath = fullPath.indexOf(projectRoot) === 0 ? fullPath.substring(projectRoot.length) : fullPath;
80+
81+
// this is important for ESLint so .eslintrc is properly loaded
82+
// we could go around this by parsing .eslintrc manually but that'd
83+
// bring complexity we don't need here right now
84+
// related: https://github.com/eslint/eslint/issues/4472
85+
process.chdir(projectRoot);
86+
87+
var res;
88+
try {
89+
res = cli.executeOnText(text, relativePath);
90+
} catch (e) {
91+
err = e.toString();
92+
}
93+
callback(err, res);
94+
});
10595
}
10696

107-
domainManager.registerCommand(
108-
domainName,
109-
'lintFile', // command name
110-
lintFile, // handler function
111-
true, // is async
112-
'lint given file with eslint', // description
113-
[
114-
{
115-
name: 'fullPath',
116-
type: 'string'
117-
},
118-
{
119-
name: 'projectRoot',
120-
type: 'string'
121-
}
122-
], [
123-
{
124-
name: 'report',
125-
type: 'object'
97+
exports.init = function (_domainManager) {
98+
domainManager = _domainManager;
99+
100+
if (!domainManager.hasDomain(domainName)) {
101+
domainManager.registerDomain(domainName, {
102+
major: 0,
103+
minor: 1
104+
});
126105
}
127-
]
128-
);
129106

130-
};
107+
domainManager.registerCommand(
108+
domainName,
109+
'lintFile', // command name
110+
lintFile, // handler function
111+
true, // is async
112+
'lint given file with eslint', // description
113+
[
114+
{
115+
name: 'fullPath',
116+
type: 'string'
117+
},
118+
{
119+
name: 'projectRoot',
120+
type: 'string'
121+
}
122+
], [
123+
{
124+
name: 'report',
125+
type: 'object'
126+
}
127+
]
128+
);
129+
130+
};
131131

132132
}());
Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
11
/*global $, brackets, define*/
22

33
define(function (require, exports, module) {
4-
'use strict';
4+
'use strict';
55

6-
// imports
7-
var CodeInspection = brackets.getModule('language/CodeInspection');
8-
var LanguageManager = brackets.getModule('language/LanguageManager');
9-
var ProjectManager = brackets.getModule('project/ProjectManager');
10-
var ExtensionUtils = brackets.getModule('utils/ExtensionUtils');
11-
var NodeDomain = brackets.getModule('utils/NodeDomain');
6+
// imports
7+
var CodeInspection = brackets.getModule('language/CodeInspection');
8+
var LanguageManager = brackets.getModule('language/LanguageManager');
9+
var ProjectManager = brackets.getModule('project/ProjectManager');
10+
var ExtensionUtils = brackets.getModule('utils/ExtensionUtils');
11+
var NodeDomain = brackets.getModule('utils/NodeDomain');
1212

13-
// constants
14-
var JS_LANGUAGE = LanguageManager.getLanguageForExtension('js');
15-
var LINTER_NAME = 'ESLint';
16-
var nodeDomain = new NodeDomain('brackets-eslint', ExtensionUtils.getModulePath(module, 'domain'));
13+
// constants
14+
var JS_LANGUAGE = LanguageManager.getLanguageForExtension('js');
15+
var LINTER_NAME = 'ESLint';
16+
var nodeDomain = new NodeDomain('brackets-eslint', ExtensionUtils.getModulePath(module, 'domain'));
1717

18-
// this will map ESLint output to match format expected by Brackets
19-
function remapResults(results) {
20-
return {
21-
errors: results.map(function (result) {
22-
var message = result.message;
23-
if (result.ruleId) {
24-
message += ' [' + result.ruleId + ']';
25-
}
18+
// this will map ESLint output to match format expected by Brackets
19+
function remapResults(results) {
2620
return {
27-
message: message,
28-
pos: {
29-
line: result.line - 1,
30-
ch: result.column
31-
},
32-
type: result.ruleId
21+
errors: results.map(function (result) {
22+
var message = result.message;
23+
if (result.ruleId) {
24+
message += ' [' + result.ruleId + ']';
25+
}
26+
return {
27+
message: message,
28+
pos: {
29+
line: result.line - 1,
30+
ch: result.column
31+
},
32+
type: result.ruleId
33+
};
34+
})
3335
};
34-
})
35-
};
36-
}
36+
}
3737

38-
function handleLintSync(text, fullPath) {
39-
throw new Error('ESLint sync is not available, use async for ' + fullPath);
40-
}
38+
function handleLintSync(text, fullPath) {
39+
throw new Error('ESLint sync is not available, use async for ' + fullPath);
40+
}
4141

42-
function handleLintAsync(text, fullPath) {
43-
var deferred = new $.Deferred();
44-
var projectRoot = ProjectManager.getProjectRoot().fullPath;
42+
function handleLintAsync(text, fullPath) {
43+
var deferred = new $.Deferred();
44+
var projectRoot = ProjectManager.getProjectRoot().fullPath;
4545

46-
nodeDomain.exec('lintFile', fullPath, projectRoot)
47-
.then(function (report) {
48-
if (report.results.length > 1) {
49-
console.warn('ESLint returned multiple results, where only one set was expected');
50-
}
51-
var results = report.results[0];
52-
var remapped = remapResults(results.messages);
53-
deferred.resolve(remapped);
54-
}, function (err) {
55-
deferred.reject(err);
56-
});
46+
nodeDomain.exec('lintFile', fullPath, projectRoot)
47+
.then(function (report) {
48+
if (report.results.length > 1) {
49+
console.warn('ESLint returned multiple results, where only one set was expected');
50+
}
51+
var results = report.results[0];
52+
var remapped = remapResults(results.messages);
53+
deferred.resolve(remapped);
54+
}, function (err) {
55+
deferred.reject(err);
56+
});
5757

58-
return deferred.promise();
59-
}
58+
return deferred.promise();
59+
}
6060

61-
// register a linter with CodeInspection
62-
CodeInspection.register(JS_LANGUAGE.getId(), {
63-
name: LINTER_NAME,
64-
scanFile: handleLintSync,
65-
scanFileAsync: handleLintAsync
66-
});
61+
// register a linter with CodeInspection
62+
CodeInspection.register(JS_LANGUAGE.getId(), {
63+
name: LINTER_NAME,
64+
scanFile: handleLintSync,
65+
scanFileAsync: handleLintAsync
66+
});
6767

6868
});

0 commit comments

Comments
 (0)