Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
monaco-editor-erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
monaco-editor-erp5
Commits
7e6c8ec6
Commit
7e6c8ec6
authored
Oct 28, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
include ruff as linter
parent
ec356fc2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
1 deletion
+80
-1
.gitmodules
.gitmodules
+3
-0
README.md
README.md
+4
-0
index.js
index.js
+71
-1
package.json
package.json
+1
-0
ruff
ruff
+1
-0
No files found.
.gitmodules
0 → 100644
View file @
7e6c8ec6
[submodule "ruff"]
path = ruff
url = https://github.com/astral-sh/ruff/
README.md
View file @
7e6c8ec6
...
...
@@ -4,8 +4,12 @@ This code is based on https://github.com/Microsoft/monaco-editor-samples/tree/a9
To build, after cloning this repository:
install https://rustwasm.github.io/wasm-pack/installer/
run:
```
npm install
npm run build:wasm
npm run build
```
...
...
index.js
View file @
7e6c8ec6
import
'
core-js/actual
'
;
// BBB firefox 68
//
import 'core-js/actual'; // BBB firefox 68
import
"
./public-path.js
"
import
*
as
monaco
from
'
monaco-editor
'
;
import
init
,
{
Workspace
}
from
"
./ruff/crates/ruff_wasm/src/pkg
"
;
/**
* @param {monaco.editor.IEditor} editor
* @param {object} config the config, following https://raw.githubusercontent.com/charliermarsh/ruff/main/ruff.schema.json
* @returns {Disposable}
*/
self
.
registerRuffDiagnosticProvider
=
async
(
editor
,
config
)
=>
{
await
init
();
const
workspace
=
new
Workspace
(
config
)
const
model
=
editor
.
getModel
()
let
codeActionProviderDisposable
;
return
model
.
onDidChangeContent
(()
=>
{
const
diagnostics
=
workspace
.
check
(
model
.
getValue
());
codeActionProviderDisposable
?.
dispose
();
codeActionProviderDisposable
=
monaco
.
languages
.
registerCodeActionProvider
(
"
python
"
,
{
provideCodeActions
:
function
(
model
,
position
)
{
const
actions
=
diagnostics
.
filter
((
check
)
=>
position
.
startLineNumber
===
check
.
location
.
row
)
.
filter
(({
fix
})
=>
fix
)
.
map
((
check
)
=>
({
title
:
check
.
fix
?
check
.
fix
.
message
?
`
${
check
.
code
}
:
${
check
.
fix
.
message
}
`
:
`Fix
${
check
.
code
}
`
:
"
Fix
"
,
id
:
`fix-
${
check
.
code
}
`
,
kind
:
"
quickfix
"
,
edit
:
check
.
fix
?
{
edits
:
check
.
fix
.
edits
.
map
((
edit
)
=>
({
resource
:
model
.
uri
,
versionId
:
model
.
getVersionId
(),
textEdit
:
{
range
:
{
startLineNumber
:
edit
.
location
.
row
,
startColumn
:
edit
.
location
.
column
,
endLineNumber
:
edit
.
end_location
.
row
,
endColumn
:
edit
.
end_location
.
column
,
},
text
:
edit
.
content
||
""
,
},
})),
}
:
undefined
,
}));
return
{
actions
,
dispose
:
()
=>
{}
};
},
});
monaco
.
editor
.
setModelMarkers
(
model
,
"
owner
"
,
diagnostics
.
map
((
diagnostic
)
=>
({
startLineNumber
:
diagnostic
.
location
.
row
,
startColumn
:
diagnostic
.
location
.
column
,
endLineNumber
:
diagnostic
.
end_location
.
row
,
endColumn
:
diagnostic
.
end_location
.
column
,
message
:
`
${
diagnostic
.
code
}
:
${
diagnostic
.
message
}
`
,
severity
:
monaco
.
MarkerSeverity
.
Error
,
tags
:
diagnostic
.
code
===
"
F401
"
||
diagnostic
.
code
===
"
F841
"
?
[
monaco
.
MarkerTag
.
Unnecessary
]
:
[],
})),
);
}
);
}
self
.
MonacoEnvironment
=
{
getWorkerUrl
:
function
(
moduleId
,
label
)
{
if
(
label
===
'
json
'
)
{
...
...
package.json
View file @
7e6c8ec6
{
"name"
:
"monaco-editor-erp5"
,
"scripts"
:
{
"build:wasm"
:
"wasm-pack -v build ruff/crates/ruff_wasm --target web"
,
"build"
:
"webpack --config webpack.config.js"
,
"deploy"
:
"node deploy.js"
},
...
...
ruff
@
7b4b0045
Subproject commit 7b4b0045067b8eb41d0b03d9c3549ce3595373fa
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment