lint-rules-alvin 1.0.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.
@@ -0,0 +1,9 @@
1
+ {
2
+ "editor.codeActionsOnSave": {
3
+ "source.fixAll.eslint": "explicit"
4
+ },
5
+ "eslint.codeAction.showDocumentation": {
6
+ "enable": true
7
+ },
8
+ "eslint.enable": true
9
+ }
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # lint-rules-alvin
2
+
3
+ [My](https://github.com/Ctrl-Shift-Alvin) personal repo containing configs for code linters. Some of my public repos use this, so it's public. A generalized config makes managaing configs much easier (once they're working, of course).
4
+
5
+ All dependencies are optional, but you need to install the correct ones depending on which files you use.
6
+
7
+ `eslint/configs` contains all different configs for each plugin. Sometimes there are multiple configs for the same plugin.
8
+
9
+ `eslint/custom_rules` contains custom rules that are used by the `eslint/configs/custom.js` file.
10
+
11
+ `eslint/presets` contains full configs that are mostly sets of configs from `eslint/configs`.
12
+
13
+ Feel free to fork and customize. In case anybody is insane (or too lazy to change to another config) and actually uses this, please only submit actual issues, not style changes, since... you know... it's my personal repo.
@@ -0,0 +1,31 @@
1
+ import eslintPluginAstro from 'eslint-plugin-astro';
2
+
3
+ /**
4
+ * The `ESLint` Astro config.
5
+ *
6
+ * Extends `eslint-plugin-astro`'s `flat/base` config.
7
+ */
8
+ export const astro = [
9
+ ...eslintPluginAstro.configs['flat/base'],
10
+ {
11
+ name: 'eslint-plugin-astro',
12
+ rules: {
13
+ 'astro/missing-client-only-directive-value': 'error',
14
+ 'astro/no-conflict-set-directives': 'error',
15
+ 'astro/no-deprecated-astro-canonicalurl': 'error',
16
+ 'astro/no-deprecated-astro-fetchcontent': 'error',
17
+ 'astro/no-deprecated-astro-resolve': 'error',
18
+ 'astro/no-deprecated-getentrybyslug': 'error',
19
+ 'astro/no-exports-from-components': 'error',
20
+ 'astro/no-unused-define-vars-in-style': 'error',
21
+ 'astro/valid-compile': 'error',
22
+ 'astro/no-set-html-directive': 'warn',
23
+ 'astro/no-set-text-directive': 'error',
24
+ 'astro/no-unused-css-selector': 'error',
25
+ 'astro/prefer-class-list-directive': 'error',
26
+ 'astro/prefer-object-class-list': 'error',
27
+ 'astro/prefer-split-class-list': 'off',
28
+ 'astro/sort-attributes': 'off'
29
+ }
30
+ }
31
+ ];
@@ -0,0 +1,22 @@
1
+ import path from 'node:path';
2
+ import { includeIgnoreFile } from '@eslint/compat';
3
+ import { globalIgnores } from 'eslint/config';
4
+
5
+ /**
6
+ * The `ESLint` base config. Includes base rules, ignore files and directives.
7
+ */
8
+ export const base = [
9
+ includeIgnoreFile(path.join(
10
+ process.cwd(),
11
+ '.gitignore'
12
+ )),
13
+ globalIgnores([
14
+ 'eslint.config.js',
15
+ 'eslint.config.ts'
16
+ ]),
17
+ {
18
+ name: 'base',
19
+ files: [ '**/*.{ts,tsx}' ],
20
+ rules: { 'no-undef': 'off' }
21
+ }
22
+ ];
@@ -0,0 +1,45 @@
1
+ import { newlineBetweenImportsRule } from '../custom_rules/newline-between-imports.js';
2
+ import { unnamedImportsLastRule } from '../custom_rules/unnamed-imports-last.js';
3
+ import { jsxMultilinePropNewlineRule } from '../custom_rules/jsx-multiline-prop-newline.js';
4
+ import { jsxNoSingleObjectCurlyNewlineRule } from '../custom_rules/jsx-no-single-object-curly-newline.js';
5
+ import { maxChainPerLineRule } from '../custom_rules/max-chain-per-line.js';
6
+ import { chainFirstOnNewlineRule } from '../custom_rules/chain-first-on-newline.js';
7
+ import { multilineParenNewlineRule } from '../custom_rules/multiline-paren-newline.js';
8
+
9
+ export const custom = {
10
+ plugins: {
11
+ custom: {
12
+ rules: {
13
+ 'newline-between-imports': newlineBetweenImportsRule,
14
+ 'unnamed-imports-last': unnamedImportsLastRule,
15
+ 'jsx-multiline-prop-newline': jsxMultilinePropNewlineRule,
16
+ 'jsx-no-single-object-curly-newline': jsxNoSingleObjectCurlyNewlineRule,
17
+ 'max-chain-per-line': maxChainPerLineRule,
18
+ 'chain-first-on-newline': chainFirstOnNewlineRule,
19
+ 'multiline-paren-newline': multilineParenNewlineRule
20
+ }
21
+ }
22
+ },
23
+ rules: {
24
+ 'custom/newline-between-imports': [
25
+ 'error',
26
+ { minItems: 2 }
27
+ ],
28
+ 'custom/unnamed-imports-last': 'error',
29
+ 'custom/jsx-multiline-prop-newline': 'error',
30
+ 'custom/jsx-no-single-object-curly-newline': 'error',
31
+ 'custom/max-chain-per-line': [
32
+ 'error',
33
+ { maxChain: 2 }
34
+ ],
35
+ 'custom/chain-first-on-newline': [
36
+ 'error',
37
+ 'require'
38
+ ],
39
+ 'custom/multiline-paren-newline': [
40
+ 'error',
41
+ { singleArgument: true }
42
+ ]
43
+ }
44
+ };
45
+
@@ -0,0 +1,77 @@
1
+ import { importX as eslintPluginImportX } from 'eslint-plugin-import-x';
2
+
3
+ /**
4
+ * The `ESLint` import config.
5
+ */
6
+ export const importX = {
7
+ name: 'eslint-plugin-import-x',
8
+ plugins: { 'import-x': eslintPluginImportX },
9
+ rules: {
10
+ 'import-x/export': 'error',
11
+ 'import-x/no-deprecated': 'error',
12
+ 'import-x/no-empty-named-blocks': 'error',
13
+ 'import-x/no-extraneous-dependencies': [
14
+ 'error',
15
+ {
16
+ devDependencies: true,
17
+ optionalDependencies: true,
18
+ peerDependencies: true,
19
+ bundledDependencies: true
20
+ }
21
+ ],
22
+ 'import-x/no-mutable-exports': 'error',
23
+ 'import-x/no-named-as-default': 'off',
24
+ 'import-x/no-named-as-default-member': 'off',
25
+ 'import-x/no-rename-default': 'off',
26
+
27
+ 'import-x/no-amd': 'error',
28
+ 'import-x/no-commonjs': 'error',
29
+ 'import-x/no-import-module-exports': 'error',
30
+ 'import-x/no-nodejs-modules': 'off',
31
+ 'import-x/unambiguous': 'error',
32
+
33
+ 'import-x/default': 'error',
34
+ 'import-x/named': 'error',
35
+ 'import-x/namespace': 'error',
36
+ 'import-x/no-absolute-path': 'error',
37
+ 'import-x/no-cycle': 'off',
38
+ 'import-x/no-dynamic-require': 'error',
39
+ 'import-x/no-internal-modules': 'off',
40
+ 'import-x/no-relative-packages': 'error',
41
+ 'import-x/no-relative-parent-imports': 'off',
42
+ 'import-x/no-restricted-paths': 'off', // Allow the user to override
43
+ 'import-x/no-self-import': 'error',
44
+ 'import-x/no-unresolved': 'error',
45
+ 'import-x/no-useless-path-segments': 'error',
46
+ 'import-x/no-webpack-loader-syntax': 'error',
47
+
48
+ 'import-x/consistent-type-specifier-style': [
49
+ 'error',
50
+ 'prefer-inline'
51
+ ],
52
+ 'import-x/dynamic-import-chunkname': 'off',
53
+ 'import-x/export-last': 'off',
54
+ 'import-x/extensions': 'off',
55
+ 'import-x/first': 'error',
56
+ 'import-x/group-exports': 'off',
57
+ 'import-x/imports-first': 'off', // Replaced by 'import/first'
58
+ 'import-x/max-dependencies': 'off',
59
+ 'import-x/newline-after-import': [
60
+ 'error',
61
+ { considerComments: false }
62
+ ],
63
+ 'import-x/no-anonymous-default-export': 'off', // See next rule
64
+ 'import-x/no-default-export': 'error',
65
+ 'import-x/no-duplicates': 'error',
66
+ 'import-x/no-named-default': 'off', // In favor of 'import/no-default-export'
67
+ 'import-x/no-named-export': 'off',
68
+ 'import-x/no-namespace': 'off',
69
+ 'import-x/no-unassigned-import': [
70
+ 'error',
71
+ { allow: [ '**/*.css' ] }
72
+ ],
73
+ 'import-x/order': 'error',
74
+ 'import-x/prefer-default-export': 'off',
75
+ 'import-x/prefer-namespace-import': 'off'
76
+ }
77
+ };
@@ -0,0 +1,22 @@
1
+ import { importX as eslintPluginImportX } from 'eslint-plugin-import-x';
2
+ import { importX } from './index.js';
3
+
4
+ /**
5
+ * The `ESLint` import config with a TS resolver.
6
+ *
7
+ * Extends `eslint-plugin-import-x`'s `typescript` flat config.
8
+ */
9
+ export const importXTs = {
10
+ ...importX,
11
+ ...eslintPluginImportX.flatConfigs.typescript,
12
+ settings: {
13
+ 'import-x/resolver': {
14
+ typescript: true,
15
+ node: true
16
+ }
17
+ },
18
+ rules: {
19
+ ...importX.rules,
20
+ 'import-x/no-unresolved': 'error'
21
+ }
22
+ };
@@ -0,0 +1,12 @@
1
+ import { Linter } from 'eslint';
2
+
3
+ export declare const astro: Linter.Config[];
4
+ export declare const base: Linter.Config[];
5
+ export declare const custom: Linter.Config;
6
+ export declare const importX: Linter.Config;
7
+ export declare const importXTs: Linter.Config;
8
+ export declare const json: Linter.Config[];
9
+ export declare const markdown: Linter.Config;
10
+ export declare const reactHooks: Linter.Config;
11
+ export declare const stylistic: Linter.Config;
12
+ export declare const typescript: Linter.Config;
@@ -0,0 +1,10 @@
1
+ export { astro } from './astro.js';
2
+ export { base } from './base.js';
3
+ export { custom } from './custom.js';
4
+ export { importX } from './importX.js';
5
+ export { importXTs } from './importXTs.js';
6
+ export { json } from './json.js';
7
+ export { markdown } from './markdown.js';
8
+ export { reactHooks } from './reactHooks.js';
9
+ export { stylistic } from './stylistic.js';
10
+ export { typescript } from './typescript.js';
@@ -0,0 +1,22 @@
1
+ import eslintPluginJsonc from 'eslint-plugin-jsonc';
2
+
3
+ /**
4
+ * The `ESLint` JSON config. Supports JSON, JSONc an JSON5.
5
+ */
6
+ export const json = [
7
+ { // eslint-plugin-json
8
+ name: 'eslint-plugin-json',
9
+ files: [ '**/*.{json}' ],
10
+ ...eslintPluginJsonc.configs['flat/recommended-with-json']
11
+ },
12
+ { // eslint-plugin-jsonc
13
+ name: 'eslint-plugin-jsonc',
14
+ files: [ '**/*.{jsonc}' ],
15
+ ...eslintPluginJsonc.configs['flat/recommended-with-jsonc']
16
+ },
17
+ { // eslint-plugin-json5
18
+ name: 'eslint-plugin-json5',
19
+ files: [ '**/*.{json5}' ],
20
+ ...eslintPluginJsonc.configs['flat/recommended-with-json5']
21
+ }
22
+ ];
@@ -0,0 +1,10 @@
1
+ import eslintPluginMarkdown from 'eslint-plugin-markdown';
2
+
3
+ /**
4
+ * The `ESLint` markdown config.
5
+ */
6
+ export const markdown = {
7
+ name: 'eslint-plugin-markdown',
8
+ files: [ '**/*.{md}' ],
9
+ ...eslintPluginMarkdown.configs.recommended
10
+ };
@@ -0,0 +1,8 @@
1
+ import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
2
+
3
+ export const reactHooks = {
4
+ name: 'eslint-plugin-react-hooks',
5
+ files: [ '**/*.{jsx,tsx}' ],
6
+ plugins: { 'react-hooks': eslintPluginReactHooks },
7
+ extends: [ 'react-hooks/recommended' ]
8
+ };