Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: antfu/eslint-config
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.19.4
Choose a base ref
...
head repository: antfu/eslint-config
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.20.0
Choose a head ref
  • 4 commits
  • 11 files changed
  • 1 contributor

Commits on Apr 4, 2022

  1. chore: update

    antfu authored Apr 4, 2022
    Copy the full SHA
    327ab9d View commit details

Commits on Apr 6, 2022

  1. Update README.md

    antfu authored Apr 6, 2022
    Copy the full SHA
    eaff018 View commit details
  2. Copy the full SHA
    d23abea View commit details
  3. release v0.20.0

    antfu committed Apr 6, 2022
    Copy the full SHA
    0af15d4 View commit details
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -34,7 +34,8 @@ For example:
```json
{
"scripts": {
"lint": "eslint ."
"lint": "eslint .",
"lint:fix": "eslint . --fix"
}
}
```
@@ -54,7 +55,9 @@ Create `.vscode/settings.json`

## Check Also

- [antfu/dotfiles](https://github.com/antfu/dotfiles) - My dotfiles
- [antfu/vscode-settings](https://github.com/antfu/vscode-settings) - My VS Code settings
- [antfu/eslint-config](https://github.com/antfu/eslint-config) - My ESLint config
- [antfu/ts-starter](https://github.com/antfu/ts-starter) - My starter template for TypeScript library
- [antfu/vitesse](https://github.com/antfu/vitesse) - My starter template for Vue & Vite app

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-monorepo",
"version": "0.19.4",
"version": "0.20.0",
"private": true,
"license": "MIT",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
2 changes: 1 addition & 1 deletion packages/all/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config",
"version": "0.19.4",
"version": "0.20.0",
"description": "",
"keywords": [],
"license": "MIT",
1 change: 1 addition & 0 deletions packages/basic/index.js
Original file line number Diff line number Diff line change
@@ -293,5 +293,6 @@ module.exports = {
// antfu
'antfu/no-leading-newline': 'error',
'antfu/if-newline': 'error',
'antfu/prefer-inline-type-import': 'error',
},
}
2 changes: 1 addition & 1 deletion packages/basic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-basic",
"version": "0.19.4",
"version": "0.20.0",
"description": "",
"keywords": [],
"license": "MIT",
2 changes: 1 addition & 1 deletion packages/eslint-plugin-antfu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-antfu",
"version": "0.19.4",
"version": "0.20.0",
"license": "MIT",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
2 changes: 2 additions & 0 deletions packages/eslint-plugin-antfu/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import ifNewline from './rules/if-newline'
import noLeadingNewline from './rules/no-leading-newline'
import preferInlineTypeImport from './rules/prefer-inline-type-import'

export default {
rules: {
'no-leading-newline': noLeadingNewline,
'if-newline': ifNewline,
'prefer-inline-type-import': preferInlineTypeImport,
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Ported from https://github.com/gajus/eslint-plugin-canonical/blob/master/src/rules/preferInlineTypeImport.js
// by Gajus Kuizinas https://github.com/gajus

import { createEslintRule } from '../utils'

export const RULE_NAME = 'prefer-inline-type-import'
export type MessageIds = 'preferInlineTypeImport'
export type Options = []

export default createEslintRule<Options, MessageIds>({
name: RULE_NAME,
meta: {
type: 'suggestion',
docs: {
description: 'Newline after if',
recommended: 'error',
},
fixable: 'code',
schema: [],
messages: {
preferInlineTypeImport: 'Prefer inline type import',
},
},
defaultOptions: [],
create: (context) => {
const sourceCode = context.getSourceCode()
return {
ImportDeclaration: (node) => {
if (node.importKind === 'type') {
context.report({
*fix(fixer) {
yield * removeTypeSpecifier(fixer, sourceCode, node)

for (const specifier of node.specifiers)
yield fixer.insertTextBefore(specifier, 'type ')
},
loc: node.loc,
messageId: 'preferInlineTypeImport',
node,
})
}
},
}
},
})

function *removeTypeSpecifier(fixer, sourceCode, node) {
const importKeyword = sourceCode.getFirstToken(node)

const typeIdentifier = sourceCode.getTokenAfter(importKeyword)

yield fixer.remove(typeIdentifier)

if (importKeyword.loc.end.column + 1 === typeIdentifier.loc.start.column) {
yield fixer.removeRange([
importKeyword.range[1],
importKeyword.range[1] + 1,
])
}
}
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-react",
"version": "0.19.4",
"version": "0.20.0",
"description": "",
"keywords": [],
"license": "MIT",
2 changes: 1 addition & 1 deletion packages/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-ts",
"version": "0.19.4",
"version": "0.20.0",
"description": "",
"keywords": [],
"license": "MIT",
2 changes: 1 addition & 1 deletion packages/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-vue",
"version": "0.19.4",
"version": "0.20.0",
"description": "",
"keywords": [],
"license": "MIT",