@ocavue/eslint-config 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,6 +5,7 @@ A set of ESLint shareable configs for TypeScript projects.
5
5
  - Out of the box support for TypeScript, React, and Markdown
6
6
  - Sort your imports
7
7
  - Sort your fields in `package.json`
8
+ - Prefer top-level function declarations over function expressions
8
9
 
9
10
  ## Install
10
11
 
@@ -75,3 +76,8 @@ If you are using VS Code, you and install [ESLint extension](https://marketplace
75
76
  }
76
77
  }
77
78
  ```
79
+
80
+ ## Inspired by
81
+
82
+ - https://github.com/antfu/eslint-config
83
+ - https://github.com/sxzz/eslint-config
@@ -0,0 +1,2 @@
1
+ export function antfu(): import("eslint-define-config").FlatESLintConfigItem[];
2
+ //# sourceMappingURL=antfu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"antfu.d.ts","sourceRoot":"","sources":["../../src/antfu.js"],"names":[],"mappings":"AAEA,+EAcC"}
@@ -1,3 +1,10 @@
1
+ /**
2
+ * @typedef {Object} BasicOptions
3
+ * @property {import('./typescript.js').TypescriptOptions} [typescript]
4
+ */
5
+ /**
6
+ * @param {BasicOptions} [options]
7
+ */
1
8
  export function basic(options?: BasicOptions | undefined): import("eslint-define-config").FlatESLintConfigItem[];
2
9
  export type BasicOptions = {
3
10
  typescript?: import("./typescript.js").TypescriptOptions | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"basic.d.ts","sourceRoot":"","sources":["../../src/basic.js"],"names":[],"mappings":"AAkBO,iHAgBN"}
1
+ {"version":3,"file":"basic.d.ts","sourceRoot":"","sources":["../../src/basic.js"],"names":[],"mappings":"AAWA;;;GAGG;AAEH;;GAEG;AACH,iHAiBC"}
@@ -1 +1 @@
1
- {"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../../src/imports.js"],"names":[],"mappings":"AAKO,iFA0CN"}
1
+ {"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../../src/imports.js"],"names":[],"mappings":"AAKA,iFA0CC"}
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/markdown.js"],"names":[],"mappings":"AAOO,kFA0DN"}
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/markdown.js"],"names":[],"mappings":"AAOA,kFA0DC"}
@@ -1 +1 @@
1
- {"version":3,"file":"no-only-tests.d.ts","sourceRoot":"","sources":["../../src/no-only-tests.js"],"names":[],"mappings":"AAKO,qFAcN"}
1
+ {"version":3,"file":"no-only-tests.d.ts","sourceRoot":"","sources":["../../src/no-only-tests.js"],"names":[],"mappings":"AAKA,qFAcC"}
@@ -1,2 +1,5 @@
1
+ /**
2
+ * Sort package.json keys
3
+ */
1
4
  export function packageJson(): import("eslint-define-config").FlatESLintConfigItem[];
2
5
  //# sourceMappingURL=package-json.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../../src/package-json.js"],"names":[],"mappings":"AAUO,qFA0EN"}
1
+ {"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../../src/package-json.js"],"names":[],"mappings":"AAOA;;GAEG;AACH,qFA0EC"}
@@ -1,2 +1,8 @@
1
+ /**
2
+ * Turns off all rules that are unnecessary or might conflict with Prettier.
3
+ *
4
+ * Notice that this config does not run `prettier` as an ESLint rule, so you
5
+ * have to run `pretter` separately for formatting.
6
+ */
1
7
  export function prettier(): import("eslint-define-config").FlatESLintConfigItem[];
2
8
  //# sourceMappingURL=prettier.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prettier.d.ts","sourceRoot":"","sources":["../../src/prettier.js"],"names":[],"mappings":"AAQO,kFAWN"}
1
+ {"version":3,"file":"prettier.d.ts","sourceRoot":"","sources":["../../src/prettier.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,kFAWC"}
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/react.js"],"names":[],"mappings":"AASO,+EAwCN"}
1
+ {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/react.js"],"names":[],"mappings":"AASA,+EAwCC"}
@@ -1,3 +1,11 @@
1
+ /**
2
+ * @typedef {Object} TypescriptOptions
3
+ * @property {string | false} [project] - Path to tsconfig.json, defaults
4
+ * to './tsconfig.json'. You can pass `false` to disable the tsconfig.json check.
5
+ */
6
+ /**
7
+ * @param {TypescriptOptions} [options]
8
+ */
1
9
  export function typescript(options?: TypescriptOptions | undefined): import("eslint-define-config").FlatESLintConfigItem[];
2
10
  export type TypescriptOptions = {
3
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/typescript.js"],"names":[],"mappings":"AAkBO,2HAsEN;;;;;;;;qBArFoB,2BAA2B;qBAD3B,kCAAkC"}
1
+ {"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/typescript.js"],"names":[],"mappings":"AASA;;;;GAIG;AAEH;;GAEG;AACH,2HAsEC;;;;;;;;qBArFoB,2BAA2B;qBAD3B,kCAAkC"}
@@ -1 +1 @@
1
- {"version":3,"file":"unicorn.d.ts","sourceRoot":"","sources":["../../src/unicorn.js"],"names":[],"mappings":"AAKO,iFA+DN"}
1
+ {"version":3,"file":"unicorn.d.ts","sourceRoot":"","sources":["../../src/unicorn.js"],"names":[],"mappings":"AAKA,iFA+DC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ocavue/eslint-config",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.1.0",
5
5
  "packageManager": "pnpm@8.5.1",
6
6
  "description": "",
7
7
  "author": "ocavue <ocavue@gmail.com>",
@@ -37,6 +37,7 @@
37
37
  "eslint-config-prettier": "^8.8.0",
38
38
  "eslint-define-config": "^1.20.0",
39
39
  "eslint-import-resolver-typescript": "^3.5.5",
40
+ "eslint-plugin-antfu": "^0.39.3",
40
41
  "eslint-plugin-import": "^2.27.5",
41
42
  "eslint-plugin-jsonc": "^2.8.0",
42
43
  "eslint-plugin-markdown": "^3.0.0",
package/src/antfu.js ADDED
@@ -0,0 +1,17 @@
1
+ import antfuPlugin from 'eslint-plugin-antfu'
2
+
3
+ export function antfu() {
4
+ /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
5
+ const config = [
6
+ {
7
+ plugins: {
8
+ antfu: antfuPlugin,
9
+ },
10
+ rules: {
11
+ 'antfu/top-level-function': 'error',
12
+ },
13
+ },
14
+ ]
15
+
16
+ return config
17
+ }
package/src/basic.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // @ts-check
2
2
 
3
+ import { antfu } from './antfu.js'
3
4
  import { imports } from './imports.js'
4
5
  import { noOnlyTests } from './no-only-tests.js'
5
6
  import { packageJson } from './package-json.js'
@@ -16,7 +17,7 @@ import { unicorn } from './unicorn.js'
16
17
  /**
17
18
  * @param {BasicOptions} [options]
18
19
  */
19
- export const basic = (options) => {
20
+ export function basic(options) {
20
21
  /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
21
22
  const config = [
22
23
  {
@@ -27,6 +28,7 @@ export const basic = (options) => {
27
28
  ...imports(),
28
29
  ...packageJson(),
29
30
  ...unicorn(),
31
+ ...antfu(),
30
32
  ...noOnlyTests(),
31
33
  ...prettier(),
32
34
  ]
package/src/imports.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // @ts-expect-error no type
4
4
  import importPlugin from 'eslint-plugin-import'
5
5
 
6
- export const imports = () => {
6
+ export function imports() {
7
7
  /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
8
8
  const config = [
9
9
  {
package/src/markdown.js CHANGED
@@ -5,7 +5,7 @@ import markdownPlugin from 'eslint-plugin-markdown'
5
5
 
6
6
  import { GLOB_MARKDOWN, GLOB_SRC, GLOB_VUE } from './shared.js'
7
7
 
8
- export const markdown = () => {
8
+ export function markdown() {
9
9
  /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
10
10
  const config = [
11
11
  {
@@ -3,7 +3,7 @@
3
3
  // @ts-expect-error: eslint-plugin-unicorn is not typed
4
4
  import plugin from 'eslint-plugin-no-only-tests'
5
5
 
6
- export const noOnlyTests = () => {
6
+ export function noOnlyTests() {
7
7
  /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
8
8
  const config = [
9
9
  {
@@ -8,7 +8,7 @@ import { GLOB_PACKAGE_JSON } from './shared.js'
8
8
  /**
9
9
  * Sort package.json keys
10
10
  */
11
- export const packageJson = () => {
11
+ export function packageJson() {
12
12
  /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
13
13
  const config = [
14
14
  {
package/src/prettier.js CHANGED
@@ -6,7 +6,7 @@ import prettierConfig from 'eslint-config-prettier'
6
6
  * Notice that this config does not run `prettier` as an ESLint rule, so you
7
7
  * have to run `pretter` separately for formatting.
8
8
  */
9
- export const prettier = () => {
9
+ export function prettier() {
10
10
  /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
11
11
  const config = [
12
12
  {
package/src/react.js CHANGED
@@ -7,7 +7,7 @@ import reactHooksPlugin from 'eslint-plugin-react-hooks'
7
7
 
8
8
  import { GLOB_TSX } from './shared.js'
9
9
 
10
- export const react = () => {
10
+ export function react() {
11
11
  /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
12
12
  const config = [
13
13
  {
package/src/typescript.js CHANGED
@@ -16,7 +16,7 @@ export { tsParser, tsPlugin }
16
16
  /**
17
17
  * @param {TypescriptOptions} [options]
18
18
  */
19
- export const typescript = (options) => {
19
+ export function typescript(options) {
20
20
  const project = options?.project ?? './tsconfig.json'
21
21
 
22
22
  /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
package/src/unicorn.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // @ts-expect-error: eslint-plugin-unicorn is not typed
4
4
  import plugin from 'eslint-plugin-unicorn'
5
5
 
6
- export const unicorn = () => {
6
+ export function unicorn() {
7
7
  /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
8
8
  const config = [
9
9
  {