Skip to content

Commit 0a4ce3b

Browse files
author
Barthélémy Ledoux
authored
create eslint plugin (#219)
* add eslint plugin * add rule for import deprecation * add tests to the test workflow * rename workflow * add changeset * add vscode linter * add linter rules to the engine * add lint to the test workflow * finish linting * remove all warnings from the repo * remove one last warning * match the absolute path of the imported file * document the new rules * fix compileIcon test * fix mor etests on compile icon * fix tests again * add tests for icons * add changeset * some additional tests * fix monorepo once more * fix eslint tests * build: fix test again * add content to mock import * build icons * order tests by speed * simplify yml code * fix build * fix build process * fix most ts errors * fix most of it * make sure all types pass * remove all extraneous tsconfig files * refactor: script before template * fix lint * remove the open prop on accordion * remove alert tsconfig * test: changing btn attrs repaint vue component * de-comment react changes * update dependencies * fix loading of icons * remove useless component * better docgen config * fix test apps tsconfigs * a last set of fixes * fix one more project * fix types * update name of job * fix percy snapshots
1 parent 2ef4c37 commit 0a4ce3b

File tree

119 files changed

+1893
-789
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+1893
-789
lines changed

.changeset/eslint-plugin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cypress-design/eslint-plugin": patch
3+
---
4+
5+
create eslint plugin

.changeset/refactor-eslint.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@cypress-design/react-statusicon': patch
3+
'@cypress-design/vue-statusicon': patch
4+
'@cypress-design/react-button': patch
5+
'@cypress-design/react-alert': patch
6+
'@cypress-design/vue-button': patch
7+
'@cypress-design/react-icon': patch
8+
'@cypress-design/react-tabs': patch
9+
'@cypress-design/vue-alert': patch
10+
'@cypress-design/vue-icon': patch
11+
'@cypress-design/icon-registry': patch
12+
'@cypress-design/css': patch
13+
---
14+
15+
refactor some typings so eslint passes without warning

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
**/dist
2+
**/iconsData
3+
**/_TreeShakableIcons.ts
4+
icon-registry/src/icons.ts
5+
icon-registry/src/iconsList.ts

.eslintrc.cjs

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,111 @@ module.exports = {
1212
'no-only-tests/no-only-tests': 'error',
1313
'no-unused-vars': 'off',
1414
},
15+
overrides: [
16+
{
17+
files: ['packages/eslint-plugin/**/*.js'],
18+
env: {
19+
node: true,
20+
},
21+
},
22+
{
23+
files: ['{packages,css,icon-registry}/**/*.{ts,tsx}'],
24+
plugins: ['@typescript-eslint'],
25+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
26+
parser: '@typescript-eslint/parser',
27+
parserOptions: {
28+
sourceType: 'module',
29+
project: ['./tsconfig.json'],
30+
},
31+
env: {
32+
node: true,
33+
},
34+
},
35+
{
36+
files: ['components/*/react/*.{ts,tsx}'],
37+
plugins: ['@typescript-eslint'],
38+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
39+
parser: '@typescript-eslint/parser',
40+
parserOptions: {
41+
sourceType: 'module',
42+
project: ['./tsconfig.react.json'],
43+
},
44+
env: {
45+
browser: true,
46+
},
47+
},
48+
{
49+
files: ['components/*/react/*.{cy,rootStory,rootstory}.tsx'],
50+
plugins: ['@typescript-eslint'],
51+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
52+
parser: '@typescript-eslint/parser',
53+
parserOptions: {
54+
sourceType: 'module',
55+
project: ['./tsconfig.react.json'],
56+
},
57+
rules: {
58+
'@typescript-eslint/no-empty-function': 'off',
59+
'@typescript-eslint/no-explicit-any': 'off',
60+
},
61+
env: {
62+
browser: true,
63+
},
64+
},
65+
{
66+
files: ['components/*/vue/*.{ts,vue}'],
67+
plugins: ['@typescript-eslint'],
68+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
69+
parser: 'vue-eslint-parser',
70+
parserOptions: {
71+
parser: '@typescript-eslint/parser',
72+
sourceType: 'module',
73+
extraFileExtensions: ['.vue'],
74+
project: ['./tsconfig.vue.json', './tsconfig.json'],
75+
},
76+
env: {
77+
browser: true,
78+
},
79+
},
80+
{
81+
files: ['test/vue-app/src/*.{ts,vue}'],
82+
plugins: ['@typescript-eslint', '@cypress-design'],
83+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
84+
parser: 'vue-eslint-parser',
85+
parserOptions: {
86+
parser: '@typescript-eslint/parser',
87+
sourceType: 'module',
88+
extraFileExtensions: ['.vue'],
89+
project: ['./test/vue-app/tsconfig.json'],
90+
},
91+
settings: {
92+
'import/resolver': {
93+
typescript: {
94+
project: ['./test/vue-app/tsconfig.json'],
95+
},
96+
},
97+
},
98+
rules: {
99+
'@cypress-design/deprecate-imports': [
100+
'warn',
101+
[
102+
{
103+
name: 'Button',
104+
source: ['**/invalid-path/*'],
105+
docs: 'https://design.cypress.io/components/vue/Button',
106+
},
107+
],
108+
],
109+
'@cypress-design/deprecate-imports-again': [
110+
'error',
111+
[
112+
{
113+
name: 'Lodash',
114+
source: 'lodash',
115+
docs: 'https://design.cypress.io/components/vue/Button',
116+
},
117+
],
118+
],
119+
},
120+
},
121+
],
15122
}

.github/workflows/e2e-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build each test
33
on: [push]
44

55
jobs:
6-
cypress-run:
6+
build-projects:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Get Yarn cache path

.github/workflows/cypress.yml renamed to .github/workflows/test.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Cypress Tests
1+
name: Tests
22

33
on: [push]
44

@@ -34,14 +34,29 @@ jobs:
3434
env:
3535
CI: true
3636

37+
- name: Lint all files
38+
run: yarn eslint .
39+
40+
- name: Run Eslint Plugin Tests
41+
run: yarn test:eslint-plugin
42+
43+
- name: Generate icon files
44+
run: |
45+
yarn turbo run build --filter=@cypress-design/css
46+
yarn workspace @cypress-design/icon-registry run build:svg
47+
yarn workspace @cypress-design/icon-registry run build:icons
48+
3749
- name: Run Unit Tests
3850
run: yarn test
3951

4052
- name: Build Components
4153
run: yarn run build:components
4254

4355
- name: Check global types
44-
run: yarn vue-tsc --noEmit
56+
run: |
57+
yarn vue-tsc --noEmit -p .
58+
yarn tsc --noEmit --project ./tsconfig.react.json
59+
yarn vue-tsc --noEmit --project ./tsconfig.vue.json
4560
4661
# run cypress component tests
4762
- name: Cypress run CT

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"typescript.tsdk": "node_modules/typescript/lib",
66
"[vue]": {
77
"editor.defaultFormatter": "esbenp.prettier-vscode"
8-
}
8+
},
9+
"eslint.validate": ["javascript", "typescript", "vue"]
910
}

_templates/component/new/components_ComponentName_react_tsconfig.json.ejs.t

Lines changed: 0 additions & 10 deletions
This file was deleted.

_templates/component/new/components_ComponentName_vue_tsconfig.json.ejs.t

Lines changed: 0 additions & 17 deletions
This file was deleted.

components/Accordion/react/tsconfig.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)