From 2f492907a7d4704e162bee37b740fc818ecfad1e Mon Sep 17 00:00:00 2001 From: Leroy Korterink Date: Wed, 6 Nov 2024 23:40:15 +0100 Subject: [PATCH] Add exports and update README.md --- README.md | 214 ++++++++++++++++++--------------------------------- package.json | 8 ++ 2 files changed, 81 insertions(+), 141 deletions(-) diff --git a/README.md b/README.md index 2bd68b7..fac1e24 100755 --- a/README.md +++ b/README.md @@ -1,168 +1,100 @@ -# Media.Monks - eslint Configuration +# Monks - eslint Configuration -The official Media.Monks eslint configuration, based on the -[Frontend Coding Standards](https://github.com/mediamonks/frontend-coding-standards). +The Monks ESLint Configuration is a set of linting rules and presets designed to enforce the +[Frontend Coding Standards](https://github.com/mediamonks/frontend-coding-standards) at Monks. This +configuration helps maintain code quality and consistency across different projects by providing +tailored presets for various project types, including JavaScript, TypeScript, and React. -| Package | Version | Downloads | -| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | -| `@mediamonks/eslint-config` | [![](https://img.shields.io/npm/v/@mediamonks/eslint-config)](https://npmjs.com/@mediamonks/eslint-config) | ![](https://img.shields.io/npm/dm/@mediamonks/eslint-config) | -| `@mediamonks/eslint-config-react` | [![](https://img.shields.io/npm/v/@mediamonks/eslint-config-react)](https://npmjs.com/@mediamonks/eslint-config-react) | ![](https://img.shields.io/npm/dm/@mediamonks/eslint-config-react) | -| `@mediamonks/eslint-config-typescript` | [![](https://img.shields.io/npm/v/@mediamonks/eslint-config-typescript)](https://npmjs.com/@mediamonks/eslint-config-typescript) | ![](https://img.shields.io/npm/dm/@mediamonks/eslint-config-typescript) | -| `@mediamonks/eslint-config-typescript-react` | [![](https://img.shields.io/npm/v/@mediamonks/eslint-config-typescript-react)](https://npmjs.com/@mediamonks/eslint-config-typescript-react) | ![](https://img.shields.io/npm/dm/@mediamonks/eslint-config-typescript-react) | -| `@mediamonks/eslint-plugin-react` | [![](https://img.shields.io/npm/v/@mediamonks/eslint-plugin-react)](https://npmjs.com/@mediamonks/eslint-plugin-react) | ![](https://img.shields.io/npm/dm/@mediamonks/eslint-plugin-react) | +## Quickstart -## Installation - -Installation and configuration in a project is super easy, follow the instructions for one of the -following project types. - -- [For JavaScript projects](#for-javascript-projects) -- [For JavaScript projects using React](#for-javascript-projects-using-react) -- [For TypeScript projects](#for-typescript-projects) -- [For TypeScript projects using React](#for-typescript-projects-using-react) - -### For JavaScript projects - -Install the following package(s): +1. Install `@mediamonks/eslint-config` ```sh npm install --save-dev @mediamonks/eslint-config ``` -Add the following configuration to your `package.json` - -```json -"eslintConfig": { - "overrides": [ - { - "files": ["*.js"], - "extends": [ - "@mediamonks/eslint-config" - ] - } - ] -} -``` +2. Create a `eslint.config.js` file in the root of your module -### For JavaScript projects using React +3. Configure your project with one of the configuration presets -Install the following package(s): +## Examples -```sh -npm install --save-dev \ - @mediamonks/eslint-config - @mediamonks/eslint-config-react -``` - -Add the following configuration to your `package.json` - -```json -"eslintConfig": { - "overrides": [ - { - "files": ["*.js"], - "extends": [ - "@mediamonks/eslint-config" - ] - } - { - "files": ["*.jsx"], - "extends": [ - "@mediamonks/eslint-config", - "@mediamonks/eslint-config-react" - ] - } - ] -} -``` +The package provides four presets tailored for different project types. These presets ensure that +your project adheres to the coding standards and best practices. Below are examples of how to +configure your project using these presets. -### For TypeScript projects +### For projects with JavaScript -Install the following package(s): +```js +import { configs } from '@mediamonks/eslint-config'; -```sh -npm install --save-dev \ - @mediamonks/eslint-config \ - @mediamonks/eslint-config-typescript +export default [ + { + ignores: ['build/*'], + }, + ...configs.JavaScript, + { + languageOptions: { + // Your project language options... + // Please see the eslint/typescript-eslint documentation for more details + }, + }, +]; ``` -Add the following configuration to your `package.json` +### For projects with JavaScript and React -```json -"eslintConfig": { - "overrides": [ - { - "files": ["*.js"], - "extends": [ - "@mediamonks/eslint-config" - ] +```js +import { configs } from '@mediamonks/eslint-config'; + +export default [ + { + ignores: ['build/*'], + }, + ...configs.javascriptReact, + { + languageOptions: { + // Your project language options... + // Please see the eslint/typescript-eslint documentation for more details }, - { - "files": ["*.ts"], - "parserOptions": { - "project": "./tsconfig.json" - }, - "extends": [ - "@mediamonks/eslint-config", - "@mediamonks/eslint-config-typescript" - ] - } - ] -} + }, +]; ``` -### For TypeScript projects using React +### For projects with TypeScript -Install the following package(s): +```js +import { configs } from '@mediamonks/eslint-config'; -```sh -npm install --save-dev \ - @mediamonks/eslint-config \ - @mediamonks/eslint-config-react \ - @mediamonks/eslint-config-typescript \ - @mediamonks/eslint-config-typescript-react +export default [ + { + ignores: ['build/*'], + }, + ...configs.typescript, + { + languageOptions: { + // Your project language options... + // Please see the eslint/typescript-eslint documentation for more details + }, + }, +]; ``` -Add the following configuration to your `package.json` +### For projects with TypeScript and React -```json -"eslintConfig": { - "overrides": [ - { - "files": ["*.js"], - "extends": [ - "@mediamonks/eslint-config" - ] - }, - { - "files": ["*.jsx"], - "extends": [ - "@mediamonks/eslint-config", - "@mediamonks/eslint-config-react" - ] - }, - { - "files": ["*.ts"], - "parserOptions": { - "project": "./tsconfig.json" - }, - "extends": [ - "@mediamonks/eslint-config", - "@mediamonks/eslint-config-typescript" - ] +```js +import { configs } from '@mediamonks/eslint-config'; + +export default [ + { + ignores: ['build/*'], + }, + ...configs.typescriptReact, + { + languageOptions: { + // Your project language options... + // Please see the eslint/typescript-eslint documentation for more details }, - { - "files": ["*.tsx"], - "parserOptions": { - "project": "./tsconfig.json" - }, - "extends": [ - "@mediamonks/eslint-config", - "@mediamonks/eslint-config-react", - "@mediamonks/eslint-config-typescript", - "@mediamonks/eslint-config-typescript-react" - ] - } - ] -} + }, +]; ``` diff --git a/package.json b/package.json index 016ba60..27b7708 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,14 @@ "eslint-config" ], "type": "module", + "exports": { + ".": "./index.js" + }, + "files": [ + "src/**/*", + "LICENSE", + "README.md" + ], "scripts": { "eslint": "eslint .", "eslint:fix": "eslint . --fix",