Skip to content
Open
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
11 changes: 11 additions & 0 deletions ale_linters/javascript/oxlint.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
" Author: Jeff Miccolis<jeff@miccolis.net>
" Description: oxlint for JavaScript files.

call ale#linter#Define('javascript', {
\ 'name': 'oxlint',
\ 'lsp': 'stdio',
\ 'executable': function('ale#handlers#oxlint#GetExecutable'),
\ 'command': '%e --lsp',
\ 'project_root': function('ale#handlers#oxlint#GetProjectRoot'),
\ 'initialization_options': function('ale#handlers#oxlint#GetInitializationOptions'),
\})
12 changes: 12 additions & 0 deletions ale_linters/typescript/oxlint.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
" Author: Jeff Miccolis<jeff@miccolis.net>
" Description: oxlint for TypeScript files.

call ale#linter#Define('typescript', {
\ 'name': 'oxlint',
\ 'lsp': 'stdio',
\ 'executable': function('ale#handlers#oxlint#GetExecutable'),
\ 'command': '%e --lsp',
\ 'project_root': function('ale#handlers#oxlint#GetProjectRoot'),
\ 'initialization_options': function('ale#handlers#oxlint#GetInitializationOptions'),
\})

5 changes: 5 additions & 0 deletions autoload/ale/fix/registry.vim
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['javascript', 'typescript', 'astro'],
\ 'description': 'Apply eslint --fix to a file.',
\ },
\ 'oxfmt': {
\ 'function': 'ale#fixers#oxfmt#Fix',
\ 'suggested_filetypes': ['javascript', 'typescript', 'typescriptreact', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'toml', 'yaml'],
\ 'description': 'Apply oxfmt to a file.',
\ },
\ 'mix_format': {
\ 'function': 'ale#fixers#mix_format#Fix',
\ 'suggested_filetypes': ['elixir'],
Expand Down
34 changes: 34 additions & 0 deletions autoload/ale/fixers/oxfmt.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
" Author: Jeff Miccolis <jeff@miccolis.net>
" Description: Fixing files with oxlint.

call ale#Set('javascript_oxfmt_executable', 'oxfmt')
call ale#Set('javascript_oxfmt_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('javascript_oxfmt_options', '')

function! ale#fixers#oxfmt#GetExecutable(buffer) abort
return ale#path#FindExecutable(a:buffer, 'javascript_oxfmt', [
\ 'node_modules/.bin/oxfmt',
\])
endfunction

function! ale#fixers#oxfmt#Fix(buffer) abort
let l:executable = ale#fixers#oxfmt#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'javascript_oxfmt_options')

" Needs oxfmt with https://github.com/oxc-project/oxc/pull/16868
return {
\ 'cwd': ale#fixers#oxfmt#GetCwd(a:buffer),
\ 'command': ale#Escape(l:executable)
\ . ale#Pad(l:options)
\ . ' --stdin-filepath %s',
\}

endfunction

function! ale#fixers#oxfmt#GetCwd(buffer) abort
let l:config = ale#path#FindNearestFile(a:buffer, '.oxfmtrc.json')

" Fall back to the directory of the buffer
return !empty(l:config) ? fnamemodify(l:config, ':h') : '%s:h'
endfunction

45 changes: 45 additions & 0 deletions autoload/ale/handlers/oxlint.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
" Author: Jeff Miccolis <jeff@miccolis.net>

call ale#Set('javascript_oxlint_executable', 'oxlint')
call ale#Set('javascript_oxlint_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('javascript_oxlint_options', {})

function! ale#handlers#oxlint#GetExecutable(buffer) abort
return ale#path#FindExecutable(a:buffer, 'javascript_oxlint', [
\ 'node_modules/.bin/oxlint',
\])
endfunction

function! ale#handlers#oxlint#GetProjectRoot(buffer) abort
let l:possible_project_roots = [
\ '.oxlintrc.json',
\ '.oxlintrc.jsonc',
\ 'oxlint.config.ts',
\ 'oxlint.config.mts',
\ 'package.json',
\ bufname(a:buffer),
\]

