eslint-plugin-use-agnostic 0.11.1 → 0.11.2
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Linter } from "eslint";
|
|
2
1
|
import tseslint from "typescript-eslint";
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -121,11 +120,15 @@ export const skip = Object.freeze({
|
|
|
121
120
|
skip: true,
|
|
122
121
|
});
|
|
123
122
|
|
|
124
|
-
// common linter for AST retrieval
|
|
125
|
-
export const linter = new Linter();
|
|
126
|
-
|
|
127
123
|
// ESLint configs language options
|
|
128
|
-
|
|
124
|
+
/** @type {import('eslint').Linter.LanguageOptions} */
|
|
125
|
+
export const typeScriptAndJSXCompatible = {
|
|
129
126
|
// for compatibility with .ts and .tsx
|
|
130
127
|
parser: tseslint.parser,
|
|
131
|
-
|
|
128
|
+
// for compatibility with JSX
|
|
129
|
+
parserOptions: {
|
|
130
|
+
ecmaFeatures: {
|
|
131
|
+
jsx: true,
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
};
|
|
@@ -8,8 +8,7 @@ import {
|
|
|
8
8
|
EXTENSIONS,
|
|
9
9
|
ARE_NOT_ALLOWED_TO_IMPORT,
|
|
10
10
|
resolvedDirectives_resolvedModules,
|
|
11
|
-
|
|
12
|
-
typeScriptCompatible,
|
|
11
|
+
typeScriptAndJSXCompatible,
|
|
13
12
|
} from "../constants/bases.js";
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -90,11 +89,13 @@ export const resolveImportPath = (currentDir, importPath, cwd) => {
|
|
|
90
89
|
* @returns The ESLint-generated AST (Abstract Syntax Tree) of the file.
|
|
91
90
|
*/
|
|
92
91
|
export const getASTFromFilePath = (resolvedPath) => {
|
|
92
|
+
// ensures each instance of the function is based on its own linter
|
|
93
|
+
// (just in case somehow some linters were running concurrently)
|
|
93
94
|
const linter = new Linter();
|
|
94
95
|
// the raw code of the file at the end of the resolved path
|
|
95
96
|
const text = fs.readFileSync(resolvedPath, "utf8");
|
|
96
97
|
// utilizes linter.verify ...
|
|
97
|
-
linter.verify(text, { languageOptions:
|
|
98
|
+
linter.verify(text, { languageOptions: typeScriptAndJSXCompatible });
|
|
98
99
|
// ... to retrieve the raw code as a SourceCode object ...
|
|
99
100
|
const code = linter.getSourceCode();
|
|
100
101
|
// ... from which to extra the ESLint-generated AST
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
agnostic20ConfigName,
|
|
5
5
|
useAgnosticPluginName,
|
|
6
6
|
enforceEffectiveDirectivesRuleName,
|
|
7
|
-
|
|
7
|
+
typeScriptAndJSXCompatible,
|
|
8
8
|
} from "../_commons/constants/bases.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -26,7 +26,7 @@ export const makeAgnostic20Config = (plugin) => ({
|
|
|
26
26
|
[`${useAgnosticPluginName}/${enforceEffectiveDirectivesRuleName}`]:
|
|
27
27
|
"warn",
|
|
28
28
|
},
|
|
29
|
-
languageOptions:
|
|
29
|
+
languageOptions: typeScriptAndJSXCompatible,
|
|
30
30
|
},
|
|
31
31
|
]),
|
|
32
32
|
});
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
directive21ConfigName,
|
|
5
5
|
useAgnosticPluginName,
|
|
6
6
|
enforceCommentedDirectivesRuleName,
|
|
7
|
-
|
|
7
|
+
typeScriptAndJSXCompatible,
|
|
8
8
|
} from "../_commons/constants/bases.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -26,7 +26,7 @@ export const makeDirective21Config = (plugin) => ({
|
|
|
26
26
|
[`${useAgnosticPluginName}/${enforceCommentedDirectivesRuleName}`]:
|
|
27
27
|
"warn",
|
|
28
28
|
},
|
|
29
|
-
languageOptions:
|
|
29
|
+
languageOptions: typeScriptAndJSXCompatible,
|
|
30
30
|
},
|
|
31
31
|
]),
|
|
32
32
|
});
|