Skip to content

Commit

Permalink
fix: add non compatible rules
Browse files Browse the repository at this point in the history
  • Loading branch information
arianrhodsandlot committed May 20, 2024
1 parent 8b825ad commit 4cc0dea
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.15.1] - 2024-05-20
## Fixed
- Turn on the no-undef rule for js files
- Turn off the no-undef rule for ts files only
- Improve compatibility

## [0.15.0] - 2024-05-17
### Added
Expand Down
1 change: 0 additions & 1 deletion src/flat-configs/custom/custom-rules/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export const eslintRules: FlatConfigRules = {
'no-sequences': 'error',
'no-template-curly-in-string': 'error',
'no-throw-literal': 'error',
'no-undef': 'off',
'no-undef-init': 'error',
'no-unmodified-loop-condition': 'error',
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
Expand Down
2 changes: 2 additions & 0 deletions src/flat-configs/custom/custom-rules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { eslintCommentsRules } from './eslint-comments.js'
import { eslintRules } from './eslint.js'
import { importRules } from './import.js'
import { nRules } from './n.js'
import { nonCompatibleRules } from './non-compatible.js'
import { perfectionistRules } from './perfectionist.js'
import { promiseRules } from './promise.js'
import { reactRules } from './react.js'
Expand Down Expand Up @@ -59,6 +60,7 @@ export function getCustomRulesConfigs() {
if (options.perfectionist) {
Object.assign(customRules, perfectionistRules)
}
Object.assign(customRules, nonCompatibleRules)

const customRulesConfigs: FlatConfigs = [{ name: 'custom-rules', rules: customRules }]
return customRulesConfigs
Expand Down
11 changes: 11 additions & 0 deletions src/flat-configs/custom/custom-rules/non-compatible.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Linter } from 'eslint'
import type { FlatConfigRules } from '../../../types/eslint.js'

const eslintMajorVersion = Number.parseInt(Linter.version, 10)

export const nonCompatibleRules: FlatConfigRules =
eslintMajorVersion > 8
? {
'promise/no-multiple-resolved': 'off',
}
: {}
2 changes: 2 additions & 0 deletions src/flat-configs/custom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getMarkdownConfigs } from './markdown.js'
import { getNConfigs } from './n.js'
import { getReactConfigs } from './react.js'
import { getTestConfigs } from './test.js'
import { getTypeScriptConfigs } from './typescript.js'

export function getCustomFlatConfigs() {
return [
Expand All @@ -19,6 +20,7 @@ export function getCustomFlatConfigs() {
...getNConfigs(),
...getReactConfigs(),
...getTestConfigs(),
...getTypeScriptConfigs(),

...getConflictConfigs(),
]
Expand Down
15 changes: 15 additions & 0 deletions src/flat-configs/custom/typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { tsGlob } from '../../lib/constants.js'
import type { FlatConfigs } from '../../types/eslint.js'

export function getTypeScriptConfigs() {
const typeScriptConfigs: FlatConfigs = [
{
files: [tsGlob],
name: 'typescript',
rules: {
'no-undef': 'off',
},
},
]
return typeScriptConfigs
}

0 comments on commit 4cc0dea

Please sign in to comment.