for l:possible_root in l:possible_project_roots
let l:project_root = ale#path#FindNearestFile(a:buffer, l:possible_root)

if empty(l:project_root)
let l:project_root = ale#path#FindNearestDirectory(a:buffer, l:possible_root)
endif

if !empty(l:project_root)
" dir:p expands to /full/path/to/dir/ whereas
" file:p expands to /full/path/to/file (no trailing slash)
" Appending '/' ensures that :h:h removes the path's last segment
" regardless of whether it is a directory or not.
return fnamemodify(l:project_root . '/', ':p:h:h')
endif
endfor

return ''
endfunction

function! ale#handlers#oxlint#GetInitializationOptions(buffer) abort
let l:options = ale#Var(a:buffer, 'javascript_oxlint_options')
return l:options
endfunction
6 changes: 6 additions & 0 deletions doc/ale-css.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ them reads `./.fecsrc` as the default configuration file. See:
|ale-javascript-fecs|.


===============================================================================
oxfmt *ale-typescript-oxfmt*

See |ale-javascript-oxfmt| for information about the available options.


===============================================================================
prettier *ale-css-prettier*

Expand Down
6 changes: 6 additions & 0 deletions doc/ale-graphql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ You will need the GraphQL ESLint plugin installed for this to work.
===============================================================================
gqlint *ale-graphql-gqlint*

===============================================================================
oxfmt *ale-typescript-oxfmt*

See |ale-javascript-oxfmt| for information about the available options.


===============================================================================
prettier *ale-graphql-prettier*

Expand Down
58 changes: 58 additions & 0 deletions doc/ale-javascript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,64 @@ g:ale_javascript_jshint_use_global
See |ale-integrations-local-executables|


===============================================================================
oxfmt *ale-javascript-oxfmt*

*ale-options.javascript_oxfmt_executable*
*g:ale_javascript_oxfmt_executable*
*b:ale_javascript_oxfmt_executable*
javascript_oxfmt_executable
g:ale_javascript_oxfmt_executable
Type: |String|
Default: `'oxfmt'`

See |ale-integrations-local-executables|

*ale-options.javascript_oxfmt_options*
*g:ale_javascript_oxfmt_options*
*b:ale_javascript_oxfmt_options*
javascript_oxfmt_options
g:ale_javascript_oxfmt_options
Type: |String|
Default: `''`

This variable can be set to pass additional options to oxfmt.


===============================================================================
oxlint *ale-javascript-oxlint*

*ale-options.javascript_oxlint_executable*
*g:ale_javascript_oxlint_executable*
*b:ale_javascript_oxlint_executable*
javascript_oxlint_executable
g:ale_javascript_oxlint_executable
Type: |String|
Default: `'oxlint'`

See |ale-integrations-local-executables|

*ale-options.javascript_oxlint_options*
*g:ale_javascript_oxlint_options*
*b:ale_javascript_oxlint_options*
javascript_oxlint_options
g:ale_javascript_oxlint_options
Type: |String|
Default: `''`

This variable can be set to pass additional options to oxlint.

*ale-options.javascript_oxlint_use_global*
*g:ale_javascript_oxlint_use_global*
*b:ale_javascript_oxlint_use_global*
javascript_oxlint_use_global
g:ale_javascript_oxlint_use_global
Type: |Number|
Default: `get(g:, 'ale_use_global_executables', 0)`

See |ale-integrations-local-executables|


===============================================================================
prettier *ale-javascript-prettier*

Expand Down
6 changes: 6 additions & 0 deletions doc/ale-json.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ g:ale_json_jq_filters
This option can be changed to pass custom filters to `jq`.


===============================================================================
oxfmt *ale-typescript-oxfmt*

See |ale-javascript-oxfmt| for information about the available options.


===============================================================================
prettier *ale-json-prettier*

Expand Down
6 changes: 6 additions & 0 deletions doc/ale-json5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ The `eslint` linter for JSON uses the JavaScript options for `eslint`; see:
You will need a JSON5 ESLint plugin installed for this to work.


