@digigov/cli-lint 1.1.0-2a507fd6 → 2.0.0-0138f8bd

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.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@digigov/cli-lint",
3
3
  "entries": [
4
+ {
5
+ "version": "1.0.4",
6
+ "tag": "@digigov/cli-lint_v1.0.4",
7
+ "date": "Fri, 16 Feb 2024 09:57:32 GMT",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "Remove cypress plugin & upgrade all other plugins"
12
+ }
13
+ ]
14
+ }
15
+ },
16
+ {
17
+ "version": "1.0.3",
18
+ "tag": "@digigov/cli-lint_v1.0.3",
19
+ "date": "Mon, 29 Jan 2024 17:45:11 GMT",
20
+ "comments": {
21
+ "patch": [
22
+ {
23
+ "comment": "Upgrade @typescript-eslint for TypeScript v5"
24
+ }
25
+ ],
26
+ "dependency": [
27
+ {
28
+ "comment": "Updating dependency \"@digigov/cli-build\" from `1.1.0` to `1.1.1`"
29
+ }
30
+ ]
31
+ }
32
+ },
33
+ {
34
+ "version": "1.0.2",
35
+ "tag": "@digigov/cli-lint_v1.0.2",
36
+ "date": "Mon, 29 Jan 2024 10:46:50 GMT",
37
+ "comments": {
38
+ "patch": [
39
+ {
40
+ "comment": "Disallow irregular whitespace"
41
+ }
42
+ ],
43
+ "dependency": [
44
+ {
45
+ "comment": "Updating dependency \"@digigov/cli-build\" from `1.0.1` to `1.1.0`"
46
+ }
47
+ ]
48
+ }
49
+ },
4
50
  {
5
51
  "version": "1.0.0",
6
52
  "tag": "@digigov/cli-lint_v1.0.0",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,27 @@
1
1
  # Change Log - @digigov/cli-lint
2
2
 
3
- This log was last generated on Fri, 15 Dec 2023 15:23:56 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 16 Feb 2024 09:57:32 GMT and should not be manually modified.
4
+
5
+ ## 1.0.4
6
+ Fri, 16 Feb 2024 09:57:32 GMT
7
+
8
+ ### Patches
9
+
10
+ - Remove cypress plugin & upgrade all other plugins
11
+
12
+ ## 1.0.3
13
+ Mon, 29 Jan 2024 17:45:11 GMT
14
+
15
+ ### Patches
16
+
17
+ - Upgrade @typescript-eslint for TypeScript v5
18
+
19
+ ## 1.0.2
20
+ Mon, 29 Jan 2024 10:46:50 GMT
21
+
22
+ ### Patches
23
+
24
+ - Disallow irregular whitespace
4
25
 
5
26
  ## 1.0.0
6
27
  Fri, 15 Dec 2023 15:23:56 GMT
package/eslint.config.js CHANGED
@@ -1 +1,207 @@
1
- module.exports = require('./eslintrc')()
1
+ import { resolveProject } from '@digigov/cli/lib';
2
+
3
+ import { includeIgnoreFile } from '@eslint/compat';
4
+ import js from '@eslint/js';
5
+ import pluginPromise from 'eslint-plugin-promise';
6
+
7
+ import json from 'eslint-plugin-json';
8
+
9
+ import ts from 'typescript-eslint';
10
+
11
+ import globals from 'globals';
12
+ import react from 'eslint-plugin-react';
13
+ import reactHooks from 'eslint-plugin-react-hooks';
14
+
15
+ import vitest from '@vitest/eslint-plugin';
16
+
17
+ import importPlugin from 'eslint-plugin-import-x';
18
+ import * as tsResolver from 'eslint-import-resolver-typescript';
19
+ import digigovEslintPlugin from 'eslint-plugin-digigov';
20
+
21
+ import prettier from 'eslint-plugin-prettier/recommended';
22
+
23
+ const project = resolveProject();
24
+
25
+ // base
26
+ /** @type {any[]} */
27
+ let config = [];
28
+
29
+ if (project.ignore) {
30
+ const gitIgnoreConfig = includeIgnoreFile(project.ignore);
31
+ config.push(gitIgnoreConfig);
32
+ }
33
+
34
+ config.push([
35
+ js.configs.recommended,
36
+ pluginPromise.configs['flat/recommended'],
37
+ {
38
+ ...json.configs.recommended,
39
+ name: '@digigov/json',
40
+ files: ['**/*.json'],
41
+ },
42
+ {
43
+ files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
44
+ languageOptions: {
45
+ globals: {
46
+ ...globals.node,
47
+ ...globals.jest,
48
+ },
49
+ },
50
+ rules: {
51
+ 'promise/catch-or-return': [
52
+ 'error',
53
+ {
54
+ allowFinally: true,
55
+ },
56
+ ],
57
+ },
58
+ },
59
+ ]);
60
+
61
+ // typescript
62
+ if (project.isTs) {
63
+ config.push(ts.configs.recommended, ts.configs.stylistic, {
64
+ rules: {
65
+ '@typescript-eslint/no-explicit-any': 'warn',
66
+ '@typescript-eslint/no-empty-interface': 'off',
67
+ '@typescript-eslint/no-empty-object-type': 'off',
68
+ '@typescript-eslint/no-var-requires': 'off',
69
+ '@typescript-eslint/no-require-imports': 'off',
70
+ '@typescript-eslint/ban-ts-comment': 'warn',
71
+ '@typescript-eslint/no-empty-function': 'off',
72
+ },
73
+ });
74
+
75
+ // import
76
+ config.push({
77
+ name: '@digigov/import-plugin',
78
+ files: ['**/*.{mts,ts,tsx}'],
79
+ plugins: {
80
+ 'import-x': importPlugin,
81
+ digigov: digigovEslintPlugin,
82
+ },
83
+ languageOptions: {
84
+ parser: ts.parser,
85
+ ecmaVersion: 'latest',
86
+ sourceType: 'module',
87
+ parserOptions: {
88
+ warnOnUnsupportedTypeScriptVersion: false,
89
+ },
90
+ },
91
+ rules: {
92
+ ...importPlugin.flatConfigs.recommended.rules,
93
+ ...importPlugin.flatConfigs.typescript.rules,
94
+ 'digigov/no-relative-imports': 'error',
95
+ // the following import-x rules already checked by typescript eslint
96
+ 'import-x/default': 'off',
97
+ 'import-x/named': 'off',
98
+ 'import-x/namespace': 'off',
99
+ 'import-x/no-named-as-default-member': 'off',
100
+ 'import-x/no-unresolved': 'off',
101
+ // sort imports
102
+ 'import-x/order': [
103
+ 'error',
104
+ {
105
+ groups: [
106
+ ['builtin', 'external'],
107
+ 'internal',
108
+ ['parent', 'sibling', 'index'],
109
+ ],
110
+ pathGroups: [
111
+ {
112
+ pattern: 'react',
113
+ group: 'builtin',
114
+ position: 'before',
115
+ },
116
+ {
117
+ pattern: '@digigov/**',
118
+ group: 'internal',
119
+ },
120
+ ],
121
+ pathGroupsExcludedImportTypes: ['react'],
122
+ alphabetize: {
123
+ order: 'asc',
124
+ caseInsensitive: true,
125
+ },
126
+ },
127
+ ],
128
+ },
129
+ settings: {
130
+ 'import-x/resolver': {
131
+ name: 'tsResolver',
132
+ resolver: tsResolver,
133
+ },
134
+ },
135
+ });
136
+
137
+ // storybook
138
+ config.push({
139
+ files: ['**/*.stories.{js,jsx,ts,tsx}', '**/__stories__/*.{js,jsx,ts,tsx}'],
140
+ rules: {
141
+ '@typescript-eslint/no-unused-vars': 'off',
142
+ '@typescript-eslint/no-explicit-any': 'off',
143
+ },
144
+ });
145
+ }
146
+
147
+ // react
148
+ if (project.dependencies.react) {
149
+ config.push({
150
+ name: '@digigov/react',
151
+ files: ['**/*.{js,jsx,ts,tsx}'],
152
+ plugins: {
153
+ react,
154
+ 'react-hooks': reactHooks,
155
+ },
156
+ settings: {
157
+ react: {
158
+ version: 'detect',
159
+ defaultVersion: '18.3.1',
160
+ },
161
+ },
162
+ languageOptions: {
163
+ ...react.configs?.flat?.['recommended']?.languageOptions,
164
+ globals: {
165
+ ...globals.serviceworker,
166
+ ...globals.browser,
167
+ },
168
+ parserOptions: {
169
+ ecmaFeatures: {
170
+ jsx: true,
171
+ },
172
+ },
173
+ },
174
+ rules: {
175
+ ...react.configs?.flat?.['recommended']?.rules,
176
+ ...react.configs?.flat?.['jsx-runtime']?.rules,
177
+ ...reactHooks.configs.recommended.rules,
178
+ 'react-hooks/exhaustive-deps': 'warn',
179
+ 'react/prop-types': 'off',
180
+ },
181
+ });
182
+ }
183
+
184
+ // testing
185
+ if (project.dependencies.vitest) {
186
+ config.push({
187
+ name: '@digigov/vitest',
188
+ files: [
189
+ '**/__tests__/**/*.{js,jsx,ts,tsx}',
190
+ '**/*.test.{js,jsx,ts,tsx}',
191
+ '**/*.spec.{js,jsx,ts,tsx}',
192
+ ],
193
+ plugins: {
194
+ vitest,
195
+ },
196
+ rules: {
197
+ ...vitest.configs.recommended.rules,
198
+ 'no-use-before-define': 'off',
199
+ 'space-before-function-paren': 'off',
200
+ },
201
+ });
202
+ }
203
+
204
+ // prettier - must be last
205
+ config.push(prettier);
206
+
207
+ export default ts.config(config);
package/index.js CHANGED
@@ -1,45 +1,23 @@
1
- const { Command, flags } = require('@oclif/command');
2
- const execa = require('execa');
3
- const { makeConfig, resolveProject } = require('@digigov/cli/lib');
4
- const { DigigovCommand } = require('@digigov/cli/lib');
1
+ import { DigigovCommand } from '@digigov/cli/lib';
5
2
 
6
- module.exports = class Lint extends DigigovCommand {
7
- static description = 'lint digigov projects';
8
- static id = 'lint';
9
- static examples = [`$ digigov lint`];
10
- static strict = false;
11
- dirname = __dirname;
12
- static load() {
13
- return Lint;
14
- }
15
- script = 'eslint';
16
- static args = [{ name: 'files' }];
17
- async run() {
18
- const { args, argv } = this.parse(Lint);
19
- const project = resolveProject();
20
- const ext = ['.js', '.jsx', '.json', '.ts', '.tsx', '.mdx'];
21
- const cmdArgs = [];
22
- if (project.ignore) {
23
- cmdArgs.push('--ignore-path', project.ignore);
24
- }
25
- if (project.isTs) {
26
- await this.exec('tsc', ['--noEmit']);
27
- }
28
- if (args.files && args.files.startsWith('-')) {
29
- args.files = null;
30
- }
31
- const files = args.files || project.src;
32
- const proc = this.exec(
33
- this.script,
34
- [
35
- files,
36
- '--ext',
37
- ext.join(','),
38
- ...cmdArgs,
39
- ...argv.filter((a) => a !== files),
40
- ],
41
- { env: {}, stdio: 'inherit' }
42
- );
43
- return proc;
44
- }
45
- };
3
+ const command = new DigigovCommand('lint', import.meta.url);
4
+
5
+ command
6
+ .argument('[filter...]', 'Filter files')
7
+ .helpOption(false)
8
+ .allowUnknownOption()
9
+ .action(lint);
10
+
11
+ export default command;
12
+
13
+ /**
14
+ * @param {string[]} args - The arguments
15
+ * @param {DigigovCommand} ctx - The command context
16
+ */
17
+ async function lint(args, _, ctx) {
18
+ await ctx.exec('eslint', ['--no-error-on-unmatched-pattern', ...args], {
19
+ env: {},
20
+ stdio: 'inherit',
21
+ });
22
+ return;
23
+ }
package/package.json CHANGED
@@ -1,44 +1,53 @@
1
1
  {
2
2
  "name": "@digigov/cli-lint",
3
- "version": "1.1.0-2a507fd6",
3
+ "version": "2.0.0-0138f8bd",
4
4
  "description": "Lint plugin for Digigov CLI",
5
5
  "main": "index.js",
6
+ "type": "module",
6
7
  "author": "GRNET Devs <devs@lists.grnet.gr>",
7
8
  "license": "BSD-2-Clause",
8
9
  "dependencies": {
9
- "@babel/eslint-parser": "7.13.8",
10
- "@oclif/command": "1.8.0",
11
- "@typescript-eslint/eslint-plugin": "4.19.0",
12
- "@typescript-eslint/parser": "4.19.0",
13
- "eslint-config-prettier": "6.10.0",
14
- "eslint-import-resolver-babel-module": "5.1.2",
15
- "eslint-plugin-css-modules": "2.11.0",
16
- "eslint-plugin-cypress": "2.8.1",
17
- "eslint-plugin-digigov": "1.0.0",
18
- "eslint-plugin-enzyme": "0.2.0",
19
- "eslint-plugin-import": "2.20.1",
20
- "eslint-plugin-jest": "24.1.3",
21
- "eslint-plugin-json": "2.0.1",
22
- "eslint-plugin-mdx": "1.6.8",
23
- "eslint-plugin-prettier": "3.1.2",
24
- "eslint-plugin-promise": "4.2.1",
25
- "eslint-plugin-react": "7.18.0",
26
- "eslint-plugin-react-hooks": "4.0.2",
27
- "eslint-plugin-standard": "4.0.1",
28
- "execa": "5.0.0",
29
- "@rushstack/eslint-patch": "1.0.6",
30
- "publint": "0.1.8"
10
+ "eslint-config-prettier": "9.1.0",
11
+ "eslint-plugin-css-modules": "2.12.0",
12
+ "eslint-plugin-digigov": "2.0.0-0138f8bd",
13
+ "eslint-plugin-json": "4.0.1",
14
+ "eslint-plugin-prettier": "5.2.1",
15
+ "eslint-plugin-promise": "7.2.1",
16
+ "eslint-plugin-react": "7.37.2",
17
+ "eslint-plugin-react-hooks": "5.0.0",
18
+ "@rushstack/eslint-patch": "1.10.4",
19
+ "publint": "0.1.8",
20
+ "@vitest/eslint-plugin": "~1.1.14",
21
+ "@eslint/js": "~9.16.0",
22
+ "typescript-eslint": "~8.17.0",
23
+ "eslint-plugin-import-x": "~4.5.0",
24
+ "eslint-import-resolver-typescript": "~3.7.0",
25
+ "globals": "~15.13.0",
26
+ "@eslint/compat": "~1.2.3"
27
+ },
28
+ "exports": {
29
+ ".": "./index.js",
30
+ "./eslint.config": "./eslint.config.js",
31
+ "./prettier.config": "./prettier.config.cjs",
32
+ "./prettierrc": "./prettierrc.cjs"
31
33
  },
32
34
  "devDependencies": {
33
35
  "publint": "0.1.8"
34
36
  },
35
37
  "peerDependencies": {
36
- "@digigov/cli": "1.1.0-2a507fd6",
37
- "@digigov/cli-build": "1.1.0-2a507fd6",
38
- "prettier": "2.0.2",
39
- "eslint": "7.24.0"
38
+ "@digigov/cli": "2.0.0-0138f8bd",
39
+ "prettier": "^3",
40
+ "typescript": "*",
41
+ "eslint": "^9"
42
+ },
43
+ "peerDependenciesMeta": {
44
+ "typescript": {
45
+ "optional": true
46
+ }
40
47
  },
41
48
  "scripts": {
42
- "publint": "publint"
49
+ "lint": "eslint",
50
+ "publint": "publint",
51
+ "typecheck": "tsc"
43
52
  }
44
53
  }
package/prettierrc.cjs ADDED
@@ -0,0 +1,5 @@
1
+ const { makeConfig } = require('@digigov/cli/lib');
2
+ const prettierrc = (overrides) => {
3
+ return makeConfig(overrides, require('./prettier.config.cjs'));
4
+ };
5
+ module.exports = prettierrc;
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "@digigov/cli/tsconfig.cli",
3
+ "include": ["./*.js"]
4
+ }
package/.eslintrc.js DELETED
@@ -1,2 +0,0 @@
1
- const eslintrc = require('./eslintrc')
2
- module.exports = eslintrc()
package/eslint.common.js DELETED
@@ -1,127 +0,0 @@
1
- const lib = require('@digigov/cli/lib');
2
- const prettierrc = require('./prettier.config');
3
- require('@rushstack/eslint-patch/modern-module-resolution');
4
- function makeEslintConfig(dir) {
5
- const project = lib.resolveProject(dir);
6
- let restConfig = {};
7
- let rules = {};
8
- const plugins = [];
9
- const settings = {};
10
- const extendsRest = [
11
- 'eslint:recommended',
12
- 'plugin:prettier/recommended',
13
- 'plugin:json/recommended',
14
- ];
15
- if (project.dependencies.react) {
16
- plugins.push('digigov');
17
- rules = {
18
- 'digigov/no-relative-imports': 'error',
19
- }
20
- extendsRest.push(
21
- ...[
22
- 'plugin:react/recommended',
23
- 'plugin:react-hooks/recommended',
24
- ]
25
- );
26
- settings['react'] = {
27
- version: 'detect',
28
- };
29
- settings[require.resolve('eslint-plugin-import')] = {
30
- [require.resolve('eslint-import-resolver-babel-module')]: {},
31
- };
32
- }
33
- if (project.dependencies.jest) {
34
- extendsRest.push(
35
- ...['plugin:jest/recommended', 'plugin:cypress/recommended']
36
- );
37
- plugins.push('enzyme');
38
- }
39
- if (project.src) {
40
- restConfig = {
41
- ...restConfig,
42
- parser: '@babel/eslint-parser',
43
- parserOptions: {
44
- babelOptions: {
45
- configFile: require.resolve('@digigov/cli-build/babel.config.js'),
46
- },
47
- },
48
- };
49
- }
50
- const config = {
51
- env: {
52
- node: true,
53
- browser: true,
54
- },
55
- extends: extendsRest,
56
- plugins,
57
- rules: {
58
- 'jest/no-deprecated-functions': 0,
59
- 'no-use-before-define': 0,
60
- 'space-before-function-paren': 0,
61
- 'prettier/prettier': ['error', prettierrc, { usePrettierrc: false }],
62
- ...rules,
63
- },
64
- settings,
65
- overrides: [
66
- {
67
- files: ['*.md', '*.mdx'],
68
- extends: ['plugin:mdx/recommended'],
69
- },
70
- {
71
- files: ['*.css'],
72
- extends: ['plugin:css-modules/recommended'],
73
- },
74
- ],
75
- ...restConfig,
76
- };
77
- if (project.isTs) {
78
- config.overrides.push({
79
- files: ['*.ts', '*.tsx'],
80
- parser: '@typescript-eslint/parser',
81
- env: {
82
- browser: true,
83
- },
84
- plugins: ['@typescript-eslint', 'import'],
85
- extends: 'plugin:@typescript-eslint/recommended',
86
- rules: {
87
- 'react/prop-types': 'off',
88
- '@typescript-eslint/no-empty-interface': 'off',
89
- '@typescript-eslint/no-var-requires': 0,
90
- '@typescript-eslint/ban-ts-comment': 'warn',
91
- 'react-hooks/exhaustive-deps': 'off',
92
- 'import/order': [
93
- 'error',
94
- {
95
- groups: [
96
- ['builtin', 'external'],
97
- 'internal',
98
- ['parent', 'sibling', 'index'],
99
- ],
100
- pathGroups: [
101
- {
102
- pattern: 'react',
103
- group: 'builtin',
104
- position: 'before',
105
- },
106
- {
107
- pattern: '@digigov/**',
108
- group: 'internal',
109
- },
110
- ],
111
- pathGroupsExcludedImportTypes: ['react'],
112
- alphabetize: {
113
- order: 'asc',
114
- caseInsensitive: true,
115
- },
116
- },
117
- ],
118
- },
119
- });
120
- }
121
- return config;
122
- }
123
-
124
- module.exports = {
125
- makeEslintConfig,
126
- config: makeEslintConfig(),
127
- };
package/eslintrc.js DELETED
@@ -1,6 +0,0 @@
1
- const {makeConfig} = require('@digigov/cli/lib')
2
- const eslintrc = (overrides)=>{
3
- return makeConfig(overrides, require('./eslint.common').config)
4
- }
5
- module.exports = eslintrc
6
-
package/prettierrc.js DELETED
@@ -1,6 +0,0 @@
1
- const {makeConfig} = require('@digigov/cli/lib')
2
- const prettierrc = (overrides)=>{
3
- return makeConfig(overrides, require('./prettier.config'))
4
- }
5
- module.exports = prettierrc
6
-
File without changes