@swissgeo/config-eslint 1.0.0-beta.2 → 1.0.0-beta.3

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,15 @@
1
+ import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint';
2
+ /**
3
+ * Generates a set of ESLint rules for Cypress tests. The root directory of the Cypress tests can be
4
+ * specified (the default value is 'tests/cypress/').
5
+ *
6
+ * @param cypressRootDir The root directory of the Cypress tests.
7
+ * @returns The set of ESLint rules for Cypress tests.
8
+ */
9
+ export declare function cypressConfig(cypressRootDir?: string): FlatConfig.ConfigArray;
10
+ export declare const vueConfig: FlatConfig.ConfigArray;
11
+ export declare const unitTestsConfig: FlatConfig.ConfigArray;
12
+ export declare const markdownConfig: FlatConfig.ConfigArray;
13
+ export declare const jsConfig: FlatConfig.ConfigArray;
14
+ declare const defaultConfig: FlatConfig.ConfigArray;
15
+ export default defaultConfig;
package/dist/index.js ADDED
@@ -0,0 +1,211 @@
1
+ import jsESLint from '@eslint/js';
2
+ import markdown from '@eslint/markdown';
3
+ import skipFormatting from '@vue/eslint-config-prettier/skip-formatting';
4
+ import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript';
5
+ import pluginChaiFriendly from 'eslint-plugin-chai-friendly';
6
+ import pluginCypress from 'eslint-plugin-cypress/flat';
7
+ import mocha from 'eslint-plugin-mocha';
8
+ import perfectionist from 'eslint-plugin-perfectionist';
9
+ import pluginVue from 'eslint-plugin-vue';
10
+ import globals from 'globals';
11
+ import tsESLint, { plugin as tsESLintPlugin } from 'typescript-eslint';
12
+ const noUnusedVarsRules = {
13
+ 'no-unused-vars': [
14
+ 'error',
15
+ {
16
+ argsIgnorePattern: '^_',
17
+ caughtErrorsIgnorePattern: '^_',
18
+ destructuredArrayIgnorePattern: '^_',
19
+ },
20
+ ],
21
+ '@typescript-eslint/no-unused-vars': [
22
+ 'error',
23
+ {
24
+ argsIgnorePattern: '^_',
25
+ caughtErrorsIgnorePattern: '^_',
26
+ destructuredArrayIgnorePattern: '^_',
27
+ },
28
+ ],
29
+ };
30
+ const standardTSRules = {
31
+ 'no-unused-vars': 'off',
32
+ '@typescript-eslint/no-unused-vars': [
33
+ 'error',
34
+ {
35
+ // as we are adding dispatcher reference in all our store action, but won't be using
36
+ // them directly in the action, we must ignore these unused variables too
37
+ argsIgnorePattern: '^(_|dispatcher)',
38
+ caughtErrorsIgnorePattern: '^_',
39
+ destructuredArrayIgnorePattern: '^_',
40
+ },
41
+ ],
42
+ '@typescript-eslint/consistent-type-exports': 'error',
43
+ '@typescript-eslint/no-import-type-side-effects': 'error',
44
+ };
45
+ const chaiFriendlyRules = {
46
+ plugins: {
47
+ 'chai-friendly': pluginChaiFriendly,
48
+ },
49
+ rules: {
50
+ 'no-console': 'off',
51
+ 'no-prototype-builtins': 'off',
52
+ // see https://github.com/ihordiachenko/eslint-plugin-chai-friendly?tab=readme-ov-file#usage
53
+ 'no-unused-expressions': 'off', // disable original rule for JS
54
+ '@typescript-eslint/no-unused-expressions': 'off', // disable original rule for TS
55
+ 'chai-friendly/no-unused-expressions': 'error',
56
+ ...noUnusedVarsRules,
57
+ },
58
+ };
59
+ /**
60
+ * Generates a set of ESLint rules for Cypress tests. The root directory of the Cypress tests can be
61
+ * specified (the default value is 'tests/cypress/').
62
+ *
63
+ * @param cypressRootDir The root directory of the Cypress tests.
64
+ * @returns The set of ESLint rules for Cypress tests.
65
+ */
66
+ export function cypressConfig(cypressRootDir = 'tests/cypress/') {
67
+ return tsESLint.config([
68
+ {
69
+ files: [`${cypressRootDir}**/*.ts`, `${cypressRootDir}**/*.js`],
70
+ languageOptions: {
71
+ parserOptions: {
72
+ projectService: true,
73
+ tsconfigRootDir: import.meta.dirname,
74
+ },
75
+ },
76
+ rules: standardTSRules,
77
+ ...pluginCypress.configs.recommended,
78
+ ...chaiFriendlyRules,
79
+ },
80
+ ]);
81
+ }
82
+ const allIgnores = [
83
+ '.gitignore',
84
+ '**/node_modules',
85
+ '**/.github',
86
+ '**/dist',
87
+ 'tsconfig.json',
88
+ '**/*.md',
89
+ '**/eslint.config.mts',
90
+ ];
91
+ export const vueConfig = defineConfigWithVueTs(pluginVue.configs['flat/essential'], vueTsConfigs.recommendedTypeCheckedOnly, {
92
+ files: ['**/*.vue'],
93
+ plugins: {
94
+ '@typescript-eslint': tsESLintPlugin,
95
+ perfectionist,
96
+ },
97
+ rules: {
98
+ 'vue/html-indent': ['error', 4],
99
+ // TODO: switch to 'error' (or remove this line) after complete TS migration
100
+ 'vue/block-lang': 'off',
101
+ 'perfectionist/sort-imports': [
102
+ 'error',
103
+ { type: 'alphabetical', internalPattern: ['^@/.*'] },
104
+ ],
105
+ // Enforce consistent brace style for all control statements
106
+ curly: ['error', 'all'],
107
+ // Enforce opening brace on same line and closing brace on new line
108
+ 'brace-style': ['error', '1tbs', { allowSingleLine: false }],
109
+ ...noUnusedVarsRules,
110
+ },
111
+ });
112
+ export const unitTestsConfig = [
113
+ {
114
+ files: ['**/*.spec.{js,ts}', 'scripts/**.{js,ts}'],
115
+ ...chaiFriendlyRules,
116
+ },
117
+ ];
118
+ export const markdownConfig = [
119
+ {
120
+ files: ['**/*.md'],
121
+ plugins: {
122
+ markdown: markdown,
123
+ },
124
+ processor: 'markdown/markdown',
125
+ rules: {
126
+ 'no-irregular-whitespace': 'off',
127
+ 'no-undef': 'off',
128
+ },
129
+ },
130
+ ];
131
+ export const jsConfig = [
132
+ jsESLint.configs.recommended,
133
+ {
134
+ ignores: allIgnores,
135
+ },
136
+ {
137
+ files: ['**/*.js', '**/*.jsx'],
138
+ // no need to check our snippets
139
+ ignores: ['**/*.md'],
140
+ plugins: {
141
+ mocha,
142
+ 'chai-friendly': pluginChaiFriendly,
143
+ perfectionist,
144
+ '@typescript-eslint': tsESLintPlugin,
145
+ },
146
+ languageOptions: {
147
+ ecmaVersion: 'latest',
148
+ globals: {
149
+ ...globals.browser,
150
+ ...globals.vitest,
151
+ ...globals.node,
152
+ defineModel: 'readonly',
153
+ __APP_VERSION__: true,
154
+ __VITE_ENVIRONMENT__: true,
155
+ __CESIUM_STATIC_PATH__: true,
156
+ __IS_TESTING_WITH_CYPRESS__: true,
157
+ },
158
+ sourceType: 'module',
159
+ },
160
+ rules: {
161
+ eqeqeq: ['error', 'always'],
162
+ 'mocha/no-exclusive-tests': 'error',
163
+ 'no-console': 'error',
164
+ 'no-var': 'error',
165
+ 'perfectionist/sort-imports': [
166
+ 'error',
167
+ { type: 'alphabetical', internalPattern: ['^@/.*'] },
168
+ ],
169
+ // Enforce consistent brace style for all control statements
170
+ curly: ['error', 'all'],
171
+ // Enforce opening brace on same line and closing brace on new line
172
+ 'brace-style': ['error', '1tbs', { allowSingleLine: false }],
173
+ ...noUnusedVarsRules,
174
+ },
175
+ },
176
+ ...markdownConfig,
177
+ ...unitTestsConfig,
178
+ ...vueConfig,
179
+ // skip the formatting in the linting process
180
+ skipFormatting,
181
+ ];
182
+ const defaultConfig = tsESLint.config(...jsConfig, tsESLint.configs.recommended, ...markdownConfig, ...vueConfig, {
183
+ ignores: allIgnores,
184
+ }, {
185
+ files: ['**/*.ts', '**/*.tsx'],
186
+ // no need to check our snippets
187
+ ignores: ['**/*.md'],
188
+ plugins: { perfectionist },
189
+ languageOptions: {
190
+ parserOptions: {
191
+ projectService: true,
192
+ tsconfigRootDir: import.meta.dirname,
193
+ },
194
+ },
195
+ // switching to TypeScript unused var rule (instead of JS rule), so that no error is raised
196
+ // on unused param from abstract function arguments
197
+ rules: {
198
+ ...standardTSRules,
199
+ 'perfectionist/sort-imports': [
200
+ 'error',
201
+ { type: 'alphabetical', internalPattern: ['^@/.*'] },
202
+ ],
203
+ // Enforce consistent brace style for all control statements
204
+ curly: ['error', 'all'],
205
+ // Enforce opening brace on same line and closing brace on new line
206
+ 'brace-style': ['error', '1tbs', { allowSingleLine: false }],
207
+ },
208
+ },
209
+ // we have to declare that AFTER the TS specifics, our unit test rules from the JS config are otherwise ignored (when the tests are written in TS)
210
+ unitTestsConfig);
211
+ export default defaultConfig;
package/package.json CHANGED
@@ -1,37 +1,47 @@
1
1
  {
2
- "name": "@swissgeo/config-eslint",
3
- "version": "1.0.0-beta.2",
4
- "description": "Shared ESLint config for SWISSGEO projects.",
5
- "license": "BSD-3-Clause",
6
- "type": "module",
7
- "main": "index.ts",
8
- "dependencies": {
9
- "@eslint/js": "^9.39.1",
10
- "@eslint/markdown": "^7.5.1",
11
- "@typescript-eslint/utils": "^8.46.4",
12
- "@vue/eslint-config-prettier": "^10.2.0",
13
- "@vue/eslint-config-typescript": "^14.6.0",
14
- "eslint-plugin-chai-friendly": "^1.1.0",
15
- "eslint-plugin-cypress": "^5.2.0",
16
- "eslint-plugin-mocha": "^11.2.0",
17
- "eslint-plugin-perfectionist": "^4.15.1",
18
- "eslint-plugin-prettier": "^5.5.4",
19
- "eslint-plugin-vue": "^10.5.1",
20
- "typescript-eslint": "^8.46.4"
21
- },
22
- "devDependencies": {
23
- "globals": "^16.5.0",
24
- "typescript": "^5.9.3",
25
- "@swissgeo/config-typescript": "1.0.0-beta.2"
26
- },
27
- "peerDependencies": {
28
- "eslint": "^9.39.1",
29
- "@swissgeo/config-prettier": "1.0.0-beta.2",
30
- "@swissgeo/config-stylelint": "1.0.0-beta.2"
31
- },
32
- "scripts": {
33
- "lint": "eslint --fix",
34
- "lint:no-fix": "eslint",
35
- "type-check": "tsc -p tsconfig.json"
36
- }
37
- }
2
+ "name": "@swissgeo/config-eslint",
3
+ "version": "1.0.0-beta.3",
4
+ "description": "Shared ESLint config for SWISSGEO projects.",
5
+ "license": "BSD-3-Clause",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.umd.cjs"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "build": "pnpm run type-check && pnpm run generate-types",
16
+ "generate-types": "tsc --declaration",
17
+ "lint": "eslint --fix",
18
+ "lint:no-fix": "eslint",
19
+ "type-check": "tsc -p tsconfig.json"
20
+ },
21
+ "dependencies": {
22
+ "@eslint/js": "catalog:",
23
+ "@eslint/markdown": "catalog:",
24
+ "@typescript-eslint/utils": "catalog:",
25
+ "@vue/eslint-config-prettier": "catalog:",
26
+ "@vue/eslint-config-typescript": "catalog:",
27
+ "eslint-plugin-chai-friendly": "catalog:",
28
+ "eslint-plugin-cypress": "catalog:",
29
+ "eslint-plugin-mocha": "catalog:",
30
+ "eslint-plugin-perfectionist": "catalog:",
31
+ "eslint-plugin-prettier": "catalog:",
32
+ "eslint-plugin-vue": "catalog:",
33
+ "typescript-eslint": "catalog:"
34
+ },
35
+ "devDependencies": {
36
+ "@microsoft/api-extractor": "catalog:",
37
+ "@swissgeo/config-typescript": "workspace:*",
38
+ "@types/node": "catalog:",
39
+ "globals": "catalog:",
40
+ "typescript": "catalog:"
41
+ },
42
+ "peerDependencies": {
43
+ "@swissgeo/config-prettier": "workspace:*",
44
+ "@swissgeo/config-stylelint": "workspace:*",
45
+ "eslint": "catalog:"
46
+ }
47
+ }
package/tsconfig.json CHANGED
@@ -1,4 +1,11 @@
1
1
  {
2
- "extends": "@swissgeo/config-typescript/tsconfig.base.json",
3
- "include": ["**/*.ts"]
2
+ "files": ["index.ts"],
3
+ "compilerOptions": {
4
+ "target": "ESNext",
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "noEmitOnError": false,
8
+ "outDir": "dist",
9
+ "types": ["node"]
10
+ }
4
11
  }
