Open jcollum-nutrien opened 1 month ago
the file is named bop.spec.ts.snap.
, with a trailing dot?
Also, you're using eslint 9, but can you confirm the version of the import plugin you're using?
the file is named
bop.spec.ts.snap.
,
No, that's a typo from adding spaces after the end of the word. Two spaces and OSX inserts a period.
Also, you're using eslint 9, but can you confirm the version of the import plugin you're using?
"eslint-plugin-import": "^2.27.5",
which is resolving to 2.29.1
in the node modules folder.
Looks like that's out of date. I'll update and see if it fixes it.
Indeed, that version doesn't support eslint 9 and you shouldn't be using them together :-)
I set "eslint-plugin-import": "2.31.0",
in my root package.json and the error is still happening.
✗ cat node_modules/eslint-plugin-import/package.json | grep version
"version": "2.31.0",
However I'm not convinced that ESLint is actually using 2.31.0 when running the command. Is there some way to check the versions that ESLint is using for plugins when it runs? No --verbose
and --debug
isn't giving me that information.
I'm trying to just ignore any __snapshot__
folder instead of having to sort all this out. But when I add
ignores: ['**/__snapshot__/']
to my root eslint config
I get an error You are linting "src", but all of the files matching the glob pattern "src" are ignored.
I take out that ignores
block and the problem goes away. But the docs say:
If you want to recursively ignore all directories named .config, you need to use **/.config/, as in this example:
// eslint.config.js
export default [
{
ignores: ["**/.config/"]
}
];
are the underscores in the path screwing things up? I tried escaping them and then Prettier removed the escapes. I don't think you need to escape underscores in a string.
Edit: sorted it by using ignores: ['**/*.snap'],
instead. This looks like a different bug or a mismatch between the docs and the software.
You don't need to escape underscores, no.
You don't need to escape underscores, no.
I got it sorted, see Edit block in that comment.
Awesome! What's the mismatch you see in the docs? Let's fix it :-)
The docs say this should work (the full quote is up above):
ignores: ["**/.config/"]
but when I add
ignores: ['**/__snapshot__/']
I get an error about src
being ignored. I can fix it with
ignores: ['**/*.snap'],
to ignore all of the files with .snap
extension and it works fine. I don't see how adding ignores: ['**/__snapshot__/']
would result in all files in all src
directories being ignored.
I still think there's an actual bug in here somewhere.
As part of normal dev work I added a snapshot (Jest) file to a workspace in my repo. This apparently broke Eslint. When I remove the snapshot file the TypeError goes away. See
NOTE THIS LINE
in the middle.config
``` import presets from '@nutrien/data-product-eslint-config/eslint-preset.mjs'; // pull in the list of packages that are included in the base layer for lambdas import layerPackageJson from './layers/node-dependencies/nodejs/package.json' assert { type: 'json' }; const packages = Object.keys(layerPackageJson.dependencies); export default [ ...presets, { rules: { 'import/no-extraneous-dependencies': 'warn', // overwrite extended base eslintrc sort-keys warning 'sort-keys': [ 'error', 'asc', { caseSensitive: true, natural: false, minKeys: 6 }, ], }, settings: { 'import/core-modules': [2, ...packages], }, }, ]; ```base config
``` import js from '@eslint/js'; import ts from '@typescript-eslint/eslint-plugin'; import tsParser from '@typescript-eslint/parser'; import prettier from 'eslint-config-prettier'; import importPlugin from 'eslint-plugin-import'; import jest from 'eslint-plugin-jest'; import simpleImportSort from 'eslint-plugin-simple-import-sort'; import globals from 'globals'; /** @type {import('eslint').Linter.Config[]} */ export default [ { files: ['**/*.{js,ts,jsx,tsx}'], languageOptions: { parser: tsParser, globals: { ...globals.node, }, }, plugins: { js, ts, '@typescript-eslint': ts, simpleImportSort, import: importPlugin, }, ignores: ['.eslintrc.*', 'jest.config.js', 'cdk.out/**/*'], rules: { ...js.configs['recommended'].rules, ...ts.configs['recommended'].rules, '@typescript-eslint/no-unused-vars': 'error', '@typescript-eslint/no-explicit-any': 'error', 'import/no-duplicates': 'error', 'import/no-cycle': 'error', 'import/no-extraneous-dependencies': 'error', // https://eslint.org/docs/latest/rules/no-redeclare#handled_by_typescript 'no-redeclare': 'off', 'simpleImportSort/imports': [ 'error', { // adds default custom grouping for @nutrien packages // see https://github.com/lydell/eslint-plugin-simple-import-sort#custom-grouping groups: [['^\\u0000', '^@?\\w'], ['^@nutrien'], ['^', '^\\.']], }, ], 'simpleImportSort/exports': 'error', }, }, { files: ['**/jest.setup.ts', '**/__tests__/**/*', '**/*.{spec,test}.*'], plugins: { jest, }, languageOptions: { globals: { ...globals.jest, }, }, rules: { ...jest.configs['recommended'].rules, '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/no-empty-function': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-non-null-assertion': 'off', 'jest/no-alias-methods': 'warn', 'jest/prefer-to-contain': 'warn', 'jest/prefer-to-have-length': 'warn', }, }, // should be the last config in order to override preceding rules prettier, ]; ```