@australiangreens/eslint-plugin-ag-internal 0.0.1 → 0.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.
@@ -0,0 +1,3 @@
1
+ import { Linter } from 'eslint';
2
+ declare const config: Linter.Config[];
3
+ export default config;
@@ -0,0 +1,41 @@
1
+ import jsEslint from '@eslint/js';
2
+ import importPlugin from 'eslint-plugin-import';
3
+ import { pluginName } from '../util.js';
4
+ const config = [
5
+ jsEslint.configs.recommended,
6
+ {
7
+ name: `${pluginName()}/eslint`,
8
+ rules: {
9
+ // Not enabled in recommended, we prefer to be more specific
10
+ radix: ['error', 'as-needed'],
11
+ // Not enabled in recommended, we treat it as an error
12
+ 'no-plusplus': [
13
+ 'error',
14
+ {
15
+ allowForLoopAfterthoughts: true,
16
+ },
17
+ ],
18
+ },
19
+ },
20
+ importPlugin.flatConfigs.recommended,
21
+ importPlugin.flatConfigs.typescript,
22
+ {
23
+ name: `${pluginName()}/import`,
24
+ rules: {
25
+ // These are not incuded in the recommended config, we treat as errors
26
+ 'import/newline-after-import': 'error',
27
+ 'import/no-unresolved': 'error',
28
+ // These are warnings in recommended, we treat as errors
29
+ 'import/no-named-as-default': 'error',
30
+ 'import/no-named-as-default-member': 'error',
31
+ 'import/no-duplicates': 'error',
32
+ },
33
+ settings: {
34
+ 'import/resolver': {
35
+ typescript: true,
36
+ node: true,
37
+ },
38
+ },
39
+ },
40
+ ];
41
+ export default config;
@@ -0,0 +1,3 @@
1
+ import { Linter } from 'eslint';
2
+ declare const config: Linter.Config[];
3
+ export default config;
@@ -0,0 +1,54 @@
1
+ import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
2
+ import reactPlugin from 'eslint-plugin-react';
3
+ import reactHooksPlugin from 'eslint-plugin-react-hooks';
4
+ import reactRefreshPlugin from 'eslint-plugin-react-refresh';
5
+ import { pluginName } from '../util.js';
6
+ const config = [
7
+ jsxA11yPlugin.flatConfigs.strict,
8
+ {
9
+ name: `${pluginName()}/jsx-a11y`,
10
+ rules: {
11
+ // As of eslint-plugin-jsx-a11y v6 these rules are not enabled (since
12
+ // they would be a breaking change). So lets enable them ourselves while
13
+ // we wait for v7.
14
+ 'jsx-a11y/lang': 'error',
15
+ 'jsx-a11y/no-aria-hidden-on-focusable': 'error',
16
+ // TODO [LIST-981] Except for this one, have 6 errors
17
+ // 'jsx-a11y/prefer-tag-over-role': 'error',
18
+ },
19
+ },
20
+ reactPlugin.configs.flat.recommended,
21
+ reactPlugin.configs.flat['jsx-runtime'],
22
+ {
23
+ name: `${pluginName()}/react`,
24
+ rules: {
25
+ // Enforce destructuring for props instead of the props.foo pattern
26
+ 'react/destructuring-assignment': ['error', 'always'],
27
+ },
28
+ settings: {
29
+ // https://github.com/jsx-eslint/eslint-plugin-react#configuration
30
+ react: {
31
+ version: 'detect',
32
+ },
33
+ },
34
+ },
35
+ // The plugin provides 2 hooks
36
+ reactHooksPlugin.configs['recommended-latest'],
37
+ {
38
+ name: `${pluginName()}/react-hooks`,
39
+ rules: {
40
+ // This is a warning in recommended-latest, we treat as an error
41
+ 'react-hooks/exhaustive-deps': 'error',
42
+ // The remaining rule, 'react-hooks/rules-of-hooks' is already an error
43
+ },
44
+ },
45
+ reactRefreshPlugin.configs.recommended,
46
+ {
47
+ name: `${pluginName()}/react-refresh`,
48
+ rules: {
49
+ // [LIST-974] Disabled for now until we fix the issues it raises
50
+ 'react-refresh/only-export-components': 'off',
51
+ },
52
+ },
53
+ ];
54
+ export default config;
@@ -0,0 +1,3 @@
1
+ import { Linter } from 'eslint';
2
+ declare const config: Linter.Config[];
3
+ export default config;
@@ -0,0 +1,40 @@
1
+ import tsdocPlugin from 'eslint-plugin-tsdoc';
2
+ import { configs as tsEslintConfigs } from 'typescript-eslint';
3
+ import { pluginName } from '../util.js';
4
+ const config = [
5
+ ...tsEslintConfigs.recommended,
6
+ {
7
+ name: `${pluginName()}/typescript-eslint`,
8
+ rules: {
9
+ // Not enabled in recommended
10
+ '@typescript-eslint/no-use-before-define': [
11
+ 'error',
12
+ {
13
+ variables: true,
14
+ functions: false,
15
+ classes: false,
16
+ enums: true,
17
+ typedefs: true,
18
+ },
19
+ ],
20
+ // It can be useful to effectively re-export the props of another
21
+ // component for some wrappers. E.g. SaladBarProviderProps is same as
22
+ // SnackbarProps
23
+ '@typescript-eslint/no-empty-interface': 'off',
24
+ },
25
+ },
26
+ {
27
+ // Provides single rule for validating that TypeScript doc comments conform
28
+ // to the TSDoc specification
29
+ name: `${pluginName()}/tsdoc`,
30
+ // At time of writing tsdoc didn't have an exported flat config, but we can
31
+ // import it as per https://github.com/microsoft/tsdoc/issues/374
32
+ plugins: {
33
+ tsdoc: tsdocPlugin,
34
+ },
35
+ rules: {
36
+ 'tsdoc/syntax': 'error',
37
+ },
38
+ },
39
+ ];
40
+ export default config;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- declare const plugin: {
1
+ import { Linter } from 'eslint';
2
+ type ConfigName = 'recommended' | 'recommendedJsOnly' | 'recommendedReact' | 'recommendedReactJsOnly';
3
+ type Plugin = {
2
4
  meta: {
3
- name: any;
4
- version: any;
5
- };
6
- configs: {
7
- recommended: import("eslint/lib/types").Linter.Config<import("eslint/lib/types").Linter.RulesRecord>[];
5
+ name: string;
6
+ version: string;
8
7
  };
8
+ configs: Record<ConfigName, Linter.Config[]>;
9
9
  };
10
+ declare const plugin: Plugin;
10
11
  export default plugin;
package/dist/index.js CHANGED
@@ -1,75 +1,24 @@
1
- import jsEslint from '@eslint/js';
2
1
  import eslintConfigPrettier from 'eslint-config-prettier/flat';
3
- import importPlugin from 'eslint-plugin-import';
4
2
  import { defineConfig } from 'eslint/config';
5
- import fs from 'fs';
6
- import tsEslint from 'typescript-eslint';
7
- // '../package.json' be correct both in src/ and dist/
8
- const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
3
+ import javascriptConfig from './configs/javascript.js';
4
+ import reactConfig from './configs/react.js';
5
+ import typescriptConfig from './configs/typescript.js';
6
+ import { pluginScopedName, pluginVersion } from './util.js';
7
+ const buildConfig = (...configs) => defineConfig([...configs, eslintConfigPrettier]);
9
8
  const plugin = {
10
9
  meta: {
11
- name: pkg.name,
12
- version: pkg.version,
10
+ name: pluginScopedName(),
11
+ version: pluginVersion(),
13
12
  },
14
13
  configs: {
15
- recommended: defineConfig([
16
- {
17
- name: 'js',
18
- extends: [jsEslint.configs.recommended],
19
- rules: {
20
- // Not enabled in recommended, we prefer to be more specific
21
- radix: ['error', 'as-needed'],
22
- // Not enabled in recommended, we treat it as an error
23
- 'no-plusplus': [
24
- 'error',
25
- {
26
- allowForLoopAfterthoughts: true,
27
- },
28
- ],
29
- },
30
- },
31
- {
32
- name: 'ts',
33
- // It exports a named config object, but that causes errors
34
- // eslint-disable-next-line import/no-named-as-default-member
35
- extends: [tsEslint.configs.recommended],
36
- rules: {
37
- // Not enabled in recommended
38
- '@typescript-eslint/no-use-before-define': [
39
- 'error',
40
- {
41
- variables: true,
42
- functions: false,
43
- classes: false,
44
- enums: true,
45
- typedefs: true,
46
- },
47
- ],
48
- // It can be useful to effectively re-export the props of another
49
- // component for some wrappers. E.g. SaladBarProviderProps is same as
50
- // SnackbarProps
51
- '@typescript-eslint/no-empty-interface': 'off',
52
- },
53
- },
54
- {
55
- // Linting of ES6+ import/export syntax
56
- name: 'import',
57
- extends: [importPlugin.flatConfigs.recommended, importPlugin.flatConfigs.typescript],
58
- rules: {
59
- 'import/newline-after-import': 'error',
60
- 'import/no-unresolved': 'error',
61
- },
62
- settings: {
63
- 'import/resolver': {
64
- typescript: true,
65
- node: true,
66
- },
67
- },
68
- },
69
- // Turns off all rules that are unnecessary or might conflict with Prettier,
70
- // which we use for formatting.
71
- eslintConfigPrettier,
72
- ]),
14
+ /** All our rules for a typescript app, typically backend*/
15
+ recommended: buildConfig(javascriptConfig, typescriptConfig),
16
+ /** Same as recommended but without any typescript rules */
17
+ recommendedJsOnly: buildConfig(javascriptConfig),
18
+ /** Same as recommended but with the addition of react related rules */
19
+ recommendedReact: buildConfig(javascriptConfig, typescriptConfig, reactConfig),
20
+ /** recommendedReact but without any typescript rules */
21
+ recommendedReactJsOnly: buildConfig(javascriptConfig, reactConfig),
73
22
  },
74
23
  };
75
24
  export default plugin;
package/dist/util.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare function pluginScopedName(): any;
2
+ export declare function pluginName(): any;
3
+ export declare function pluginVersion(): any;
package/dist/util.js ADDED
@@ -0,0 +1,15 @@
1
+ import fs from 'fs';
2
+ /**
3
+ * Use to get name and version from package.json
4
+ * The relative path works from both src/ and dist/
5
+ */
6
+ const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
7
+ export function pluginScopedName() {
8
+ return pkg.name;
9
+ }
10
+ export function pluginName() {
11
+ return pkg.name.replace(/^@.*\//, '');
12
+ }
13
+ export function pluginVersion() {
14
+ return pkg.version;
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@australiangreens/eslint-plugin-ag-internal",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/australiangreens/eslint-plugin-ag-internal#readme",
@@ -22,24 +22,34 @@
22
22
  },
23
23
  "types": "./dist/index.d.ts",
24
24
  "scripts": {
25
- "eslint": "eslint --max-warnings 0",
25
+ "lint": "eslint --max-warnings 0",
26
26
  "build": "tsc --build",
27
+ "clean": "rimraf dist",
28
+ "build:clean": "pnpm clean && pnpm build",
27
29
  "build:watch": "tsc --build --watch",
28
- "clean": "rm -rf dist",
29
30
  "test": "echo \"Error: no test specified\" && exit 1"
30
31
  },
31
- "devDependencies": {
32
+ "dependencies": {
32
33
  "@eslint/js": "^9.36.0",
33
- "@types/node": "^24.5.2",
34
- "eslint": "^9.26.0",
35
34
  "eslint-config-prettier": "^10.1.8",
36
35
  "eslint-import-resolver-typescript": "^4.4.4",
37
36
  "eslint-plugin-eslint-plugin": "^7.0.0",
38
37
  "eslint-plugin-import": "^2.32.0",
39
- "globals": "^16.4.0",
40
- "typescript": "^5.9.2",
38
+ "eslint-plugin-jsx-a11y": "^6.10.2",
39
+ "eslint-plugin-react": "^7.37.5",
40
+ "eslint-plugin-react-hooks": "^5.2.0",
41
+ "eslint-plugin-react-refresh": "^0.4.21",
42
+ "eslint-plugin-tsdoc": "^0.4.0",
41
43
  "typescript-eslint": "^8.44.1"
42
44
  },
45
+ "devDependencies": {
46
+ "@types/eslint-plugin-jsx-a11y": "^6.10.0",
47
+ "@types/node": "^24.5.2",
48
+ "eslint": "^9.36.0",
49
+ "globals": "^16.4.0",
50
+ "rimraf": "^6.0.1",
51
+ "typescript": "^5.9.2"
52
+ },
43
53
  "peerDependencies": {
44
54
  "eslint": ">=9.26.0"
45
55
  },