@constructive-io/eslint-config 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Constructive <developers@constructive.io>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # @constructive-io/eslint-config
2
+
3
+ <p align="center">
4
+ <img src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" height="250"><br />
5
+ @constructive-io/eslint-config
6
+ <br />
7
+ <a href="https://github.com/constructive-io/dev-utils/actions/workflows/ci.yml">
8
+ <img height="20" src="https://github.com/constructive-io/dev-utils/actions/workflows/ci.yml/badge.svg" />
9
+ </a>
10
+ <a href="https://github.com/constructive-io/dev-utils/blob/main/LICENSE">
11
+ <img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/>
12
+ </a>
13
+ </p>
14
+
15
+ Shared [ESLint 9 flat config](https://eslint.org/docs/latest/use/configure/configuration-files) for Constructive repos. It is the flat-config translation of the `.eslintrc.json` that every repo used to carry, published once so the rules can't drift per repo.
16
+
17
+ ## install
18
+
19
+ ```sh
20
+ npm install --save-dev @constructive-io/eslint-config eslint
21
+ ```
22
+
23
+ ## usage
24
+
25
+ ```js
26
+ // eslint.config.mjs
27
+ import base from '@constructive-io/eslint-config';
28
+
29
+ export default [...base, { ignores: ['**/generated/**'] }];
30
+ ```
31
+
32
+ That's it — three lines. Anything you append wins, since flat config is last-match-wins.
33
+
34
+ ## what's in it
35
+
36
+ - `@typescript-eslint` parser + `recommended`, on top of `eslint:recommended`
37
+ - `eslint-config-prettier` applied last, so formatting rules never fight prettier
38
+ - `simple-import-sort` for imports and exports (warn)
39
+ - `unused-imports/no-unused-imports` (warn)
40
+ - `indent: 2`, single quotes (escape/template-literal friendly), `quote-props: as-needed`, `semi: always`
41
+ - `@typescript-eslint/no-unused-vars` as a warning, ignoring `React`, `res`, `next` and `_`-prefixed args
42
+ - off: `no-explicit-any`, `no-var-requires` / `no-require-imports`, `ban-ts-comment`, `no-unsafe-declaration-merging`, `no-console`, `prefer-const`, `no-case-declarations`, `no-implicit-globals`
43
+ - browser + node + es2021 + jest globals (via [`globals`](https://www.npmjs.com/package/globals))
44
+ - default ignores: `**/node_modules/**`, `**/dist/**`, `**/esm/**`, `**/coverage/**`, `**/build/**`, `**/generated/**`, `**/*.d.ts`
45
+
46
+ ## api
47
+
48
+ ### `default` — `Linter.Config[]`
49
+
50
+ The config array. Spread it; this is what nearly every repo wants.
51
+
52
+ ### `createConfig(options?)`
53
+
54
+ For repos that need to change the config rather than append to it. All options are optional and replace (not merge with) the defaults, except `rules`, which is merged last.
55
+
56
+ ```js
57
+ import { createConfig } from '@constructive-io/eslint-config';
58
+
59
+ export default createConfig({
60
+ ignores: ['**/node_modules/**', '**/out/**'],
61
+ rules: { 'simple-import-sort/imports': 'error' }
62
+ });
63
+ ```
64
+
65
+ ### `defaultIgnores`, `files`, `rules`
66
+
67
+ The individual pieces, exported so you can build your own array without re-typing them.
68
+
69
+ ## no build step
70
+
71
+ This package ships hand-written `.mjs` and `.d.ts` — it is intentionally a leaf with no build tooling of its own, so build tools (`makage`) can depend on it without creating a publish cycle.
package/index.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import type { Linter } from 'eslint';
2
+
3
+ export declare const defaultIgnores: string[];
4
+ export declare const files: string[];
5
+ export declare const rules: Linter.RulesRecord;
6
+
7
+ export interface CreateConfigOptions {
8
+ ignores?: string[];
9
+ files?: string[];
10
+ rules?: Linter.RulesRecord;
11
+ }
12
+
13
+ export declare function createConfig(
14
+ options?: CreateConfigOptions
15
+ ): Linter.Config[];
16
+
17
+ declare const config: Linter.Config[];
18
+ export default config;
package/index.mjs ADDED
@@ -0,0 +1,91 @@
1
+ import js from '@eslint/js';
2
+ import tsPlugin from '@typescript-eslint/eslint-plugin';
3
+ import tsParser from '@typescript-eslint/parser';
4
+ import prettier from 'eslint-config-prettier';
5
+ import simpleImportSort from 'eslint-plugin-simple-import-sort';
6
+ import unusedImports from 'eslint-plugin-unused-imports';
7
+ import globals from 'globals';
8
+
9
+ export const defaultIgnores = [
10
+ '**/node_modules/**',
11
+ '**/dist/**',
12
+ '**/esm/**',
13
+ '**/coverage/**',
14
+ '**/build/**',
15
+ '**/generated/**',
16
+ '**/*.d.ts'
17
+ ];
18
+
19
+ export const files = ['**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'];
20
+
21
+ export const rules = {
22
+ indent: ['error', 2],
23
+ quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
24
+ 'quote-props': ['error', 'as-needed'],
25
+ semi: ['error', 'always'],
26
+
27
+ 'simple-import-sort/imports': 'warn',
28
+ 'simple-import-sort/exports': 'warn',
29
+ 'unused-imports/no-unused-imports': 'warn',
30
+
31
+ '@typescript-eslint/no-unused-vars': [
32
+ 'warn',
33
+ { argsIgnorePattern: 'React|res|next|^_' }
34
+ ],
35
+
36
+ // empty interfaces are used as extension points / named aliases
37
+ '@typescript-eslint/no-empty-object-type': [
38
+ 'error',
39
+ { allowInterfaces: 'always' }
40
+ ],
41
+
42
+ '@typescript-eslint/no-explicit-any': 'off',
43
+ '@typescript-eslint/no-require-imports': 'off',
44
+ '@typescript-eslint/no-var-requires': 'off',
45
+ '@typescript-eslint/ban-ts-comment': 'off',
46
+ '@typescript-eslint/no-unsafe-declaration-merging': 'off',
47
+ 'no-console': 'off',
48
+ 'prefer-const': 'off',
49
+ 'no-case-declarations': 'off',
50
+ 'no-implicit-globals': 'off'
51
+ };
52
+
53
+ /**
54
+ * Build the shared config array.
55
+ *
56
+ * @param {{ ignores?: string[], files?: string[], rules?: Record<string, unknown> }} [options]
57
+ */
58
+ export function createConfig(options = {}) {
59
+ return [
60
+ { ignores: options.ignores ?? defaultIgnores },
61
+ {
62
+ files: options.files ?? files,
63
+ languageOptions: {
64
+ parser: tsParser,
65
+ ecmaVersion: 'latest',
66
+ sourceType: 'module',
67
+ globals: {
68
+ ...globals.browser,
69
+ ...globals.node,
70
+ ...globals.es2021,
71
+ ...globals.jest
72
+ }
73
+ },
74
+ plugins: {
75
+ '@typescript-eslint': tsPlugin,
76
+ 'simple-import-sort': simpleImportSort,
77
+ 'unused-imports': unusedImports
78
+ },
79
+ rules: {
80
+ ...js.configs.recommended.rules,
81
+ ...tsPlugin.configs['eslint-recommended'].overrides[0].rules,
82
+ ...tsPlugin.configs.recommended.rules,
83
+ ...prettier.rules,
84
+ ...rules,
85
+ ...options.rules
86
+ }
87
+ }
88
+ ];
89
+ }
90
+
91
+ export default createConfig();
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@constructive-io/eslint-config",
3
+ "version": "0.2.0",
4
+ "author": "Constructive <developers@constructive.io>",
5
+ "description": "Shared ESLint 9 flat config for Constructive repos",
6
+ "main": "index.mjs",
7
+ "types": "index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts",
11
+ "default": "./index.mjs"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "index.mjs",
17
+ "index.d.ts",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "homepage": "https://github.com/constructive-io/dev-utils",
22
+ "license": "MIT",
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/constructive-io/dev-utils"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/constructive-io/dev-utils/issues"
32
+ },
33
+ "scripts": {
34
+ "lint": "eslint . --fix"
35
+ },
36
+ "dependencies": {
37
+ "@eslint/js": "^9.39.2",
38
+ "@typescript-eslint/eslint-plugin": "^8.53.1",
39
+ "@typescript-eslint/parser": "^8.53.1",
40
+ "eslint-config-prettier": "^10.1.8",
41
+ "eslint-plugin-simple-import-sort": "^12.1.1",
42
+ "eslint-plugin-unused-imports": "^4.3.0",
43
+ "globals": "^17.7.0"
44
+ },
45
+ "peerDependencies": {
46
+ "eslint": "^9"
47
+ },
48
+ "keywords": [
49
+ "eslint",
50
+ "eslintconfig",
51
+ "flat-config",
52
+ "typescript",
53
+ "prettier",
54
+ "lint"
55
+ ],
56
+ "gitHead": "2985d68020ec7d1eeae9a839bdb7ebb68727dd55"
57
+ }