From 5a7d893f99a4f7f392c31e1339782b33c2514062 Mon Sep 17 00:00:00 2001 From: Steve Dodier-Lazaro Date: Mon, 17 Feb 2025 15:08:00 +0100 Subject: [PATCH 01/16] chore: Update eslint and cosmiconfig --- .eslintrc.cjs | 135 --- eslint.config.mjs | 180 ++++ examples/rename-imports/Input.vue | 1 + package.json | 27 +- src/__tests__/bin.spec.ts | 1 - src/template/__tests__/stringify.spec.ts | 6 +- src/types/StyleTransformation.ts | 1 + yarn.lock | 1105 +++++++++++++--------- 8 files changed, 838 insertions(+), 618 deletions(-) delete mode 100644 .eslintrc.cjs create mode 100644 eslint.config.mjs diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index b4ff954..0000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,135 +0,0 @@ -module.exports = { - env: { - es2022: true, - node: true, - }, - - parserOptions: { - ecmaVersion: 2022, - parser: '@typescript-eslint/parser', - }, - - extends: [ - 'eslint:recommended', - 'airbnb-base', - 'plugin:import/errors', - 'plugin:import/warnings', - 'plugin:import/typescript', - 'plugin:jest/recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:import/typescript', - 'prettier', - 'plugin:yml/prettier', - ], - - settings: { - 'import/resolver': { - typescript: true, - }, - 'import/core-modules': [ - 'vue', - '@vue/compiler-core', - '@vue/compiler-dom', - '@vue/compiler-sfc', - '@vue/shared', - ], - }, - - rules: { - 'line-comment-position': 'error', - 'newline-before-return': 'error', - 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'warn', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'warn', - 'no-param-reassign': [ - 'error', - { - ignorePropertyModificationsFor: ['descriptor'], - props: true, - }, - ], - 'prefer-destructuring': 'error', - 'import/extensions': 'off', - 'import/newline-after-import': ['error', { count: 1 }], - 'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'], - 'import/no-extraneous-dependencies': [ - 'error', - { - devDependencies: [ - '__mocks__/*', - '**/*.spec.ts', - '.*.config.js', - '.*.config.cjs', - '.*.config.ts', - '*.config.js', - '*.config.cjs', - '*.config.ts', - '.*rc.js', - '.*rc.cjs', - ], - packageDir: ['.'], - }, - ], - 'import/order': [ - 'error', - { - alphabetize: { order: 'asc' }, - groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], - 'newlines-between': 'always', - }, - ], - 'import/prefer-default-export': 'off', - 'jest/no-disabled-tests': 'error', - 'jest/no-focused-tests': 'error', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'error', - '@typescript-eslint/no-non-null-assertion': 'error', - /* Let TS handle these rules. */ - 'no-undef': 'off', - 'no-shadow': 'off', - 'no-use-before-define': 'off', - '@typescript-eslint/no-unused-vars': 'error', - '@typescript-eslint/no-shadow': 'error', - '@typescript-eslint/no-use-before-define': 'error', - 'arrow-body-style': 'off', - 'class-methods-use-this': 'off', - 'prefer-arrow-callback': 'off', - quotes: ['error', 'single', { allowTemplateLiterals: false, avoidEscape: true }], - }, - - overrides: [ - { - files: ['**/*.cjs'], - rules: { - '@typescript-eslint/no-var-requires': 'off', - }, - }, - { - files: ['__mocks__/*'], - rules: { - '@typescript-eslint/no-var-requires': 'off', - }, - }, - { - files: ['jest.setup.ts'], - rules: { - 'jest/no-export': 'off', - }, - }, - { - files: ['examples/**/Input*'], - rules: { - 'no-console': 'off', - 'no-debugger': 'off', - 'import/no-extraneous-dependencies': 'off', - }, - }, - { - files: ['examples/**/transformation.cjs'], - rules: { - 'no-console': 'warn', - 'no-debugger': 'warn', - 'no-param-reassign': 'off', - }, - }, - ], -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..5471626 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,180 @@ +import eslint from '@eslint/js' +import tsEslint from 'typescript-eslint' +import prettier from 'eslint-config-prettier' +import eslintPluginImport from 'eslint-plugin-import' +import eslintPluginJest from 'eslint-plugin-jest' +import eslintPluginVue from 'eslint-plugin-vue' +import globals from 'globals' + +export default [ + { + ignores: [ + '*.d.ts', + '.circleci/config.yml', + '.github/dependabot.yml', + '.mergify/config.yml', + '_.log', + '_.lock', + '*.tgz', + '.gitignore', + '.eslintignore', + '.prettierignore', + '**/node_modules', + '**/coverage', + '**/dist', + 'examples/*/Input.*', + '**/dist', + ], + }, + eslint.configs.recommended, + { + languageOptions: { + ecmaVersion: 2022, + sourceType: 'module', + globals: { + ...globals.es2022, + ...globals.node, + }, + parserOptions: { + ecmaVersion: 2022, + }, + }, + settings: { + 'import/resolver': { + typescript: true, + }, + 'import/core-modules': [ + 'vue', + '@vue/compiler-core', + '@vue/compiler-dom', + '@vue/compiler-sfc', + '@vue/shared', + ], + }, + plugins: { + import: eslintPluginImport, + jest: eslintPluginJest, + }, + }, + ...tsEslint.config( + { ignores: ['*.d.ts', '**/coverage', '**/dist'] }, + { + extends: [ + eslint.configs.recommended, + ...tsEslint.configs.recommended, + ...eslintPluginVue.configs['flat/recommended'], + ], + files: ['**/*.{ts,vue}'], + languageOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + globals: globals.browser, + parserOptions: { + parser: tsEslint.parser, + }, + }, + rules: { + 'vue/prefer-import-from-vue': 'off', + 'line-comment-position': 'error', + 'newline-before-return': 'error', + 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'warn', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'warn', + 'no-param-reassign': [ + 'error', + { + ignorePropertyModificationsFor: ['descriptor'], + props: true, + }, + ], + 'prefer-destructuring': 'off', + 'import/extensions': 'off', + 'import/newline-after-import': ['error', { count: 1 }], + 'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'], + 'import/no-extraneous-dependencies': [ + 'error', + { + devDependencies: [ + '__mocks__/*', + '**/*.spec.ts', + '.*.config.js', + '.*.config.cjs', + '.*.config.ts', + '*.config.js', + '*.config.cjs', + '*.config.ts', + '.*rc.js', + '.*rc.cjs', + 'eslint.config.mjs', + ], + packageDir: ['.'], + }, + ], + 'import/order': [ + 'error', + { + alphabetize: { order: 'asc' }, + groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], + 'newlines-between': 'always', + }, + ], + 'import/prefer-default-export': 'off', + 'jest/no-disabled-tests': 'error', + 'jest/no-focused-tests': 'error', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-explicit-any': 'error', + '@typescript-eslint/no-non-null-assertion': 'error', + 'no-undef': 'off', + 'no-shadow': 'off', + 'no-use-before-define': 'off', + '@typescript-eslint/no-unused-vars': 'error', + '@typescript-eslint/no-shadow': 'error', + '@typescript-eslint/no-use-before-define': 'error', + 'arrow-body-style': 'off', + 'class-methods-use-this': 'off', + 'prefer-arrow-callback': 'off', + quotes: ['error', 'single', { allowTemplateLiterals: false, avoidEscape: true }], + }, + }, + ), + { + files: ['**/*.cjs'], + rules: { + '@typescript-eslint/no-var-requires': 'off', + }, + }, + { + files: ['__mocks__/*'], + languageOptions: { + globals: globals.jest, + }, + rules: { + '@typescript-eslint/no-var-requires': 'off', + }, + }, + { + files: ['jest.setup.ts'], + languageOptions: { + globals: globals.jest, + }, + rules: { + 'jest/no-export': 'off', + }, + }, + { + files: ['examples/**/Input*'], + rules: { + 'no-console': 'off', + 'no-debugger': 'off', + 'import/no-extraneous-dependencies': 'off', + }, + }, + { + files: ['examples/**/transformation.cjs'], + rules: { + 'no-console': 'off', + 'no-debugger': 'warn', + 'no-param-reassign': 'off', + }, + }, + prettier, +] diff --git a/examples/rename-imports/Input.vue b/examples/rename-imports/Input.vue index 7383230..f99b2c0 100644 --- a/examples/rename-imports/Input.vue +++ b/examples/rename-imports/Input.vue @@ -18,6 +18,7 @@