@nextcloud/eslint-config 8.2.0 → 8.3.0-beta.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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [v8.3.0-beta.0](https://github.com/nextcloud/eslint-config/tree/v8.3.0-beta.0) (2023-05-12)
4
+
5
+ [Full Changelog](https://github.com/nextcloud/eslint-config/compare/v8.2.1...v8.3.0-beta.0)
6
+
7
+ **Merged pull requests:**
8
+ - Typescript 5 support
9
+ - Various dependencies upgrades
10
+
11
+ ## [v8.2.1](https://github.com/nextcloud/eslint-config/tree/v8.2.1) (2023-01-30)
12
+
13
+ [Full Changelog](https://github.com/nextcloud/eslint-config/compare/v8.2.0...v8.2.1)
14
+
15
+ **Fixed:**
16
+ - Fix resolving packages that use the package `exports` feature by @susnux in https://github.com/nextcloud/eslint-config/pull/452
17
+
18
+ **Merged pull requests:**
19
+ - Various dependencies upgrades
20
+
3
21
  ## [v8.2.0](https://github.com/nextcloud/eslint-config/tree/v8.2.0) (2023-01-11)
4
22
 
5
23
  [Full Changelog](https://github.com/nextcloud/eslint-config/compare/v8.1.5...v8.2.0)
@@ -24,8 +42,7 @@
24
42
 
25
43
  [Full Changelog](https://github.com/nextcloud/eslint-config/compare/v8.1.3...v8.1.4)
26
44
 
27
- **Fixed bugs:**
28
-
45
+ **Fixed:**
29
46
  - Fix eslint-plugin-n conflict [\#421](https://github.com/nextcloud/eslint-config/pull/421) ([skjnldsv](https://github.com/skjnldsv))
30
47
 
31
48
  ## [v8.1.3](https://github.com/nextcloud/eslint-config/tree/v8.1.3) (2022-11-04)
@@ -49,7 +66,6 @@
49
66
  [Full Changelog](https://github.com/nextcloud/eslint-config/compare/v8.0.0...v8.1.2)
50
67
 
51
68
  **Dependency updates:**
52
-
53
69
  - Use [`eslint-plugin-n`](https://www.npmjs.com/package/eslint-plugin-n) instead of [`eslint-plugin-node`](https://www.npmjs.com/package/eslint-plugin-node)
54
70
 
55
71
  ## [v8.0.0](https://github.com/nextcloud/eslint-config/tree/v8.0.0) (2022-04-20)
@@ -57,11 +73,9 @@
57
73
  [Full Changelog](https://github.com/nextcloud/eslint-config/compare/v7.0.2...v8.0.0)
58
74
 
59
75
  **Breaking:**
60
-
61
76
  - Require file extensions on import [\#292](https://github.com/nextcloud/eslint-config/pull/292) ([Pytal](https://github.com/Pytal))
62
77
 
63
78
  **Dependency updates:**
64
-
65
79
  - Bump eslint from 8.7.0 to 8.8.0 [\#282](https://github.com/nextcloud/eslint-config/pull/282) ([dependabot[bot]](https://github.com/apps/dependabot))
66
80
  - Bump eslint from 8.8.0 to 8.9.0 [\#296](https://github.com/nextcloud/eslint-config/pull/296) ([dependabot[bot]](https://github.com/apps/dependabot))
67
81
 
@@ -70,11 +84,9 @@
70
84
  [Full Changelog](https://github.com/nextcloud/eslint-config/compare/v7.0.1...v7.0.2)
71
85
 
72
86
  **Fixed:**
73
-
74
87
  - Fix usual same-line vue attribute behaviour [\#272](https://github.com/nextcloud/eslint-config/pull/272) ([skjnldsv](https://github.com/skjnldsv))
75
88
 
76
89
  **Dependency updates:**
77
-
78
90
  - Bump eslint from 8.6.0 to 8.7.0 [\#271](https://github.com/nextcloud/eslint-config/pull/271) ([dependabot[bot]](https://github.com/apps/dependabot))
79
91
  - Bump @babel/core from 7.16.7 to 7.16.10 [\#273](https://github.com/nextcloud/eslint-config/pull/273) ([dependabot[bot]](https://github.com/apps/dependabot))
80
92
 
@@ -83,11 +95,9 @@
83
95
  [Full Changelog](https://github.com/nextcloud/eslint-config/compare/v7.0.0...v7.0.1)
84
96
 
85
97
  **Fixed bugs:**
86
-
87
98
  - Allow component names to be single-word [\#270](https://github.com/nextcloud/eslint-config/pull/270) ([skjnldsv](https://github.com/skjnldsv))
88
99
 
89
100
  **Dependency updates:**
90
-
91
101
  - Bump webpack from 5.65.0 to 5.66.0 [\#269](https://github.com/nextcloud/eslint-config/pull/269) ([dependabot[bot]](https://github.com/apps/dependabot))
92
102
  - Bump eslint-plugin-vue from 8.2.0 to 8.3.0 [\#268](https://github.com/nextcloud/eslint-config/pull/268) ([dependabot[bot]](https://github.com/apps/dependabot))
93
103
 
@@ -96,7 +106,6 @@
96
106
  [Full Changelog](https://github.com/nextcloud/eslint-config/compare/v6.1.2...v7.0.0)
97
107
 
98
108
  **Merged pull requests:**
99
-
100
109
  - Eslint 8 [\#266](https://github.com/nextcloud/eslint-config/pull/266) ([skjnldsv](https://github.com/skjnldsv))
101
110
  - v7.0.0 [\#267](https://github.com/nextcloud/eslint-config/pull/267) ([skjnldsv](https://github.com/skjnldsv))
102
111
  ## [v6.1.2](https://github.com/nextcloud/eslint-config/tree/v6.1.2) (2021-12-20)
@@ -104,7 +113,6 @@
104
113
  [Full Changelog](https://github.com/nextcloud/eslint-config/compare/v6.1.1...v6.1.2)
105
114
 
106
115
  **Fixes:**
107
-
108
116
  - Fix vue custom event name casing [\#249](https://github.com/nextcloud/eslint-config/pull/249) ([Pytal](https://github.com/Pytal))
109
117
 
110
118
  ## [v6.1.1](https://github.com/nextcloud/eslint-config/tree/v6.1.1) (2021-12-02)
@@ -112,7 +120,6 @@
112
120
  [Full Changelog](https://github.com/nextcloud/eslint-config/compare/v6.1.0...v6.1.1)
113
121
 
114
122
  **Fixes:**
115
-
116
123
  - Disable tag rule [\#248](https://github.com/nextcloud/eslint-config/pull/248) ([skjnldsv](https://github.com/skjnldsv))
117
124
 
118
125
  ## [v6.1.0](https://github.com/nextcloud/eslint-config/tree/v6.1.0) (2021-08-11)
@@ -120,7 +127,6 @@
120
127
  [Full Changelog](https://github.com/nextcloud/eslint-config/compare/v6.0.1...v6.1.0)
121
128
 
122
129
  **Fix dependency:**
123
-
124
130
  - Remove undesired eslint-webpack-plugin ([skjnldsv](https://github.com/skjnldsv))
125
131
 
126
132
  ## [v6.0.1](https://github.com/nextcloud/eslint-config/tree/v6.0.1) (2021-08-11)
@@ -128,7 +134,6 @@
128
134
  [Full Changelog](https://github.com/nextcloud/eslint-config/compare/v6.0.0...v6.0.1)
129
135
 
130
136
  **Merged pull requests:**
131
-
132
137
  - Fix license header tags spacing [\#180](https://github.com/nextcloud/eslint-config/pull/180) ([skjnldsv](https://github.com/skjnldsv))
133
138
 
134
139
  ## [v6.0.0](https://github.com/nextcloud/eslint-config/tree/v6.0.0)
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ## @nextcloud/eslint-config
2
2
 
3
3
  [![npm last version](https://img.shields.io/npm/v/@nextcloud/eslint-config.svg?style=flat-square)](https://www.npmjs.com/package/@nextcloud/eslint-config)
4
- [![Lint status](https://img.shields.io/github/actions/workflow/status/nextcloud/eslint-config/lint.yml?label=lint&style=flat-square)](https://github.com/nextcloud/eslint-config/actions/workflows/lint.yml)
4
+ [![Lint status](https://img.shields.io/github/actions/workflow/status/nextcloud/eslint-config/lint-eslint.yml?label=lint&style=flat-square)](https://github.com/nextcloud/eslint-config/actions/workflows/lint.yml)
5
5
  [![Dependabot status](https://img.shields.io/badge/Dependabot-enabled-brightgreen.svg?longCache=true&style=flat-square&logo=dependabot)](https://dependabot.com)
6
6
 
7
7
 
package/index.js CHANGED
@@ -29,6 +29,9 @@ module.exports = {
29
29
  paths: ['src'],
30
30
  extensions: ['.js', '.vue'],
31
31
  },
32
+ exports: {
33
+ conditions: ['import'],
34
+ },
32
35
  },
33
36
  jsdoc: {
34
37
  tagNamePreference: {
@@ -118,7 +121,7 @@ module.exports = {
118
121
  },
119
122
  overrides: [
120
123
  {
121
- files: ['**/*.ts'],
124
+ files: ['**/*.ts', '**/*.tsx'],
122
125
  extends: [
123
126
  '@vue/eslint-config-typescript/recommended',
124
127
  'plugin:import/typescript',
@@ -145,7 +148,7 @@ module.exports = {
145
148
  'import/resolver': {
146
149
  node: {
147
150
  paths: ['src'],
148
- extensions: ['.js', '.ts', '.vue'],
151
+ extensions: ['.(m|c)?js', '.ts', '.tsx', '.vue'],
149
152
  },
150
153
  },
151
154
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextcloud/eslint-config",
3
- "version": "8.2.0",
3
+ "version": "8.3.0-beta.0",
4
4
  "description": "Eslint shared config for nextcloud vue.js apps",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -9,7 +9,8 @@
9
9
  },
10
10
  "scripts": {
11
11
  "lint": "eslint -c index.js *.js",
12
- "lint:fix": "eslint -c index.js --fix *.js"
12
+ "lint:fix": "eslint -c index.js --fix *.js",
13
+ "test": "jest"
13
14
  },
14
15
  "peerDependencies": {
15
16
  "@babel/core": "^7.13.10",
@@ -18,27 +19,32 @@
18
19
  "@vue/eslint-config-typescript": "^11.0.2",
19
20
  "eslint": "^8.27.0",
20
21
  "eslint-config-standard": "^17.0.0",
22
+ "eslint-import-resolver-exports": "^1.0.0-beta.4",
21
23
  "eslint-plugin-import": "^2.26.0",
22
- "eslint-plugin-jsdoc": "^39.6.2",
24
+ "eslint-plugin-jsdoc": "^43.0.3",
23
25
  "eslint-plugin-n": "^15.5.1",
24
26
  "eslint-plugin-promise": "^6.1.1",
25
27
  "eslint-plugin-vue": "^9.7.0",
26
- "typescript": "^4.9.4",
28
+ "typescript": "^5.0.2",
27
29
  "webpack": "^5.4.0"
28
30
  },
29
31
  "devDependencies": {
30
32
  "@babel/core": "^7.13.10",
31
33
  "@babel/eslint-parser": "^7.16.5",
32
34
  "@nextcloud/eslint-plugin": "^2.0.0",
35
+ "@types/jest": "^29.4.0",
33
36
  "@vue/eslint-config-typescript": "^11.0.2",
34
37
  "eslint": "^8.27.0",
35
38
  "eslint-config-standard": "^17.0.0",
39
+ "eslint-import-resolver-exports": "^1.0.0-beta.4",
36
40
  "eslint-plugin-import": "^2.26.0",
37
- "eslint-plugin-jsdoc": "^39.6.2",
41
+ "eslint-plugin-jsdoc": "^43.0.3",
38
42
  "eslint-plugin-n": "^15.5.1",
39
43
  "eslint-plugin-promise": "^6.1.1",
40
44
  "eslint-plugin-vue": "^9.7.0",
41
- "typescript": "^4.9.4",
45
+ "jest": "^29.4.1",
46
+ "ts-jest": "^29.0.5",
47
+ "typescript": "^5.0.2",
42
48
  "webpack": "^5.4.0"
43
49
  },
44
50
  "keywords": [
@@ -57,5 +63,12 @@
57
63
  "engines": {
58
64
  "node": "^16.0.0",
59
65
  "npm": "^7.0.0 || ^8.0.0"
66
+ },
67
+ "jest": {
68
+ "preset": "ts-jest",
69
+ "testEnvironment": "node",
70
+ "setupFilesAfterEnv": [
71
+ "./tests/setup-jest.ts"
72
+ ]
60
73
  }
61
74
  }
@@ -0,0 +1,31 @@
1
+ import { ESLint } from "eslint"
2
+ import type { Linter } from "eslint"
3
+ import * as path from 'path'
4
+ import * as eslintConfig from '../index.js'
5
+
6
+
7
+ const eslint = new ESLint({
8
+ baseConfig: eslintConfig as unknown as Linter.Config<Linter.RulesRecord>
9
+ })
10
+
11
+ const lintFile = async (file) => {
12
+ const real = path.resolve(path.join(__dirname, file))
13
+ return await eslint.lintFiles(real)
14
+ }
15
+
16
+ test('some basic issues should fail', async () => {
17
+ const results = await lintFile('fixtures/example-fail.js')
18
+ expect(results).toHaveIssueCount(3)
19
+ expect(results).toHaveIssue('spaced-comment')
20
+ expect(results).toHaveIssue({ ruleId: 'no-console', line: 3 })
21
+ })
22
+
23
+ test('TSX is linted', async () => {
24
+ const ignored = await eslint.isPathIgnored('./fixtures/some.tsx')
25
+ expect(ignored).toBe(false)
26
+
27
+ const results = await lintFile('fixtures/some.tsx')
28
+ expect(results).toHaveIssue({ruleId: 'jsdoc/check-tag-names', line: 5})
29
+ expect(results).toHaveIssue({ruleId: '@typescript-eslint/no-unused-vars', line: 7})
30
+ expect(results).toHaveIssueCount(2)
31
+ })
@@ -0,0 +1,11 @@
1
+ export { }
2
+
3
+ declare global {
4
+ namespace jest {
5
+ interface Matchers<R> {
6
+ toPass(): R;
7
+ toHaveIssueCount(n: number): R;
8
+ toHaveIssue(issue: string | {ruleId: string, line?: number}): R;
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,3 @@
1
+ //should fail because of missing space on this comment
2
+ // and usage of `console` and using a semicolon
3
+ console.log('some');
@@ -0,0 +1,7 @@
1
+ // TSX
2
+
3
+ /**
4
+ * @notExported <- should work
5
+ * @aaabbbcccddd <- should fail
6
+ */
7
+ const foo = '' // <- should fail, as unused
@@ -0,0 +1,128 @@
1
+ import { ESLint, Linter } from "eslint"
2
+
3
+ /**
4
+ * Add some custom matchers for ESLint to jest
5
+ */
6
+ expect.extend({
7
+ toPass: assertLintingPassed,
8
+ toHaveIssueCount: assertHavingNIssues,
9
+ toHaveIssue: assertHavingIssue
10
+ })
11
+
12
+ /**
13
+ * Check if linting a file did not throw any errors or warnings
14
+ *
15
+ * @param received Lint result
16
+ */
17
+ function hasNoIssues(received: ESLint.LintResult) {
18
+ // dirty type check
19
+ if (received?.errorCount === undefined) throw new Error('Expected ESLintResult')
20
+
21
+ return received.errorCount === 0 && received.warningCount === 0
22
+ }
23
+
24
+ /**
25
+ * Check if linting of multiple fils
26
+ *
27
+ * @param received
28
+ * @returns {}
29
+ */
30
+ function assertLintingPassed(received: ESLint.LintResult | ESLint.LintResult[]) {
31
+ // allow single ESLintResult
32
+ if (!Array.isArray(received)) {
33
+ received = [received]
34
+ }
35
+
36
+ const errors = [] as {file: string, errors: Linter.LintMessage[]}[]
37
+ const pass = received.every((result) => {
38
+ // save issues
39
+ errors.push({file: result.filePath, errors: result.messages})
40
+ return hasNoIssues(result)
41
+ })
42
+
43
+ return {
44
+ pass,
45
+ message: () => {
46
+ if (pass) {
47
+ return 'Expected file to not pass eslint, but got no issues'
48
+ } else {
49
+ const errorMessages = errors.map((m) =>
50
+ `file: ${m.file}\n` + m.errors.map((e) => 'line: ' + e.line + ': ' + (e.ruleId || e.message))
51
+ )
52
+ return 'Expected file to pass eslint, got issues:\n' + errorMessages.join('\n')
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Count the total amount of issues
60
+ *
61
+ * @param received lint result
62
+ * @returns total amount of issues
63
+ */
64
+ function countIssues(received: ESLint.LintResult) {
65
+ return received.errorCount + received.warningCount
66
+ }
67
+
68
+ /**
69
+ * Check if exactly the same number of issues is reported
70
+ *
71
+ * @param received the lint result
72
+ * @param expected number of expected issues
73
+ * @returns jest matcher result
74
+ */
75
+ function assertHavingNIssues(received: ESLint.LintResult | ESLint.LintResult[], expected: number) {
76
+ if (!(typeof expected === 'number')) throw new Error('Expected a number as expected value')
77
+
78
+ if (!Array.isArray(received)) {
79
+ received = [received]
80
+ }
81
+
82
+ const issues = received.map(countIssues).reduce((p, c) => p + c)
83
+ const pass = issues === expected
84
+
85
+ return {
86
+ pass,
87
+ message: () => pass ? `Expected not to find exactly ${expected} issues.` : `Expected ${expected} issues, found ${issues}`
88
+ }
89
+ }
90
+
91
+ /**
92
+ * Check if result contains the expected issue
93
+ *
94
+ * @param received the lint result
95
+ * @param issue the expected issue
96
+ * @returns jest matcher result
97
+ */
98
+ function assertHavingIssue(received: ESLint.LintResult | ESLint.LintResult[], issue: string | {ruleId: string, line?: number}) {
99
+ if (!Array.isArray(received)) {
100
+ received = [received]
101
+ }
102
+
103
+ // Should not pass
104
+ if (assertLintingPassed(received).pass) {
105
+ return {
106
+ pass: false,
107
+ message: () => 'Expected issue, but no linting issues found.'
108
+ }
109
+ }
110
+
111
+ const name = typeof issue === 'string' ? issue : issue.ruleId
112
+ const result = received.some((result) => {
113
+ return result.messages.some((message) => {
114
+ // ensure name matches
115
+ if (message.ruleId !== name) return false
116
+ // if line is requested ignore not matching ones
117
+ if (typeof issue === 'object' && issue.line !== undefined && issue.line !== message.line) return false
118
+ // otherwise matched
119
+ return true
120
+ })
121
+ });
122
+
123
+ const onLine = typeof issue === 'string' ? '' : ` on line ${issue.line}`
124
+ return {
125
+ pass: result,
126
+ message: () => result ? `Unexpected error '${name}'${onLine} found.` : `Expected error '${name}'${onLine} not found.`
127
+ }
128
+ }