Skip to content

Commit

Permalink
chore(*): Sync linting and IDE config (#2137)
Browse files Browse the repository at this point in the history
### What

Commit essential linting and formatting config from our favourite IDE to
the repository. The aim is to have the same config across the team and
across IDE so we avoid dealing with changes that shouldn't be part of
our PR.

* Add config for Intellij and vscode
  - Remove gitignore on .idea config
  - Disable prettier on MDX files
  - Use LF as default line separator
  - Enable format on save
* Run `prettier --write
"**/*.{**/*,*}.{js,ts,jsx,tsx,scss,css,html,json}"`
* Remove prettier-ignore in mdx files

About MDX:
Disable formatting totally, as the maximum printWidth rule conflicts
with MDX syntax about new line = `<p>`.
Latest issue that we had:
#2128 . Issue on Prettier
repository: prettier/prettier#12209

If this wouldn't be enough, the second option is to ensure that our
files are checked before committed with a git hook:
https://github.com/lint-staged/lint-staged

For review: you can do it commit by commit.

---------

Co-authored-by: Philipp Gfeller <1659006+gfellerph@users.noreply.github.com>
  • Loading branch information
imagoiq and gfellerph committed Oct 31, 2023
1 parent 50e0624 commit 4bbd53f
Show file tree
Hide file tree
Showing 343 changed files with 5,002 additions and 2,755 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Expand Up @@ -6,9 +6,6 @@ bower_components/
package-lock.json
yarn.lock

# IDEs and editors
.idea/

# Log files
.pnpm-debug.log
lerna-debug.log
Expand Down
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .idea/design-system.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/jsLinters/eslint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/prettier.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/stylesheetLinters/stylelint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/templateLanguages.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .prettierrc
Expand Up @@ -8,8 +8,7 @@
"jsxSingleQuote": false,
"trailingComma": "all",
"bracketSpacing": true,
"bracketLine": false,
"jsxBracketSameLine": false,
"bracketSameLine": false,
"arrowParens": "avoid",
"insertPragma": false,
"proseWrap": "preserve",
Expand Down
7 changes: 7 additions & 0 deletions .vscode/settings.json
@@ -1,2 +1,9 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[mdx]": {
"editor.defaultFormatter": null,
"editor.formatOnSave": false
},
"files.eol": "\n"
}
63 changes: 42 additions & 21 deletions packages/components/cypress/e2e/tabs.cy.ts
Expand Up @@ -15,16 +15,21 @@ describe('tabs', () => {

it('should only show the first tab header as active', () => {
cy.get('@headers').each(($header, index) => {
cy.wrap($header).find('.active').should(index === 0 ? 'exist' : 'not.exist');
cy.wrap($header)
.find('.active')
.should(index === 0 ? 'exist' : 'not.exist');
});
});

it('should only show the tab panel associated with the first tab header', () => {
cy.get('post-tab-panel:visible').as('panel');
cy.get('@panel').should('have.length', 1);
cy.get('@headers').first().invoke('attr', 'panel').then(panel => {
cy.get('@panel').invoke('attr', 'name').should('equal', panel);
});
cy.get('@headers')
.first()
.invoke('attr', 'panel')
.then(panel => {
cy.get('@panel').invoke('attr', 'name').should('equal', panel);
});
});

it('should activate a clicked tab header and deactivate the tab header that was previously activated', () => {
Expand All @@ -42,9 +47,12 @@ describe('tabs', () => {

cy.get('post-tab-panel:visible').as('panel');
cy.get('@panel').should('have.length', 1);
cy.get('@headers').last().invoke('attr', 'panel').then(panel => {
cy.get('@panel').invoke('attr', 'name').should('equal', panel);
});
cy.get('@headers')
.last()
.invoke('attr', 'panel')
.then(panel => {
cy.get('@panel').invoke('attr', 'name').should('equal', panel);
});
});
});

Expand All @@ -57,19 +65,27 @@ describe('tabs', () => {

it('should only show the requested active tab panel', () => {
cy.get('@panel').should('have.length', 1);
cy.get('@tabs').invoke('attr', 'active-panel').then(activePanel => {
cy.get('@panel').invoke('attr', 'name').should('equal', activePanel);
});
cy.get('@tabs')
.invoke('attr', 'active-panel')
.then(activePanel => {
cy.get('@panel').invoke('attr', 'name').should('equal', activePanel);
});
});

it('should show as active only the tab header associated with the requested active tab panel', () => {
cy.get('@tabs').invoke('attr', 'active-panel').then(activePanel => {
cy.get('@headers').each($header => {
cy.wrap($header).invoke('attr', 'panel').then(panel => {
cy.wrap($header).find('.active').should(panel === activePanel ? 'exist' : 'not.exist');
cy.get('@tabs')
.invoke('attr', 'active-panel')
.then(activePanel => {
cy.get('@headers').each($header => {
cy.wrap($header)
.invoke('attr', 'panel')
.then(panel => {
cy.wrap($header)
.find('.active')
.should(panel === activePanel ? 'exist' : 'not.exist');
});
});
});
});
});
});

Expand All @@ -89,9 +105,12 @@ describe('tabs', () => {

cy.get('post-tab-panel:visible').as('panel');
cy.get('@panel').should('have.length', 1);
cy.get('@headers').first().invoke('attr', 'panel').then(panel => {
cy.get('@panel').invoke('attr', 'name').should('equal', panel);
});
cy.get('@headers')
.first()
.invoke('attr', 'panel')
.then(panel => {
cy.get('@panel').invoke('attr', 'name').should('equal', panel);
});
});

it('should activate the newly added tab header after clicking on it', () => {
Expand All @@ -115,9 +134,11 @@ describe('tabs', () => {

cy.get('post-tab-panel:visible').as('panel');
cy.get('@panel').should('have.length', 1);
cy.get('@new-panel').invoke('attr', 'panel').then(panel => {
cy.get('@panel').invoke('attr', 'name').should('equal', panel);
});
cy.get('@new-panel')
.invoke('attr', 'panel')
.then(panel => {
cy.get('@panel').invoke('attr', 'name').should('equal', panel);
});
});

it('should remove a tab header', () => {
Expand Down
Expand Up @@ -10,7 +10,18 @@ describe('checkPattern', () => {
});

it('should throw the provided error if the value is not a string', () => {
[undefined, null, NaN, 1, true, {}, [], () => {/* empty */}].forEach(notString => {
[
undefined,
null,
NaN,
1,
true,
{},
[],
() => {
/* empty */
},
].forEach(notString => {
expect(runCheckForValue(notString)).toThrow(error);
});
});
Expand Down

0 comments on commit 4bbd53f

Please sign in to comment.