Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
45 changes: 23 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
},
"dependencies": {
"brackets-inspection-gutters": "^0.2.10",
"eslint": "^4.14.0"
"eslint": "^4.15.0"
},
"devDependencies": {
"@types/jquery": "2.0.40",
"@types/node": "8.5.2",
"concurrently": "3.5.1",
"rimraf": "2.6.2",
"tslint": "5.8.0",
"tslint": "5.9.1",
"typescript": "2.6.2"
}
}
9 changes: 9 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const Menus = brackets.getModule('command/Menus');
const DocumentManager = brackets.getModule('document/DocumentManager');
const EditorManager = brackets.getModule('editor/EditorManager');
const PreferencesManager = brackets.getModule('preferences/PreferencesManager');
const FileSystem = brackets.getModule('filesystem/FileSystem');
const EXTENSION_NAME = 'quadre-eslint';
const AUTOFIX_COMMAND_ID = EXTENSION_NAME + '.autofix';
const AUTOFIX_COMMAND_NAME = 'Auto-fix with ESLint';
Expand Down Expand Up @@ -101,6 +102,14 @@ editMenu.addMenuItem(AUTOFIX_COMMAND_ID);
const contextMenu = Menus.getContextMenu(Menus.ContextMenuIds.EDITOR_MENU);
contextMenu.addMenuItem(AUTOFIX_COMMAND_ID);

FileSystem.on('change', (evt, file) => {
if (/^\.eslintrc(\.(js|yaml|yml|json))?$/.test(file.name)) {
const projectRoot = ProjectManager.getProjectRoot().fullPath;
const useEmbeddedESLint = preferences.get('useEmbeddedESLint');
nodeDomain.exec('configFileModified', projectRoot, useEmbeddedESLint);
}
});

// register a linter with CodeInspection
['javascript', 'jsx', 'typescript', 'tsx', 'vue'].forEach((langId) => {
CodeInspection.register(langId, {
Expand Down
14 changes: 14 additions & 0 deletions src/node/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,18 @@ exports.init = (_domainManager: any) => {
]
);

domainManager.registerCommand(
domainName,
'configFileModified',
esLint.configFileModified,
false,
'notify that config file was modified',
[
{ name: 'projectRoot', type: 'string' }
],
[
{ name: 'result', type: 'boolean' }
]
);

};
16 changes: 9 additions & 7 deletions src/node/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ const isOldNode = /^0/.test(nodeVersion);
const defaultCwd = process.cwd();
const ESLINT_SEVERITY_ERROR = 2;
const ESLINT_SEVERITY_WARNING = 1;
const BRACKETS_TYPE_ERROR = 'problem_type_error';
const BRACKETS_TYPE_WARNING = 'problem_type_warning';
const BRACKETS_TYPE_META = 'problem_type_meta';

let cli: ESLintCLIEngine | null = null;
let currentVersion: string | null = null;
Expand Down Expand Up @@ -210,15 +207,15 @@ function mapEslintMessage(result: any, majorVersion: number): CodeInspectionResu
switch (result.severity) {
case ESLINT_SEVERITY_ERROR:
message = 'ERROR: ';
type = BRACKETS_TYPE_ERROR as CodeInspectionResultType;
type = CodeInspectionResultType.ERROR;
break;
case ESLINT_SEVERITY_WARNING:
message = 'WARNING: ';
type = BRACKETS_TYPE_WARNING as CodeInspectionResultType;
type = CodeInspectionResultType.WARNING;
break;
default:
message = 'UNKNOWN: ';
type = BRACKETS_TYPE_META as CodeInspectionResultType;
type = CodeInspectionResultType.META;
}

message += result.message;
Expand Down Expand Up @@ -248,7 +245,7 @@ function createUserError(message: string): CodeInspectionReport {
erroredLastTime = true;
return {
errors: [{
type: 'problem_type_error',
type: CodeInspectionResultType.ERROR,
message,
pos: { line: 0, ch: 0 }
}]
Expand Down Expand Up @@ -323,3 +320,8 @@ export function fixFile(
}
callback(err, res);
}

export function configFileModified(projectRoot, useEmbeddedESLint) {
setProjectRoot(projectRoot, null, useEmbeddedESLint);
currentProjectRoot = projectRoot;
}
6 changes: 5 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export type CodeInspectionResultType = 'problem_type_error' | 'problem_type_warning' | 'problem_type_meta';
export enum CodeInspectionResultType {
ERROR = 'problem_type_error',
WARNING = 'problem_type_warning',
META = 'problem_type_meta'
}

export interface CodeInspectionPosition {
line: number;
Expand Down