===============================================================================
oxfmt *ale-typescript-oxfmt*

See |ale-javascript-oxfmt| for information about the available options.


===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
6 changes: 6 additions & 0 deletions doc/ale-less.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ g:ale_less_lessc_use_global
See |ale-integrations-local-executables|


===============================================================================
oxfmt *ale-typescript-oxfmt*

See |ale-javascript-oxfmt| for information about the available options.


===============================================================================
prettier *ale-less-prettier*

Expand Down
6 changes: 6 additions & 0 deletions doc/ale-scss.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ dprint *ale-scss-dprint*
See |ale-dprint-options| and https://dprint.dev/plugins/malva/.


===============================================================================
oxfmt *ale-typescript-oxfmt*

See |ale-javascript-oxfmt| for information about the available options.


===============================================================================
prettier *ale-scss-prettier*

Expand Down
11 changes: 11 additions & 0 deletions doc/ale-supported-languages-and-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Notes:
* `csslint`
* dprint
* `fecs`
* `oxfmt`
* `prettier`
* `stylelint`
* Cucumber
Expand Down Expand Up @@ -265,6 +266,7 @@ Notes:
* dprint
* `eslint`
* `gqlint`
* `oxfmt`
* `prettier`
* Groovy
* `npm-groovy-lint`
Expand Down Expand Up @@ -354,6 +356,8 @@ Notes:
* `flow`
* `jscs`
* `jshint`
* `oxfmt`
* `oxlint`
* `prettier`
* `prettier-eslint`
* `prettier-standard`
Expand All @@ -375,6 +379,7 @@ Notes:
* `jq`
* `json.tool`
* `jsonlint`
* `oxfmt`
* `prettier`
* `spectral`
* JSON5
Expand Down Expand Up @@ -409,6 +414,7 @@ Notes:
* Less
* dprint
* `lessc`
* `oxfmt`
* `prettier`
* `stylelint`
* LilyPond
Expand Down Expand Up @@ -687,6 +693,7 @@ Notes:
* `scalastyle`
* SCSS
* dprint
* `oxfmt`
* `prettier`
* `sass-lint`
* `scss-lint`
Expand Down Expand Up @@ -754,6 +761,7 @@ Notes:
* `thriftcheck`
* TOML
* `dprint`
* `oxfmt`
* `tombi`
* Twig
* `dprint`
Expand All @@ -764,6 +772,8 @@ Notes:
* `dprint`
* `eslint`
* `fecs`
* `oxfmt`
* `oxlint`
* `prettier`
* `standard`
* `tslint`
Expand Down Expand Up @@ -820,6 +830,7 @@ Notes:
* `circleci`!!
* `dprint`
* `gitlablint`
* `oxfmt`
* `prettier`
* `spectral`
* `swaglint`
Expand Down
6 changes: 6 additions & 0 deletions doc/ale-toml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ dprint *ale-toml-dprint*
See |ale-dprint-options| and https://dprint.dev/plugins/toml/.


===============================================================================
oxfmt *ale-typescript-oxfmt*

See |ale-javascript-oxfmt| for information about the available options.


===============================================================================
tombi *ale-toml-tombi*

Expand Down
12 changes: 12 additions & 0 deletions doc/ale-typescript.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ the two languages are, the `eslint` linter for TypeScript uses the JavaScript
options for `eslint` too. See: |ale-javascript-eslint|.


===============================================================================
oxfmt *ale-typescript-oxfmt*

See |ale-javascript-oxfmt| for information about the available options.


===============================================================================
oxlint *ale-typescript-oxlint*

See |ale-javascript-oxlint| for information about the available options.


===============================================================================
prettier *ale-typescript-prettier*

Expand Down
6 changes: 6 additions & 0 deletions doc/ale-yaml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ dprint *ale-yaml-dprint*
See |ale-dprint-options| and https://dprint.dev/plugins/pretty_yaml/.


===============================================================================
oxfmt *ale-typescript-oxfmt*

See |ale-javascript-oxfmt| for information about the available options.


===============================================================================
prettier *ale-yaml-prettier*

Expand Down
Loading