eslint-plugin-putout 14.9.1 → 14.10.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/README.md CHANGED
@@ -84,6 +84,7 @@ Then configure the rules you want to use under the rules section.
84
84
  ### ESM
85
85
 
86
86
  - ✅ [No unresolved](/packages/eslint-plugin-putout/lib/no-unresolved#readme)
87
+ - ✅ [Remove duplicate extension](/packages/eslint-plugin-putout/lib/remove-duplicate-extensions#readme)
87
88
 
88
89
  ### Formatting
89
90
 
package/lib/index.js CHANGED
@@ -38,6 +38,7 @@ module.exports.rules = {
38
38
  ...getWrapRule('objects-braces-inside-array'),
39
39
  ...getWrapRule('object-init'),
40
40
  ...getWrapRule('no-unresolved'),
41
+ ...getWrapRule('remove-duplicate-extensions'),
41
42
  ...getWrapRule('evaluate'),
42
43
  ...getWrapRule('tape-add-newline-before-assertion'),
43
44
  ...getWrapRule('tape-add-newline-between-tests'),
@@ -80,6 +81,7 @@ const recommended = {
80
81
  'putout/objects-braces-inside-array': 'error',
81
82
  'putout/object-init': 'error',
82
83
  'putout/no-unresolved': 'error',
84
+ 'putout/remove-duplicate-extensions': 'error',
83
85
  'putout/evaluate': 'error',
84
86
  'putout/tape-add-newline-before-assertion': 'error',
85
87
  'putout/tape-add-newline-between-tests': 'error',
@@ -0,0 +1,24 @@
1
+ # remove-duplicate-extension
2
+
3
+ Check if path has duplicate extension `.js.js` can be resolved and fix if cannot.
4
+ Duplicates can happen when **IDE** like **WebStorm** inserts filename and mistakenly adds duplicate.
5
+
6
+ Part of [`eslint-plugin-putout`](https://github.com/coderaiser/putout/tree/master/packages/eslint-plugin-putout#rules).
7
+
8
+ ## ❌ Example of incorrect code
9
+
10
+ ```js
11
+ import x from './y.js.js';
12
+ export * from './y.js.js';
13
+ export * as dir from './dir.js.js';
14
+ export {m} from './y.js.js';
15
+ ```
16
+
17
+ ## ✅ Example of correct code
18
+
19
+ ```js
20
+ import x from './y.js';
21
+ export * from './y.js';
22
+ export * as dir from './dir.js';
23
+ export {m} from './y.js';
24
+ ```
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ const getValue = ({source}) => source?.value;
4
+
5
+ module.exports.category = 'errors';
6
+ module.exports.report = () => 'Avoid duplicate extensions in relative imports';
7
+ module.exports.include = () => [
8
+ 'ImportDeclaration',
9
+ 'ImportExpression',
10
+ 'ExportAllDeclaration',
11
+ 'ExportNamedDeclaration',
12
+ ];
13
+
14
+ module.exports.fix = ({text}) => {
15
+ return text.replace('.js.js', '.js');
16
+ };
17
+
18
+ module.exports.filter = ({node}) => {
19
+ const value = getValue(node);
20
+ return /\.js\.js/.test(value);
21
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-putout",
3
- "version": "14.9.1",
3
+ "version": "14.10.0",
4
4
  "type": "commonjs",
5
5
  "description": "eslint plugin for putout",
6
6
  "release": false,