UNPKG

@nx-plugins/linter

Version:

The Nx Plugin for Linter that contains executors, generators, and utilities to use powerful Eslint capabilities.

81 lines 3.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createVueEslintJson = exports.extraEslintDependencies = void 0; const devkit_1 = require("@nrwl/devkit"); const versions_1 = require("../versions"); exports.extraEslintDependencies = { dependencies: {}, devDependencies: { 'eslint-plugin-vue': versions_1.eslintPluginVueVersion }, }; const createVueEslintJson = (projectRoot, setParserOptionsProject) => ({ extends: [ `${(0, devkit_1.offsetFromRoot)(projectRoot)}.eslintrc.json`, 'plugin:vue/vue3-recommended' ], ignorePatterns: ['!**/*'], overrides: [ { files: ['*.vue', '*.ts', '*.tsx', '*.js', '*.jsx'], /** * NOTE: We no longer set parserOptions.project by default when creating new projects. * * We have observed that users rarely add rules requiring type-checking to their Nx workspaces, and therefore * do not actually need the capabilites which parserOptions.project provides. When specifying parserOptions.project, * typescript-eslint needs to create full TypeScript Programs for you. When omitting it, it can perform a simple * parse (and AST tranformation) of the source files it encounters during a lint run, which is much faster and much * less memory intensive. * * In the rare case that users attempt to add rules requiring type-checking to their setup later on (and haven't set * parserOptions.project), the executor will attempt to look for the particular error typescript-eslint gives you * and provide feedback to the user. */ parserOptions: !setParserOptionsProject ? { parser: '@typescript-eslint/parser', } : { project: [`${projectRoot}/tsconfig.*?.json`], parser: '@typescript-eslint/parser', }, /** * Having an empty rules object present makes it more obvious to the user where they would * extend things from if they needed to */ rules: {}, }, { files: ['*.vue'], parser: 'vue-eslint-parser', parserOptions: { parser: '@typescript-eslint/parser', }, rules: { "vue/max-attributes-per-line": "off", "vue/html-self-closing": [ "error", { "html": { "void": "always", "normal": "never", "component": "always" }, "svg": "always", "math": "always" } ] }, }, { files: ['*.ts', '*.tsx'], rules: {}, }, { files: ['*.js', '*.jsx'], rules: {}, }, ], }); exports.createVueEslintJson = createVueEslintJson; //# sourceMappingURL=create-eslint.js.map