@@ -53,25 +53,47 @@ pub type JsLintFileCb = ThreadsafeFunction<
5353 false ,
5454> ;
5555
56+ /// JS callback to setup configs.
57+ #[ napi]
58+ pub type JsSetupConfigsCb = ThreadsafeFunction <
59+ // Arguments
60+ FnArgs < ( String , ) > , // Stringified options array
61+ // Return value
62+ String , // Result ("ok" or error message)
63+ // Arguments (repeated)
64+ FnArgs < ( String , ) > ,
65+ // Error status
66+ Status ,
67+ // CalleeHandled
68+ false ,
69+ > ;
70+
5671/// NAPI entry point.
5772///
5873/// JS side passes in:
5974/// 1. `args`: Command line arguments (process.argv.slice(2))
6075/// 2. `load_plugin`: Load a JS plugin from a file path.
61- /// 3. `lint_file`: Lint a file.
76+ /// 3. `setup_configs`: Setup configuration options.
77+ /// 4. `lint_file`: Lint a file.
6278///
6379/// Returns `true` if linting succeeded without errors, `false` otherwise.
6480#[ expect( clippy:: allow_attributes) ]
6581#[ allow( clippy:: trailing_empty_array, clippy:: unused_async) ] // https://github.com/napi-rs/napi-rs/issues/2758
6682#[ napi]
67- pub async fn lint ( args : Vec < String > , load_plugin : JsLoadPluginCb , lint_file : JsLintFileCb ) -> bool {
68- lint_impl ( args, load_plugin, lint_file) . await . report ( ) == ExitCode :: SUCCESS
83+ pub async fn lint (
84+ args : Vec < String > ,
85+ load_plugin : JsLoadPluginCb ,
86+ setup_configs : JsSetupConfigsCb ,
87+ lint_file : JsLintFileCb ,
88+ ) -> bool {
89+ lint_impl ( args, load_plugin, setup_configs, lint_file) . await . report ( ) == ExitCode :: SUCCESS
6990}
7091
7192/// Run the linter.
7293async fn lint_impl (
7394 args : Vec < String > ,
7495 load_plugin : JsLoadPluginCb ,
96+ setup_configs : JsSetupConfigsCb ,
7597 lint_file : JsLintFileCb ,
7698) -> CliRunResult {
7799 // Convert String args to OsString for compatibility with bpaf
@@ -105,10 +127,11 @@ async fn lint_impl(
105127
106128 // JS plugins are only supported on 64-bit little-endian platforms at present
107129 #[ cfg( all( target_pointer_width = "64" , target_endian = "little" ) ) ]
108- let external_linter = Some ( crate :: js_plugins:: create_external_linter ( load_plugin, lint_file) ) ;
130+ let external_linter =
131+ Some ( crate :: js_plugins:: create_external_linter ( load_plugin, setup_configs, lint_file) ) ;
109132 #[ cfg( not( all( target_pointer_width = "64" , target_endian = "little" ) ) ) ]
110133 let external_linter = {
111- let ( _, _) = ( load_plugin, lint_file) ;
134+ let ( _, _, _ ) = ( load_plugin, setup_configs , lint_file) ;
112135 None
113136 } ;
114137
0 commit comments