Skip to content

Commit

Permalink
#80 decided to stick with cjs for configs for now
Browse files Browse the repository at this point in the history
  • Loading branch information
bennobuilder committed Nov 27, 2024
1 parent 879b662 commit 17560a0
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 32 deletions.
25 changes: 18 additions & 7 deletions packages/style-guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ The following configs are available, and are designed to be used together.
>
> See: https://prettier.io/docs/en/install.html
To use the shared Prettier config, set the following in `package.json`.
To use the shared Prettier config, set the following in `package.json`:

```json
{
"prettier": "@vercel/style-guide/prettier"
"prettier": "@blgc/style-guide/prettier"
}
```

Expand All @@ -45,9 +45,11 @@ To use the shared Prettier config, set the following in `package.json`.
> Note: Typescript is a peer-dependency of this package, and should be installed
> at the root of your project.
To use the shared Typescript config, set the following in `tsconfig.json`:

```json
{
"extends": "@blgc/style-guide/typescript/react-library",
"extends": "@blgc/style-guide/typescript/library",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src",
Expand All @@ -64,18 +66,27 @@ To use the shared Prettier config, set the following in `package.json`.
>
> See: https://eslint.org/docs/user-guide/getting-started#installation-and-usage

To use the shared ESLint config, set the following in `eslint.config.js`:

```js
const styleGuide = require('@blgc/style-guide/eslint/library');

/**
* @type {import('eslint').Linter.Config}
*/
module.exports = {
root: true,
extends: [require.resolve('@blgc/style-guide/eslint/react-internal'), 'plugin:storybook/recommended']
};
module.exports = [
...styleGuide,
{
// Any additional custom rules
}
];
```

### [Vitest](https://vitest.dev/)

To use the shared Vitest config, set the following in `vitest.config.js`:

```js
const { defineConfig, mergeConfig } = require('vitest/config');
const { nodeConfig } = require('@blgc/style-guide/vite/library');
Expand Down
15 changes: 8 additions & 7 deletions packages/style-guide/eslint/base.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import js from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import onlyWarn from 'eslint-plugin-only-warn';
import turboPlugin from 'eslint-plugin-turbo';
import tseslint from 'typescript-eslint';
const js = require('@eslint/js');
const eslintConfigPrettier = require('eslint-config-prettier');
const onlyWarn = require('eslint-plugin-only-warn');
const turboPlugin = require('eslint-plugin-turbo');
const tseslint = require('typescript-eslint');

/**
* Base ESLint configuration.
*
* @see https://eslint.org/docs/latest/use/configure/configuration-files
* @type {import("eslint").Linter.Config}
* */
export const config = [
*/
module.exports = [
js.configs.recommended,
eslintConfigPrettier,
...tseslint.configs.recommended,
Expand Down
5 changes: 3 additions & 2 deletions packages/style-guide/eslint/library.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { config as baseConfig } from './base.js';
const { baseConfig } = require('./base.js');

/**
* ESLint configuration for TypeScript libraries.
*
* @see https://eslint.org/docs/latest/use/configure/configuration-files
* @type {import("eslint").Linter.Config}
*/
export const libraryConfig = [
module.exports = [
...baseConfig,
{
rules: {}
Expand Down
16 changes: 8 additions & 8 deletions packages/style-guide/eslint/next.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import pluginNext from '@next/eslint-plugin-next';
import pluginReact from 'eslint-plugin-react';
import pluginReactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';

import { config as baseConfig } from './base.js';
const pluginNext = require('@next/eslint-plugin-next');
const pluginReact = require('eslint-plugin-react');
const pluginReactHooks = require('eslint-plugin-react-hooks');
const globals = require('globals');
const { baseConfig } = require('./base.js');

/**
* ESLint configuration for applications that use Next.js.
*
* @see https://eslint.org/docs/latest/use/configure/configuration-files
* @type {import("eslint").Linter.Config}
* */
export const nextJsConfig = [
*/
module.exports = [
...baseConfig,
{
...pluginReact.configs.flat.recommended,
Expand Down
15 changes: 8 additions & 7 deletions packages/style-guide/eslint/react-internal.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import pluginReact from 'eslint-plugin-react';
import pluginReactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';

import { config as baseConfig } from './base.js';
const pluginReact = require('eslint-plugin-react');
const pluginReactHooks = require('eslint-plugin-react-hooks');
const globals = require('globals');
const baseConfig = require('./base.js');

/**
* ESLint configuration for applications and libraries that use ReactJs.
*
* @type {import("eslint").Linter.Config} */
export const config = [
* @see https://eslint.org/docs/latest/use/configure/configuration-files
* @type {import("eslint").Linter.Config}
*/
module.exports = [
...baseConfig,
pluginReact.configs.flat.recommended,
{
Expand Down
3 changes: 2 additions & 1 deletion packages/style-guide/prettier/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* @type {import("@ianvs/prettier-plugin-sort-imports").PrettierConfig}
* @see https://prettier.io/docs/en/configuration.html
* @type {import("prettier").Config}
*/
module.exports = {
// Editor Config Overrides
Expand Down

0 comments on commit 17560a0

Please sign in to comment.