Skip to content

Commit

Permalink
Merge pull request #15 from Torathion/4.0.0
Browse files Browse the repository at this point in the history
4.0.0
  • Loading branch information
Torathion authored Nov 10, 2024
2 parents dba2cbe + 208d644 commit 57f48a3
Show file tree
Hide file tree
Showing 71 changed files with 8,256 additions and 4,929 deletions.
3 changes: 1 addition & 2 deletions .ncurc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"format": "group",
"upgrade": true,
"reject": ["eslint"]
"upgrade": true
}
77 changes: 77 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,82 @@
# Changelog

## [4.0.0] 2024-11-10

### BREAKING

- Removed `angular` profile as I'm not using this framework anymore
- Removed `cypress` profile for the same reason
- Removed `fp` profile in favor of introducing the `apply` option
- Remove `json` profile in favor of introducing the `externalConfigs` option
- Removed `storybook` support as I'm not using it and can be easily added externally, because of it's minimal configuration

### Added

- more rules and changed deprecated rules in VSCode file patching.
- `no-loss-of-precision` as the JS interpreter can only read a specific precision of numbers
- `ts/no-unnecessary-parameter-property-assignment` to shorten class constructor code
- `guard-for-in` to not accidentally iterate through object prototype values
- `logical-assignment-operators` to shorten code
- `no-constructor-return` to prevent useless code
- `no-eq-null` to enforce `===` and `!==` in `null` comparisons
- `no-eval` to prevent xss
- `no-extend-native` as it's a memory and performance consuming anti-pattern
- Way more promise rules for safer `Promise` development
- Emit error if an unknown profile has been given
- Enabled `eslint-plugin-jsx-a11y` back again
- Using the new `projectService` property of TypeScript-Eslint 8
- Manual `tsconfigPath` option for tsconfig project resolving
- `trim` option as a partner of `rename` to permanently remove a part of a plugin name
- More errors for clearer troubleshooting

### Fixed

- Properly finish tool if an error has been encountered
- Crash upon not giving an option object
- Adjusted profile merging to not overwrite settings

### Changed

- Overhauled plugin re-importing from cache to both consider the current project and `eslint-config-shiny`'s dependencies
- Overhauled project structure to support the caching of plugins importing sub plugins. Internally for now.
- Overhauled `parseIgnoreFiles` to go up the file tree to find ignore files
- Overhauled `DisplayTaskHandler` to support the branching routes of the tool
- increase tolerance in `no-secrets/no-secrets`
- Disabled void return checks in `ts/no-misused-promises` for async html event handlers
- Updated `perfectionist` rules
- Updated `stylistic` rules
- Optimized the size of cache files
- Further optimization in renaming and parsing rules
- Migrated back to `eslint-plugin-import`
- Reduced the number of resolved extensions in the base config and distributed the rest to the corresponding profiles
- Migrated from `eslint-plugin-vitest` to `@vitest/eslint-plugin`
- `test` profile does not extend from `base` anymore to reduce cache file size
- Use `perfectionist` import sorting instead of `import`'s

### Removed

- `unicorn/prefer-modern-maths-apis` as some functions kill the performance
- `styleJsx/jsx-max-props-per-line` in favor of prettier line length
- `unicorn/no-array-callback-reference` as it disallowed the reuse of mapper functions
- deprecated `.eslintignore` from file `ignoreFiles` default
- abandoned plugin `eslint-plugin-deprecation` for the corresponding ts rule
- `eslint-plugin-xss` for being abandoned
- `eslint-plugin-ssr-friendly` for being abandoned
- `@arthurgeron/eslint-plugin-react-usememo` for not supporting Eslint 9
- `eslint-plugin-redundant-undefined` for `ts/no-duplicate-type-constituents`
- `eslint-plugin-node-security` for being abandoned
- the parsing of duplicate `eslint-plugin-sdl` rules
- Migrated `eslint-plugin-eslint-comments` to the `@eslint-community` one

### Misc

- Updated dependencies
- Updated types
- the rule replacement concept as this only bloated the cache file and most of those replaced rules are already deprecated
- Added resolutions to the package.json
- Updated package manager
- Cleanup

## [3.2.1] 2024-05-21

### Changed
Expand Down
58 changes: 43 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ Make your code so clean and polished that it shines! :sparkles:

`eslint-config-shiny` is a sophisticated configuration tool to create the most optimal eslint experience by doing all the heavy work for you! Just say what framework and for what purpose you want to use it and `eslint-config-shiny` will do the rest for you.

## As of now, it does not work with eslint 9 as most plugins haven't updated yet. Please stay with eslint 8.57.0!

## Installation

```powershell
Expand Down Expand Up @@ -61,6 +59,26 @@ export [
]
```

Applying recommended rules from other plugins:

```js
import fp from 'eslint-plugin-functional'
import shiny from 'eslint-config-shiny'

export await shiny({ configs: ['react'], apply: {fp} })
```

Adding external configs:

```js

import packageJson from 'eslint-plugin-package-json/configs/recommended'
import json from 'eslint-plugin-package-json'
import shiny from 'eslint-config-shiny'

export await shiny({ configs: ['react'], externalConfigs: [packageJson, json.configs.recommended] })
```

## Important :warning:

