@mtth/eslint-plugin 0.1.13 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2021, Matthieu Monsch.
1
+ Copyright (c) 2025, Matthieu Monsch.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of
4
4
  this software and associated documentation files (the "Software"), to deal in
package/README.md CHANGED
@@ -10,50 +10,15 @@ First, install ESLint and this plugin:
10
10
  $ npm i -D eslint @mtth/eslint-plugin
11
11
  ```
12
12
 
13
- Then reference this plugin in `.eslintrc.js`:
14
-
15
- ```js
16
- module.exports = {
17
- plugins: ['@mtth'],
18
- extends: ['plugin:@mtth/typescript'], // One of the configurations below.
19
- // Project-specific configuration...
20
- };
13
+ Then reference this plugin in `.eslint.config.mjs`:
14
+
15
+ ```javascript
16
+ import configs from '@mtth/eslint-plugin';
17
+
18
+ export default config;
21
19
  ```
22
20
 
23
21
  ## Configurations
24
22
 
25
23
  + `typescript`, defaults for a TypeScript project. The corresponding parser is
26
24
  included in the plugin.
27
-
28
- ## Next steps
29
-
30
- This plugin is best used in combination with [this prettier
31
- configuration](https://github.com/mtth/prettier-typescript) and the following
32
- convenience scripts:
33
-
34
- ```json
35
- {
36
- "fix": "npm run pretty && npm run lint -- --fix",
37
- "lint": "eslint '{src,test}/**/*.{ts,tsx}'",
38
- "pretty": "prettier --write '{src,test}/**/*.{ts,tsx}'"
39
- }
40
- ```
41
-
42
- We also recommend enabling pre-commit hooks with `husky` and `lint-staged`. For
43
- example, within your `package.json`:
44
-
45
- ```json
46
- {
47
- "husky": {
48
- "hooks": {
49
- "pre-commit": "lint-staged"
50
- }
51
- },
52
- "lint-staged": {
53
- "*.ts": [
54
- "prettier --write",
55
- "eslint --fix"
56
- ]
57
- }
58
- }
59
- ```
package/index.js CHANGED
@@ -1,124 +1,153 @@
1
- module.exports = {
2
- configs: {
3
- typescript: {
4
- parser: '@typescript-eslint/parser',
5
- plugins: [
6
- '@typescript-eslint',
7
- 'simple-import-sort',
8
- ],
9
- extends: [
10
- 'eslint:recommended',
11
- 'plugin:@typescript-eslint/recommended',
1
+ import eslint from '@eslint/js';
2
+ import stylistic from '@stylistic/eslint-plugin';
3
+ import simpleImportSort from 'eslint-plugin-simple-import-sort';
4
+ import unusedImports from 'eslint-plugin-unused-imports';
5
+ import tseslint from 'typescript-eslint';
6
+
7
+ export default tseslint.config(
8
+ {
9
+ ignores: ['**/*.gen.*'],
10
+ },
11
+ eslint.configs.recommended,
12
+ tseslint.configs.strict,
13
+ tseslint.configs.stylistic,
14
+ {
15
+ plugins: {'@stylistic': stylistic},
16
+ rules: {
17
+ '@stylistic/member-delimiter-style': 'error',
18
+ '@stylistic/quotes': ['error', 'single'],
19
+ '@stylistic/semi': 'error',
20
+ '@stylistic/type-annotation-spacing': 'error',
21
+ },
22
+ },
23
+ {
24
+ plugins: {'simple-import-sort': simpleImportSort},
25
+ rules: {
26
+ 'simple-import-sort/exports': 'error',
27
+ 'simple-import-sort/imports': 'error',
28
+ 'sort-imports': 'off',
29
+ },
30
+ },
31
+ {
32
+ plugins: {'unused-imports': unusedImports},
33
+ rules: {
34
+ '@typescript-eslint/no-unused-vars': 'off',
35
+ 'unused-imports/no-unused-imports': 'error',
36
+ 'unused-imports/no-unused-vars': ['error', {
37
+ argsIgnorePattern: '^_',
38
+ caughtErrors: 'all',
39
+ caughtErrorsIgnorePattern: '^_',
40
+ varsIgnorePattern: '^_',
41
+ }],
42
+ },
43
+ },
44
+ {
45
+ rules: {
46
+ '@typescript-eslint/array-type': ['error', {
47
+ default: 'array',
48
+ readonly: 'generic',
49
+ }],
50
+ '@typescript-eslint/consistent-indexed-object-style': 'off',
51
+ '@typescript-eslint/consistent-type-assertions': ['error', {
52
+ assertionStyle: 'as',
53
+ objectLiteralTypeAssertions: 'never',
54
+ }],
55
+ '@typescript-eslint/consistent-type-definitions': ['error',
56
+ 'interface',
12
57
  ],
13
- rules: {
14
- '@typescript-eslint/array-type': ['error', {
15
- default: 'array',
16
- readonly: 'generic',
17
- }],
18
- '@typescript-eslint/consistent-type-assertions': ['error', {
19
- assertionStyle: 'as',
20
- objectLiteralTypeAssertions: 'never',
21
- }],
22
- '@typescript-eslint/consistent-type-definitions': ['error',
23
- 'interface',
24
- ],
25
- '@typescript-eslint/explicit-function-return-type': 'error',
26
- '@typescript-eslint/member-delimiter-style': 'error',
27
- '@typescript-eslint/no-explicit-any': 'off',
28
- '@typescript-eslint/no-misused-new': 'error',
29
- '@typescript-eslint/no-this-alias': 'error',
30
- '@typescript-eslint/no-unused-vars': ['error', {
31
- argsIgnorePattern: '^_',
32
- caughtErrors: 'all',
33
- caughtErrorsIgnorePattern: '^_',
34
- varsIgnorePattern: '^_',
35
- }],
36
- '@typescript-eslint/no-use-before-define': 'off',
37
- '@typescript-eslint/no-useless-constructor': 'error',
38
- '@typescript-eslint/prefer-function-type': 'error',
39
- '@typescript-eslint/prefer-optional-chain': 'error',
40
- '@typescript-eslint/quotes': ['error', 'single'],
41
- '@typescript-eslint/semi': 'error',
42
- '@typescript-eslint/type-annotation-spacing': 'error',
43
- '@typescript-eslint/unified-signatures': 'error',
44
- 'arrow-parens': 'error',
45
- 'consistent-return': 'error',
46
- 'comma-dangle': ['error', {
47
- 'arrays': 'always-multiline',
48
- 'objects': 'always-multiline',
49
- 'imports': 'always-multiline',
50
- 'exports': 'always-multiline',
51
- 'functions': 'never',
52
- }],
53
- 'curly': 'error',
54
- 'default-case-last': 'error',
55
- 'default-param-last': 'error',
56
- 'dot-location': ['error', 'property'],
57
- 'dot-notation': 'off', // https://234.fyi/1PcbRPGcR
58
- 'eqeqeq': ['error', 'smart'],
59
- 'max-len': ['error', {
60
- ignorePattern: 'eslint-disable',
61
- ignoreTrailingComments: true,
62
- ignoreUrls: true,
63
- }],
64
- 'no-alert': 'error',
65
- 'no-caller': 'error',
66
- 'no-constructor-return': 'error',
67
- 'no-duplicate-imports': 'error',
68
- 'no-else-return': 'error',
69
- 'no-eq-null': 'error',
70
- 'no-eval': 'error',
71
- 'no-extra-bind': 'error',
72
- 'no-extra-label': 'error',
73
- 'no-implicit-globals': 'error',
74
- 'no-implied-eval': 'error',
75
- 'no-label-var': 'error',
76
- 'no-loss-of-precision': 'error',
77
- 'no-multi-spaces': 'error',
78
- 'no-new-wrappers': 'error',
79
- 'no-promise-executor-return': 'error',
80
- 'no-restricted-globals': [
81
- // https://github.com/microsoft/TypeScript/issues/18433
82
- 'error',
83
- 'closed',
84
- 'event',
85
- 'fdescribe',
86
- 'length',
87
- 'location',
88
- 'name',
89
- 'parent',
90
- 'top',
91
- ],
92
- 'no-self-compare': 'error',
93
- 'no-sequences': 'error',
94
- 'no-tabs': 'error',
95
- 'no-throw-literal': 'error',
96
- 'no-trailing-spaces': 'error',
97
- 'no-undef-init': 'error',
98
- 'no-unneeded-ternary': ['error', {defaultAssignment: false}],
99
- 'no-unused-expressions': 'error',
100
- 'no-useless-call': 'error',
101
- 'no-useless-computed-key': 'error',
102
- 'no-useless-rename': 'error',
103
- 'no-var': 'error',
104
- 'no-whitespace-before-property': 'error',
105
- 'object-shorthand': ['error', 'always', {avoidQuotes: true}],
106
- 'prefer-const': 'error',
107
- 'radix': 'error',
108
- 'require-await': 'error',
109
- 'simple-import-sort/exports': 'error',
110
- 'simple-import-sort/imports': 'error',
111
- 'sort-imports': 'off',
112
- },
113
- overrides: [
114
- {
115
- files: ['**/test/**/*.ts'],
116
- rules: {
117
- '@typescript-eslint/explicit-function-return-type': 'off',
118
- '@typescript-eslint/no-non-null-assertion': 'off',
119
- }
120
- },
58
+ '@typescript-eslint/no-dynamic-delete': 'off',
59
+ '@typescript-eslint/explicit-function-return-type': ['error', {
60
+ allowConciseArrowFunctionExpressionsStartingWithVoid: true,
61
+ allowExpressions: true,
62
+ }],
63
+ '@typescript-eslint/no-empty-function': 'off',
64
+ '@typescript-eslint/no-empty-interface': 'off',
65
+ '@typescript-eslint/no-empty-object-type': 'off',
66
+ '@typescript-eslint/no-explicit-any': 'off',
67
+ '@typescript-eslint/no-invalid-void-type': 'off', // Prevents void operator
68
+ '@typescript-eslint/no-misused-new': 'error',
69
+ '@typescript-eslint/no-namespace': 'off',
70
+ '@typescript-eslint/no-non-null-assertion': 'off',
71
+ '@typescript-eslint/no-this-alias': 'off',
72
+ '@typescript-eslint/no-unsafe-function-type': 'off',
73
+ '@typescript-eslint/no-use-before-define': 'off',
74
+ '@typescript-eslint/no-useless-constructor': 'error',
75
+ '@typescript-eslint/prefer-function-type': 'error',
76
+ '@typescript-eslint/prefer-optional-chain': 'off', // Requires typing
77
+ '@typescript-eslint/unified-signatures': 'error',
78
+ 'arrow-parens': 'error',
79
+ 'consistent-return': 'error',
80
+ 'comma-dangle': ['error', {
81
+ 'arrays': 'always-multiline',
82
+ 'objects': 'always-multiline',
83
+ 'imports': 'always-multiline',
84
+ 'exports': 'always-multiline',
85
+ 'functions': 'never',
86
+ }],
87
+ 'curly': 'error',
88
+ 'default-case-last': 'error',
89
+ 'default-param-last': 'error',
90
+ 'dot-location': ['error', 'property'],
91
+ 'dot-notation': 'off', // https://234.fyi/1PcbRPGcR
92
+ 'eqeqeq': ['error', 'smart'],
93
+ 'max-len': ['error', {
94
+ code: 100, // Add padding due to prettier sometimes going over
95
+ comments: 80,
96
+ ignorePattern: 'eslint-disable',
97
+ ignoreTrailingComments: true,
98
+ ignoreUrls: true,
99
+ }],
100
+ 'no-alert': 'error',
101
+ 'no-caller': 'error',
102
+ 'no-constructor-return': 'error',
103
+ 'no-duplicate-imports': 'error',
104
+ 'no-else-return': 'error',
105
+ 'no-eq-null': 'off', // Handled by eqeqeq.
106
+ 'no-eval': 'error',
107
+ 'no-extra-bind': 'error',
108
+ 'no-extra-label': 'error',
109
+ 'no-implicit-globals': 'error',
110
+ 'no-implied-eval': 'error',
111
+ 'no-label-var': 'error',
112
+ 'no-loss-of-precision': 'error',
113
+ 'no-multi-spaces': 'error',
114
+ 'no-new-wrappers': 'error',
115
+ 'no-promise-executor-return': 'error',
116
+ 'no-restricted-globals': [
117
+ // https://github.com/microsoft/TypeScript/issues/18433
118
+ 'error',
119
+ 'closed',
120
+ 'event',
121
+ 'fdescribe',
122
+ 'length',
123
+ 'location',
124
+ 'name',
125
+ 'parent',
126
+ 'top',
121
127
  ],
128
+ 'no-self-compare': 'error',
129
+ 'no-sequences': 'error',
130
+ 'no-tabs': 'error',
131
+ 'no-throw-literal': 'error',
132
+ 'no-trailing-spaces': 'error',
133
+ 'no-undef-init': 'error',
134
+ 'no-unneeded-ternary': ['error', {defaultAssignment: false}],
135
+ 'no-unused-expressions': 'off',
136
+ 'no-useless-call': 'error',
137
+ 'no-useless-computed-key': 'error',
138
+ 'no-useless-rename': 'error',
139
+ 'no-var': 'error',
140
+ 'no-whitespace-before-property': 'error',
141
+ 'object-shorthand': ['error', 'always', {avoidQuotes: true}],
142
+ 'prefer-const': 'error',
143
+ 'radix': 'error',
144
+ 'require-await': 'off',
122
145
  },
123
146
  },
124
- };
147
+ {
148
+ files: ['**/test/**/*.ts'],
149
+ rules: {
150
+ '@typescript-eslint/explicit-function-return-type': 'off',
151
+ }
152
+ },
153
+ );
package/package.json CHANGED
@@ -1,26 +1,28 @@
1
1
  {
2
2
  "name": "@mtth/eslint-plugin",
3
- "version": "0.1.13",
4
- "description": "Common linting configuration",
5
- "homepage": "https://github.com/mtth/eslint-plugin",
3
+ "version": "0.2.0",
4
+ "repository": "github:mtth/sdk.ts",
5
+ "description": "Shared linting config",
6
6
  "keywords": [
7
7
  "eslint"
8
8
  ],
9
- "author": {
10
- "name": "Matthieu Monsch",
11
- "email": "mtth@apache.org"
12
- },
9
+ "author": "Matthieu Monsch <mtth@apache.org>",
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "exports": "./index.js",
13
13
  "dependencies": {
14
- "@typescript-eslint/eslint-plugin": "^5.8.1",
15
- "@typescript-eslint/parser": "^5.8.1",
16
- "eslint-plugin-simple-import-sort": "^7.0.0"
14
+ "@eslint/js": "^9.20.0",
15
+ "@stylistic/eslint-plugin": "^3.1.0",
16
+ "@typescript-eslint/parser": "^8.24.0",
17
+ "eslint-plugin-simple-import-sort": "^12.1.1",
18
+ "eslint-plugin-unused-imports": "^4.1.4",
19
+ "typescript-eslint": "^8.24.0"
17
20
  },
18
21
  "peerDependencies": {
19
- "eslint": "^8.5.0"
22
+ "eslint": "^9.15.0"
20
23
  },
21
- "license": "MIT",
22
- "repository": {
23
- "type": "git",
24
- "url": "git://github.com/mtth/eslint-plugin.git"
24
+ "devDependencies": {
25
+ "eslint": "^9.20.1",
26
+ "typescript": "^5.7.3"
25
27
  }
26
- }
28
+ }
@@ -1,77 +0,0 @@
1
- name: CI
2
- on:
3
- push:
4
- branches:
5
- - main
6
- jobs:
7
- tag:
8
- name: Tag commit
9
- runs-on: ubuntu-latest
10
- timeout-minutes: 1
11
- outputs:
12
- tagged: ${{ format(steps.check-tag.outputs.exists == 'false') }}
13
- steps:
14
- - name: Check out
15
- uses: actions/checkout@v2
16
- with:
17
- fetch-depth: 0
18
- - name: Setup Node
19
- uses: actions/setup-node@v2
20
- - name: Extract version
21
- run: |
22
- PACKAGE_VERSION="$(node -p 'require("./package.json").version')"
23
- echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
24
- - name: Check tag exists
25
- uses: mukunku/tag-exists-action@v1.0.0
26
- id: check-tag
27
- with:
28
- tag: v${{ env.PACKAGE_VERSION }}
29
- env:
30
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31
- - name: Create tag
32
- if: steps.check-tag.outputs.exists == 'false'
33
- uses: pkgdeps/git-tag-action@v2
34
- with:
35
- git_commit_sha: ${{ github.sha }}
36
- git_tag_prefix: v
37
- github_repo: ${{ github.repository }}
38
- github_token: ${{ secrets.GITHUB_TOKEN }}
39
- version: ${{ env.PACKAGE_VERSION }}
40
- publish-gh:
41
- name: Publish package to GitHub
42
- runs-on: ubuntu-latest
43
- timeout-minutes: 2
44
- needs: tag
45
- if: needs.tag.outputs.tagged == 'true'
46
- steps:
47
- - name: Check out
48
- uses: actions/checkout@v2
49
- - name: Setup Node
50
- uses: actions/setup-node@v2
51
- with:
52
- registry-url: https://npm.pkg.github.com
53
- - name: Install
54
- run: npm i
55
- - name: Publish to GitHub
56
- run: npm publish
57
- env:
58
- NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59
- publish-npm:
60
- name: Publish package to NPM
61
- runs-on: ubuntu-latest
62
- timeout-minutes: 2
63
- needs: tag
64
- if: needs.tag.outputs.tagged == 'true'
65
- steps:
66
- - name: Check out
67
- uses: actions/checkout@v2
68
- - name: Setup Node
69
- uses: actions/setup-node@v2
70
- with:
71
- registry-url: https://registry.npmjs.org
72
- - name: Install
73
- run: npm i
74
- - name: Publish to NPM
75
- run: npm publish --access=public
76
- env:
77
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}