Merge branch 'eslint' of https://github.com/ethereum/remix-project into eslint
commit
f214d91dc9
@ -0,0 +1,48 @@ |
||||
import { Monaco } from "@monaco-editor/react" |
||||
import monaco from "../../types/monaco" |
||||
import { EditorUIProps } from "../remix-ui-editor" |
||||
import { default as fixes } from "./quickfixes" |
||||
|
||||
export class RemixCodeActionProvider implements monaco.languages.CodeActionProvider { |
||||
props: EditorUIProps |
||||
monaco: Monaco |
||||
constructor(props: any, monaco: any) { |
||||
this.props = props |
||||
this.monaco = monaco |
||||
} |
||||
|
||||
async provideCodeActions ( |
||||
model /**ITextModel*/, |
||||
range /**Range*/, |
||||
context /**CodeActionContext*/, |
||||
token /**CancellationToken*/ |
||||
) { |
||||
|
||||
const actions = context.markers.map(error => { |
||||
const errStrings = Object.keys(fixes) |
||||
const errStr = errStrings.find(es => error.message.includes(es)) |
||||
const fix = fixes[errStr] |
||||
return { |
||||
title: fix.title, |
||||
diagnostics: [error], |
||||
kind: "quickfix", |
||||
edit: { |
||||
edits: [ |
||||
{ |
||||
resource: model.uri, |
||||
edit: { |
||||
range: fix.range || error, |
||||
text: fix.message |
||||
} |
||||
} |
||||
] |
||||
}, |
||||
isPreferred: true |
||||
} |
||||
}) |
||||
return { |
||||
actions: actions, |
||||
dispose: () => {} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,16 @@ |
||||
export default { |
||||
"Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing \"SPDX-License-Identifier: <SPDX-License>\" to each source file. Use \"SPDX-License-Identifier: UNLICENSED\" for non-open-source code. Please see https://spdx.org for more information.": { |
||||
"title": "Add open-source license", |
||||
"message": "// SPDX-License-Identifier: GPL-3.0" |
||||
}, |
||||
"Warning: Source file does not specify required compiler version! Consider adding" : { |
||||
"title": "Add pragma line", |
||||
"message": "pragma solidity ^0.*.*;", |
||||
"range": { |
||||
startLineNumber: 2, |
||||
endLineNumber: 2, |
||||
startColumn: 1, |
||||
endColumn: 1 |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue