Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration option requireConfig #43

Merged
merged 14 commits into from
Sep 1, 2023
Merged

Add configuration option requireConfig #43

merged 14 commits into from
Sep 1, 2023

Conversation

remcohaszing
Copy link
Member

@remcohaszing remcohaszing commented Apr 6, 2022

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

Description of changes

Closes #30

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Apr 6, 2022
@remcohaszing remcohaszing marked this pull request as draft April 6, 2022 15:22
test/index.js Outdated
Comment on lines 332 to 347
const rcPath = new URL('.testremarkrc.json', import.meta.url)
t.teardown(() => fs.rm(rcPath, {force: true}))
await fs.writeFile(rcPath, '{}\n')
const watchedFileDiagnosticsPromise = createOnNotificationPromise(
connection,
PublishDiagnosticsNotification.type
)
connection.sendNotification(DidChangeWatchedFilesNotification.type, {
changes: []
})
const watchedFileDiagnostics = await watchedFileDiagnosticsPromise
t.isNot(
0,
watchedFileDiagnostics.diagnostics.length,
'should emit diagnostics if requireConfig is true with config'
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t understand why this doesn’t work. The idea is that changing the rc configuration file retriggers validation, which is does, and then finds the configuration file, but it doesn’t.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, with “but it doesn’t” you mean “which it doesn’t”, right? So the trigger works, then it can’t find the file again?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is suuuuper long btw, really hard to get what’s happening (or supposed to happen) 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree it’s long. The other test is even longer. I tried grouping it using blank lines, but it’s still quite messy.

Basically 3 things happen:

  1. The server is started and initialized without workspace support.
  2. The file is opened. As a result file diagnostics are emitted (diagnostics.length !== 0)
  3. The language server changes its option requireConfig to true. .testremarkrc.json is not present, so empty diagnostics are emitted.
  4. The file /home/remco/Projects/unified-language-server/test/.testremarkrc.json file is created and the server is notified of this. This should result in diagnostics again, but the diagnostics are empty.
    These are the values passed into unified-engine (inspected using a debugger, then tweaked manually for representation here)
    {
      alwaysStringify: false,
      cwd: '/home/remco/Projects/unified-language-server',
      files: [
        // VFile simplified for representation
        {
          messages: [],
          path: '/home/remco/Projects/unified-language-server/test/lsp.md',
          cwd: '/home/remco/Projects/unified-language-server',
          value: '# hi'
        }
      ],
      ignoreUnconfigured: true,
      plugins: [ './test/lots-of-warnings.js' ],
      quiet: false,
      rcName: 'testremark',
      silentlyIgnore: true,
      streamError: new PassThrough(),
      streamOut: new PassThrough()
    }
    The language server used is remark-with-warnings.js:
    import {createUnifiedLanguageServer} from '../index.js'
    
    createUnifiedLanguageServer({
      configurationSection: 'remark',
      processorName: 'remark',
      processorSpecifier: 'remark',
      rcName: 'testremark',
      // This is resolved from the directory containing package.json
      plugins: ['./test/lots-of-warnings.js']
    })
    I really don’t understand why this yields empty diagnostics

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this: step 2. removes the current file from the list of files, so if step 3. adds a config file, there are no files anymore in the corresponding folder?

@remcohaszing remcohaszing requested a review from wooorm April 6, 2022 15:24
Copy link
Member

@wooorm wooorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits discovered by reading through the changes

lib/index.js Show resolved Hide resolved
lib/index.js Show resolved Hide resolved
lib/index.js Show resolved Hide resolved
lib/index.js Outdated Show resolved Hide resolved
lib/index.js Show resolved Hide resolved
test/index.js Outdated Show resolved Hide resolved
@remcohaszing remcohaszing marked this pull request as ready for review August 21, 2023 15:15
@remcohaszing remcohaszing mentioned this pull request Aug 22, 2023
5 tasks
@github-actions

This comment was marked as resolved.

@remcohaszing remcohaszing reopened this Aug 22, 2023
@codecov-commenter
Copy link

codecov-commenter commented Aug 22, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (dd63b00) 100.00% compared to head (86a9d66) 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #43   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          474       558   +84     
=========================================
+ Hits           474       558   +84     
Files Changed Coverage Δ
lib/index.js 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@remcohaszing
Copy link
Member Author

Can we merge this? There’s one open comment about the test. The tests are a bit long, but they test what they’re supposed to test. I would like to resolve some issues other that depend on these changes. Also this solves an issue a lot people run into, including myself.

@remcohaszing remcohaszing merged commit c3023e7 into unifiedjs:main Sep 1, 2023
4 checks passed
@remcohaszing remcohaszing deleted the configuration-option-require-config branch September 1, 2023 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤞 phase/open Post is being triaged manually
Development

Successfully merging this pull request may close these issues.

Don’t perform actions when no configuration is found.
3 participants