From 71bf024fc2a437d77ca4f80195a6268f0382d5ec Mon Sep 17 00:00:00 2001 From: Ido Rosenthal Date: Thu, 29 Sep 2022 14:37:13 +0300 Subject: [PATCH] feat: ignore native CSS service not supporting yet --- .../language-service/src/lib/css-service.ts | 3 ++- .../test/lib/completions/contains.spec.ts | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 packages/language-service/test/lib/completions/contains.spec.ts diff --git a/packages/language-service/src/lib/css-service.ts b/packages/language-service/src/lib/css-service.ts index 1a400b78e..1f3538db9 100644 --- a/packages/language-service/src/lib/css-service.ts +++ b/packages/language-service/src/lib/css-service.ts @@ -143,6 +143,7 @@ export class CssService { atRuleName === '@st-scope' || atRuleName === '@st-namespace' || atRuleName === '@st-import' || + atRuleName === '@container' || atRuleName === '@st-global-custom-property') ) { return false; @@ -163,7 +164,7 @@ export class CssService { } else if (diag.code === 'unknownProperties') { const prop = diag.message.match(/'(.*)'/)![1]; - if (meta.getStVar(prop)) { + if (meta.getStVar(prop) || prop === 'container' || prop === 'container-name') { return false; } } diff --git a/packages/language-service/test/lib/completions/contains.spec.ts b/packages/language-service/test/lib/completions/contains.spec.ts new file mode 100644 index 000000000..ec0b92ac4 --- /dev/null +++ b/packages/language-service/test/lib/completions/contains.spec.ts @@ -0,0 +1,25 @@ +import { expect } from 'chai'; +import { createDiagnostics } from '../../test-kit/diagnostics-setup'; +import deindent from 'deindent'; + +describe('CSS contains', () => { + it('should ignore native css lsp diagnostics unknown container at-rule and declarations', () => { + // remove once css lsp supports is added or we implement the complete lsp ourselves + const filePath = '/style.st.css'; + + const diagnostics = createDiagnostics( + { + [filePath]: deindent` + @container a (inline-size > 100px) {} + .root { + container-name: a; + container: a / normal; + } + `, + }, + filePath + ); + + expect(diagnostics).to.eql([]); + }); +});