Skip to content

Commit

Permalink
Merge pull request #240 from AndreaPontrandolfo/AndreaPontrandolfo/is…
Browse files Browse the repository at this point in the history
…sue239

AndreaPontrandolfo/issue239
  • Loading branch information
AndreaPontrandolfo committed Aug 27, 2024
2 parents ff57cfc + 15d71e2 commit 99d60ea
Show file tree
Hide file tree
Showing 44 changed files with 1,074 additions and 32 deletions.
7 changes: 7 additions & 0 deletions .changeset/hip-pans-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sherifforg/create-config': major
'@sherifforg/cli': patch
'docs-website': patch
---

feat(cli): added new package @sherifforg/create-config
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ apps/cli-playground/*
!apps/cli-playground/package.json
!apps/cli-playground/tsconfig.json

# tsx trash files
apps/sheriff-webservices/undefined
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"eslint.workingDirectories": [
"./packages/sheriff-create-config",
"./packages/sheriff-cli",
"./packages/sheriff-utils",
"./packages/sheriff-types",
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ This repository is a monorepo that hosts the sourcecode of the following project
| ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Sheriff docs website](https://www.eslint-config-sheriff.dev) | [docs-website](https://github.com/AndreaPontrandolfo/sheriff/tree/master/apps/docs-website) | Sheriff documentation website | |
| [`eslint-config-sheriff`](https://www.npmjs.com/package/eslint-config-sheriff) | [eslint-config-sheriff](https://github.com/AndreaPontrandolfo/sheriff/tree/master/packages/eslint-config-sheriff) | A comprehensive and opinionated Typescript-first ESLint configuration | [![npm](https://img.shields.io/npm/v/eslint-config-sheriff.svg)](https://www.npmjs.com/package/eslint-config-sheriff) |
| [`@sherifforg/cli`](https://www.npmjs.com/package/@sherifforg/cli) | [sheriff-cli](https://github.com/AndreaPontrandolfo/sheriff/tree/master/packages/sheriff-cli) | The Sheriff CLI. Used to create and manage Sheriff-based ESLint configs. | [![npm](https://img.shields.io/npm/v/@sherifforg/cli.svg)](https://www.npmjs.com/package/@sherifforg/cli) |
| [`@sherifforg/create-config`](https://www.npmjs.com/package/@sherifforg/create-config) | [sheriff-create-config](https://github.com/AndreaPontrandolfo/sheriff/tree/master/packages/sheriff-create-config) | Package used to create Sheriff-based ESLint configs | [![npm](https://img.shields.io/npm/v/@sherifforg/create-config.svg)](https://www.npmjs.com/package/@sherifforg/create-config) |
| [`@sherifforg/cli`](https://www.npmjs.com/package/@sherifforg/cli) | [sheriff-cli](https://github.com/AndreaPontrandolfo/sheriff/tree/master/packages/sheriff-cli) | The Sheriff CLI. Used to manage Sheriff-based ESLint configs | [![npm](https://img.shields.io/npm/v/@sherifforg/cli.svg)](https://www.npmjs.com/package/@sherifforg/cli) |
| [`@sherifforg/types`](https://www.npmjs.com/package/@sherifforg/types) | [sheriff-types](https://github.com/AndreaPontrandolfo/sheriff/tree/master/packages/sheriff-types) | Sheriff types package | [![npm](https://img.shields.io/npm/v/@sherifforg/types.svg)](https://www.npmjs.com/package/@sherifforg/types) |

## 🚀 Getting Started
Expand Down
2 changes: 1 addition & 1 deletion apps/docs-website/docs/core-philosophy/criteria.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: 🎯 What line of reasoning drives Sheriff development

This library is very opinionated, but it's for the better. A lot of decisions were taken so you don't have to.<br />
You can now quickstart static analysis in all your Typescript projects with ease. <br />
Just type `npm init sheriff-config` in a CLI and you are good to go.
Just type `npm init @sherifforg/config` in a CLI and you are good to go.

Easiness of use without compromises is the top priority of Sheriff. The basic principle behind many design decisions of Sheriff is to require as less inputs from the user as possible. <br />
You can think of Sheriff like Prettier or `create-react-app`. It's a tool that comes battery-packed with optimal defaults. It removes configuration decisions from the equation, so you or your team can focus on developing the actual product.<br />
Expand Down
4 changes: 2 additions & 2 deletions apps/docs-website/docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ sidebar_position: 2
-**Seamless**: if you know ESLint, you know Sheriff
- 🔓 **No lock-in**: Sheriff has extended capabilities beyond being a simple eslint config, but it's **not** a framework. You can extend the `eslint.config.js` beyond Sheriff as much as you like, just like you normally would. Or you can disable any rule Sheriff comes with. Sheriff doesn't impose any limitation. See: [configuration](./configuration.mdx)
- 🤝 **Sheriff meets you where you are at**: some other configs bundle linting rules with formatting opinions and impose restrictions on how you should format your code. Sheriff does not. If you want to use Prettier alongside Sheriff, Sheriff provides you with the golden path to do it, if you don't it's ok too!
- 🏑 **Frictionless by design**: to setup Sheriff and take off, the only input required from the user is running the `npm init sheriff-config` command. The command will automatically infer the details of your project and figure out the optimal Sheriff configuration by itself
-**Interoperability**: you can plop Sheriff in your project at any moment. `npm init sheriff-config` will configure automatically everything for you and will warn you if you need to take any special precautions. Bottom line: it's never too late to install Sheriff
- 🏑 **Frictionless by design**: to setup Sheriff and take off, the only input required from the user is running the `npm init @sherifforg/config` command. The command will automatically infer the details of your project and figure out the optimal Sheriff configuration by itself
-**Interoperability**: you can plop Sheriff in your project at any moment. `npm init @sherifforg/config` will configure automatically everything for you and will warn you if you need to take any special precautions. Bottom line: it's never too late to install Sheriff
- 🏔 **Cutting-edge**: Sheriff is one of the first attempts in the wild to adhere to the new eslint configuration format, the `FlatConfig`. You can use Sheriff to easily and safely migrate your project to the new config format without effort. See: [migration guide](./migration-guide.mdx)
- 👊 **Sensible**: All of the rules that were hand-picked in Sheriff were chosen to counter some problematic real-world scenarios that can occur in production projects and to ensure maximum style consistency. No bloat here. See [criteria](./core-philosophy/criteria.md)
- 🛡️ **Typesafe**: The Sheriff configuration file can be typesafe! See: [eslint-config-ts](./typescript-support/eslint-config-ts.md)
Expand Down
2 changes: 1 addition & 1 deletion apps/docs-website/docs/migration-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import TabItem from "@theme/TabItem";

If you are setting up Sheriff in an already established codebase, follow these steps:

1. Start by running the `npm init sheriff-config` command and follow the advices that it prints in the console
1. Start by running the `npm init @sherifforg/config` command and follow the advices that it prints in the console
1. Make sure that the only ESLint config file present in any workspace' package is the `eslint.config.js`
1. If you want to keep your existing custom rules on-top of Sheriff, move them to the `eslint.config.js`, after the `sheriff` function, so they will override it. Refer to the [configuration instructions](./configuration.mdx)
1. Make sure to uninstall all the packages that Sheriff already incorporates out-of-the-box. [Here](./eslint-plugins.md) is the list
Expand Down
6 changes: 3 additions & 3 deletions apps/docs-website/docs/monorepo-support.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ It works best when applied to individual packages _within_ a monorepo.

To make use of the [ESLint VScode extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) in monorepos, use the [eslint.workingDirectories](https://github.com/microsoft/vscode-eslint#mono-repository-setup) setting.

## Setup with `npm init sheriff-config`
## Setup with `npm init @sherifforg/config`

If you want to use `npm init sheriff-config` to bootstrap Sheriff in one of your workspace' packages, you can actually do so by following the general usage rules of workspaces, Sheriff will try to mimic the behaviour of popular monorepo CLI tools, so it will feel seamless, intuitive and familiar.
If you want to use `npm init @sherifforg/config` to bootstrap Sheriff in one of your workspace' packages, you can actually do so by following the general usage rules of workspaces, Sheriff will try to mimic the behaviour of popular monorepo CLI tools, so it will feel seamless, intuitive and familiar.

Run the command from the root of your monorepo, and then filter by the workspace you want to apply Sheriff to. A chain of prompts will start to guide you through the correct process of installation.

Examples:

```bash npm2yarn
npm init sheriff-config --filter=packages/my-package
npm init @sherifforg/config --filter=packages/my-package
```
6 changes: 3 additions & 3 deletions apps/docs-website/docs/prettier-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Sheriff tries to incorporate [Prettier](https://prettier.io/) out-of-the-box.

## Setup

The `npm init sheriff-config` command will spin up for you a default `.prettierrc.json` configuration. You _can_ modify it if you need to, but [it is discouraged](https://prettier.io/docs/en/option-philosophy.html). Act with caution.
The `npm init @sherifforg/config` command will spin up for you a default `.prettierrc.json` configuration. You _can_ modify it if you need to, but [it is discouraged](https://prettier.io/docs/en/option-philosophy.html). Act with caution.

If you don't use the `npm init sheriff-config` command, you will have to provide a prettier config yourself. Also don't forget the [`.prettierignore` file](https://prettier.io/docs/en/ignore.html).
If you don't use the `npm init @sherifforg/config` command, you will have to provide a prettier config yourself. Also don't forget the [`.prettierignore` file](https://prettier.io/docs/en/ignore.html).

If you already have a Prettier config in your project, you are good to go. The `npm init sheriff-config` command won't create a new Prettier config, nor will attempt to modify the existing one.
If you already have a Prettier config in your project, you are good to go. The `npm init @sherifforg/config` command won't create a new Prettier config, nor will attempt to modify the existing one.

## Usage

Expand Down
4 changes: 2 additions & 2 deletions apps/docs-website/docs/setup/automatic-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Let the CLI take care of everything!
1. Just run this command in your terminal:

```bash npm2yarn
npm init sheriff-config
npm init @sherifforg/config
```

:::tip

For monorepos, refer to the extra details in the [monorepo support](../monorepo-support.mdx#setup-with-npm-init-sheriff-config) guide.
For monorepos, refer to the extra details in the [monorepo support](../monorepo-support.mdx#setup-with-npm-init-sherifforgconfig) guide.

:::

Expand Down
6 changes: 3 additions & 3 deletions apps/docs-website/docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ sidebar_position: 18

# 🩹 Troubleshooting

## The command `yarn create sheriff-config` fails when using yarn
## The command `yarn create @sherifforg/config` fails when using yarn

Depending on the context and under specific conditions, `@sherifforg/cli` may fail to install the dependencies when using `yarn`. <br />
In this case you can simply install them yourself. The `yarn create sheriff-config` command should spit out the correct command prompt for you to do so at the end of the process. If that doesn't happen, refer to the [manual setup instructions](./setup/manual-setup.mdx).
Depending on the context and under specific conditions, the setup command may fail to install the dependencies when using `yarn`. <br />
In this case you can simply install them yourself. The `yarn create @sherifforg/config` command should spit out the correct command prompt for you to do so at the end of the process. If that doesn't happen, refer to the [manual setup instructions](./setup/manual-setup.mdx).

Alternatively, consider switching package manager to [pnpm](https://pnpm.io/).

Expand Down
2 changes: 1 addition & 1 deletion apps/docs-website/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Homepage = (): JSX.Element => {
</Link>
</div>
<CodeBlock className={styles.codeblock} language="bash">
npm init sheriff-config
npm init @sherifforg/config
</CodeBlock>
</div>
</main>
Expand Down
5 changes: 4 additions & 1 deletion knip.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"apps/cli-playground",
"apps/docs-website",
],
"ignore": ["packages/sheriff-cli/src/utils/gracefullyAbort.ts"],
"ignore": [
"packages/sheriff-create-config/src/utils/gracefullyAbort.ts",
"packages/sheriff-cli/src/utils/gracefullyAbort.ts",
],
"ignoreDependencies": ["@turbo/gen", "eslint-import-resolver-typescript"],
"ignoreBinaries": ["only-allow"],
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"scripts": {
"build": "turbo run build",
"start:docs": "turbo run start --filter=docs-website --filter=sheriff-webservices",
"playground": "pnpm --filter=cli-playground exec sheriff",
"playground:mimic-monorepo": "pnpm exec sheriff --filter=cli-playground",
"playground": "pnpm --filter=cli-playground exec create-config",
"playground:mimic-monorepo": "pnpm exec create-config --filter=cli-playground",
"webservices:dev": "turbo run start --filter=sheriff-webservices",
"webservices:deploy": "turbo run serve --filter=sheriff-webservices",
"preview-docs": "turbo run serve --filter=docs-website",
Expand All @@ -30,7 +30,7 @@
"dependencies": {
"@changesets/cli": "^2.27.7",
"@manypkg/cli": "^0.21.4",
"@sherifforg/cli": "workspace:*",
"@sherifforg/create-config": "workspace:*",
"@turbo/gen": "^2.0.9",
"knip": "^5.25.1",
"prettier": "^3.3.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/sheriff-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@sherifforg/cli",
"version": "7.0.0",
"type": "module",
"description": "The Sheriff CLI. Used to create and manage Sheriff-based ESLint configs.",
"description": "The Sheriff CLI. Used to manage Sheriff-based ESLint configs.",
"scripts": {
"dev": "tsx ./src/index.ts",
"clean": "rm -rf .turbo dist",
Expand All @@ -25,7 +25,6 @@
"yargs": "^17.7.2"
},
"bin": {
"create-sheriff-config": "dist/index.js",
"sheriff": "dist/index.js"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions packages/sheriff-create-config/.typesyncrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignorePackages": ["tsconfig", "eslint-config-sheriff", "eslint"]
}
134 changes: 134 additions & 0 deletions packages/sheriff-create-config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# @sherifforg/cli

## 7.0.0

### Major Changes

- bd82253: feat(cli): renamed create-sheriff-config to @sherifforg/cli
Fixes #226

## 6.0.0

### Major Changes

- 350edfb: fix(cli): remove CJS support for config file and fix crash. Fixes #222
feat(cli): added version and help commands with aliases to cli
feat(cli): added welcome message

### Patch Changes

- c8f8f09: fix bug with ts-patch installation

## 5.2.2

### Patch Changes

- fdbb0db: chore(deps): updated some deps
- 028c5d7: chore(deps): bump
- b4685c3: feat(config): added ESLint v9 support and removed ESLint version 8.57.0 pins
Fixes #179
Fixes #185

## 5.2.1

### Patch Changes

- a8863d8: fix bug with auto install packages to ensure the correct version is installed

## 5.2.0

### Minor Changes

- 9883842: fix(deps): moved @sherifforg/constants to devDeps. Fixes #150

## 5.1.2

### Patch Changes

- 409ee4a: feat(rules): removed no-complicated-conditional-rendering
feat(plugins): added eslint-plugin-simple-import-sort plugin
feat(rules): replaced a unicorn rule with a import rule
docs(website): updated docs regarding vscode support
- 3252189: fix(cli): locked version of `eslint-ts-patch`
- 9e86345: chore(cli): updated nypm and removed custom patch
- Updated dependencies [409ee4a]
- Updated dependencies [3252189]
- @sherifforg/constants@0.0.1

## 5.1.1

### Patch Changes

- 5f90276: build(deps): added 8.57.0-0 to allowed peer deps

## 5.1.0

### Minor Changes

- 7a9a7ef: fix(cli): the cli will install [email protected]

## 5.0.0

### Major Changes

- 0afd2c8: feat(cli): completely revamped CLI experience

## 4.2.0

### Minor Changes

- 2306ffa: chore(deps): updated node and pnpm versions

### Patch Changes

- 3f56ab8: feat(rules): added eslint-plugin-arrow-return-style

## 4.1.0

### Minor Changes

- 977b2b4: feat(types): Update @sheriff/types to @sherifforg/types
- aba4e21: ci(monorepo): added merge-checks

## 4.0.0

### Major Changes

- 3870f73: feat(config): added experimental support for eslint-ts-patch
feat(CLI): massive improvements to create-sheriff-config
feat(playground): added workspace cli-playground
feat(types): @sherifforg/types is now a npm package

## 3.0.2

### Patch Changes

- d70cb51: feat(webservices): added sheriff webservices

## 3.0.1

### Patch Changes

- 91b3b38: feat(rules): added astro support. Closes #45
fix(rules): removed eslint-plugin-etc rules
BREAKING CHANGE: removed eslint-plugin-etc

## 3.0.0

### Major Changes

- fcc5a81: converted eslint-config-sheriff to typescript

### Patch Changes

- ebc0952: (docs) added readmes

## 2.10.0

### Minor Changes

- 12d630f: transition to monorepo

### Patch Changes

- bfea189: updated some links
5 changes: 5 additions & 0 deletions packages/sheriff-create-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @sherifforg/create-config

This package creates new Sheriff configs.

You can find all the relevant information at [this link](https://www.eslint-config-sheriff.dev/docs/setup/automatic-setup).
21 changes: 21 additions & 0 deletions packages/sheriff-create-config/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sheriff from 'eslint-config-sheriff';
import { defineFlatConfig } from 'eslint-define-config';

const sheriffOptions = {
react: false,
lodash: true,
next: false,
astro: false,
playwright: false,
jest: false,
vitest: false,
};

export default defineFlatConfig([
...sheriff(sheriffOptions),
{
rules: {
'fsecond/prefer-destructured-optionals': 0,
},
},
]);
Loading

0 comments on commit 99d60ea

Please sign in to comment.