- It's forced to be ESM
Expand All @@ -70,20 +88,16 @@ export [
- It's very opinionated with a lot of formatting rules
- It's written to output performant code. Any plugins that increase readability, but can decrease the performance in any away, will be deactivated.

## Supported frameworks

[x] Angular
I have no idea, why the eslint version warning is always coming up. I suspect it has to do with `eslint-plugin-sonarjs`

[x] Cypress
## Supported frameworks

[x] Jest

[x] Node.js

[x] React

[x] Storybook

[x] TestingLibrary

[x] Vitest
Expand All @@ -100,7 +114,12 @@ export [

### Configuration

If you have further questions with the config object, you can use the type `ShinyConfig`
The `ShinyConfig` is a big and flexible object that holds all the options of the project and is used to further to optimize the experience of using ESLint.

### apply

- Adds the recommended rules and the plugin to the base config.
- Only works if you have a base profile selected (so, not test or format)

### cache

Expand All @@ -114,16 +133,12 @@ If you have further questions with the config object, you can use the type `Shin
- Specify which configuration preset you want to use
- The preset names are mapped to the profile file names.
- Possible profiles:
- `angular`
- `base`
- `cypress`
- `format`
- `fp`
- `jest`
- `json`
- `node`
- `react`
- `test-angular`
- `test-base`
- `test-react`
- `test-vue`
Expand All @@ -135,10 +150,15 @@ If you have further questions with the config object, you can use the type `Shin
- **Default**: `['base']`
- Profiles extend from each other in a tree structure way. You are still allowed to use as many profiles as you want.

### externalConfigs

- Additional configs to add to the final output config array
- Those configs will also be cached and optimized

### ignoreFiles

- Specifies the ignore files you want to use
- **Default**: `['.gitignore', '.eslintignore']`
- **Default**: `['.gitignore']`

### indent

Expand All @@ -165,7 +185,6 @@ If you have further questions with the config object, you can use the type `Shin

```ts
{
'@arthurgeron/react-usememo': 'use-memo',
'@eslint-react': 'react',
'@microsoft/sdl': 'sdl',
'@stylistic/js': 'styleJs,'
Expand All @@ -181,6 +200,15 @@ If you have further questions with the config object, you can use the type `Shin
- All plugins fetch the corresponding files from the given root directory and will ignore sub directory files
- **Default**: `process.cwd()`

### trim

- Brother of `rename` that instead removes parts of the plugin name permanently.
- **Default**: `['@eslint-community']`

### tsconfigPath

- A manual way to define the path of the `tsconfig.json` to use, if the automatic search fails

### updateBrowsersList

- Updates the browsers list for `eslint-plugin-compat`
Expand Down
36 changes: 26 additions & 10 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { Linter } from 'eslint'
import { ESLint } from 'eslint'
import { FlatConfig } from '@typescript-eslint/utils/ts-eslint'

export type Profile =
| 'angular'
| 'base'
| 'cypress'
| 'format'
| 'fp'
| 'jest'
| 'json'
| 'node'
| 'react'
| 'test-angular'
| 'test-base'
| 'test-react'
| 'test-vue'
Expand All @@ -21,22 +17,31 @@ export type Profile =
| 'web'

export interface ShinyConfig {
/**
* Eslint plugins to apply to this config. This means, the plugin is added to the plugin array of the base config and all recommended rules are
* added to the base rules. This, of course, only works, if the config includes a config extending from base (vue, react, web, node).
*/
apply?: Record<string, ESLint.Plugin>
/**
* Enables the option to cache the entire converted config to a .temp folder
*
* @defaultValue `true`
*/
cache: boolean
/**
* Name of the predefined flatconfigs to use
* Name of the predefined flat configs to use
*
* @defaultValue `['base']`
*/
configs: Profile[]
/**
* Additional configs to be parsed as well. Those will be treated as isolated config objects, but will be affected by caching and optimizing.
*/
externalConfigs?: FlatConfig.Config[]
/**
* Names of the .ignore files to use.
*
* @defaultValue `['.eslintignore', '.gitignore']`
* @defaultValue `['.gitignore']`
*/
ignoreFiles: string[]
/**
Expand Down Expand Up @@ -68,7 +73,7 @@ export interface ShinyConfig {
* // Renames all rules of "typescript-eslint" to "ts"
* export default await shiny({ configs: ['base'], rename: { '@typescript-eslint': 'ts' }})
* ```
* @defaultValue: `{ '@arthurgeron/react-usememo': 'use-memo', '@typescript-eslint': 'ts', '@microsoft/sdl': 'sdl', '@stylistic/ts': 'styleTs', '@stylistic/js': 'styleJs', '@stylistic/Jsx': 'styleJsx' }`
* @defaultValue: `{ '@typescript-eslint': 'ts', '@microsoft/sdl': 'sdl', '@stylistic/ts': 'styleTs', '@stylistic/js': 'styleJs', '@stylistic/Jsx': 'styleJsx' }`
*/
rename: Record<string, string>
/**
Expand All @@ -77,6 +82,17 @@ export interface ShinyConfig {
* @defaultValue `process.cwd()`
*/
root: string
/**
* Extra list of renames that instead strip the entire value instead of replacing it. This list will always be merged with the defaults to
* handle the `base` profile.
*
* @defaultValue `['@eslint-community']`
*/
trim: string[]
/**
* The manual way to specify the tsconfig to use, if the tool can't determine it.
*/
tsconfigPath?: string
/**
* Updates the browserslist used for plugins
*
Expand All @@ -91,4 +107,4 @@ export interface ShinyConfig {
* @param options - options for this tool
* @returns a fully configured Flatconfig array.
*/
export default function shiny(options: Partial<ShinyConfig>): Promise<Linter.FlatConfig[]>
export default function shiny(options: Partial<ShinyConfig>): Promise<FlatConfig.Config>
Loading

0 comments on commit 57f48a3

Please sign in to comment.