Skip to content

Commit

Permalink
Complete and better ESlint config for volto-add-ons-ish
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh committed Jan 19, 2025
1 parent a9ac42d commit d3385b7
Show file tree
Hide file tree
Showing 13 changed files with 658 additions and 55 deletions.
4 changes: 2 additions & 2 deletions packages/blocks/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ['../../.eslintrc.cjs', 'plugin:react/jsx-runtime'],
ignorePatterns: ['storybook-static', 'dist'],
extends: ['../../.eslintrc.cjs', '../eslintconfig/addons.js'],
ignorePatterns: ['vitest.config.ts'],
};
1 change: 1 addition & 0 deletions packages/blocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { blocksConfig } from './config';

export default function install(config: ConfigType) {
config.settings.slate = slate;
// @ts-expect-error this is a quick hack for now
config.blocks.blocksConfig = blocksConfig;

return config;
Expand Down
5 changes: 5 additions & 0 deletions packages/blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@
"devDependencies": {
"@plone/registry": "workspace:*",
"@plone/types": "workspace:*",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/react": "14.2.1",
"@types/jest-axe": "^3.5.7",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"jest-axe": "^8.0.0",
"release-it": "17.1.1",
"tsconfig": "workspace:*",
"typescript": "^5.6.3",
Expand Down
3 changes: 3 additions & 0 deletions packages/blocks/setupTesting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import '@testing-library/jest-dom';
import { toHaveNoViolations } from 'jest-axe';
expect.extend(toHaveNoViolations);
14 changes: 14 additions & 0 deletions packages/blocks/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from 'vitest/config';

// https://vitejs.dev/config/
export default defineConfig({
test: {
globals: true,
environment: 'jsdom',
setupFiles: './setupTesting.ts',
// you might want to disable it, if you don't have tests that rely on CSS
// since parsing CSS is slow
css: true,
exclude: ['**/node_modules/**', '**/lib/**'],
},
});
34 changes: 34 additions & 0 deletions packages/eslintconfig/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# `eslintconfig`

Base configurations for projects.

## Usage

In `package.json`:

```json
"devDependencies": {
"eslintconfig": "workspace:*",
}
```

```js
{
"extends": "tsconfig/react-library.json",
"include": ["src", "src/**/*.js"],
"exclude": [
"node_modules",
"build",
"public",
"coverage",
"src/**/*.test.{js,jsx,ts,tsx}",
"src/**/*.spec.{js,jsx,ts,tsx}",
"src/**/*.stories.{js,jsx,ts,tsx}"
]
}
```

> [!WARNING]
> This package or app is experimental.
> The community offers no support whatsoever for it.
> Breaking changes may occur without notice.
17 changes: 17 additions & 0 deletions packages/eslintconfig/addons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
ignorePatterns: ['storybook-static', 'dist'],
overrides: [
{
files: ['**/*.{ts,tsx, js, jsx}'],
extends: [
'plugin:react/jsx-runtime', // We only want this for non-library code (eg. volto add-ons)
],
rules: {
'import/no-unresolved': 1,
'import/named': 'error',
'react/jsx-key': [2, { checkFragmentShorthand: true }],
},
},
],
};
9 changes: 9 additions & 0 deletions packages/eslintconfig/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "eslintconfig",
"version": "0.0.0",
"private": true,
"license": "MIT",
"publishConfig": {
"access": "public"
}
}
10 changes: 2 additions & 8 deletions packages/slots/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
overrides: [
{
files: ['**/*.ts', '**/*.tsx'],
extends: [
'plugin:react/jsx-runtime', // We only want this for non-library code (eg. volto add-ons)
],
},
],
extends: ['../../.eslintrc.cjs', '../eslintconfig/addons.js'],
ignorePatterns: ['vitest.config.ts'],
};
2 changes: 1 addition & 1 deletion packages/slots/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import './storybook-base.css';
import '@plone/components/dist/basic.css';
import '../main.css';
import config from '@plone/registry';
import installSlots from '../config';
import installSlots from '../index';
import installBlocks from '@plone/blocks';

config.set('slots', {});
Expand Down
4 changes: 4 additions & 0 deletions packages/slots/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
"@storybook/react": "^8.0.4",
"@storybook/react-vite": "^8.0.4",
"@storybook/theming": "^8.0.4",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/react": "14.2.1",
"@types/jest-axe": "^3.5.7",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint-plugin-storybook": "^0.8.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/theming/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ['../../.eslintrc.cjs', '../eslintconfig/addons.js'],
};
Loading

0 comments on commit d3385b7

Please sign in to comment.