@@ -0,0 +1,7 @@
1
+ declare module 'eslint-plugin-chai-friendly' {
2
+ import { FlatConfig } from '@typescript-eslint/utils/ts-eslint'
3
+
4
+ const plugin: FlatConfig.Plugin
5
+
6
+ export default plugin
7
+ }
@@ -0,0 +1,11 @@
1
+ import type { Linter } from 'eslint'
2
+
3
+ declare module 'eslint-plugin-cypress/lib' {
4
+ const plugin: {
5
+ configs: {
6
+ recommended: Linter.Config
7
+ [key: string]: Linter.Config | undefined
8
+ }
9
+ }
10
+ export default plugin
11
+ }
package/LICENSE.md DELETED
@@ -1,33 +0,0 @@
1
- web-mapviewer is available for use under the following license, commonly known
2
- as the 3-clause (or "modified") BSD license:
3
-
4
- ==============================
5
-
6
- Copyright (c) 2022, swisstopo
7
- All rights reserved.
8
-
9
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
10
-
11
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
12
-
13
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
14
-
15
- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
16
-
17
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18
-
19
- ==============================
20
-
21
- Portions of web-mapviewer are based on works by others. A non-extensive list:
22
-
23
- [Bootstrap Source Code](https://github.com/twbs/bootstrap/blob/master/LICENSE)
24
-
25
- [VueJS Source Code](https://github.com/vuejs/vue/blob/dev/LICENSE)
26
-
27
- [OpenLayers Source Code](https://github.com/openlayers/openlayers/blob/master/LICENSE.md)
28
-
29
- [Font Awesome Icons](https://creativecommons.org/licenses/by/4.0/)
30
-
31
- [Font Awesome Fonts](https://scripts.sil.org/OFL)
32
-
33
- [Font Awesome Code](https://opensource.org/licenses/MIT)
package/packages.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import type { Linter } from 'eslint'
2
-
3
- import { FlatConfig } from '@typescript-eslint/utils/ts-eslint'
4
-
5
- declare module 'eslint-plugin-chai-friendly' {
6
- const plugin: FlatConfig.Plugin
7
- export default plugin
8
- }
9
-
10
- declare module 'eslint-plugin-cypress/flat' {
11
- const plugin: {
12
- configs: {
13
- recommended: Linter.Config
14
- [key: string]: Linter.Config | undefined
15
- }
16
- }
17
- export default plugin
18
- }