![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@jsenv/eslint-config
Advanced tools
Readme
ESLint config file consists into a single big object. This package helps to split this big object into smaller objects. This is possible thanks to a function capable to compose objects together to obtain a final object needed to configure ESLint.
composeEslintConfig is a function returning an eslint config object being the composition of eslint config objects passed in arguments.
const {
composeEslintConfig,
eslintConfigBase,
} = require("@jsenv/eslint-config")
const eslintConfig = composeEslintConfig(
eslintConfigBase,
// first "group": enable html plugin
{
plugins: ["html"],
settings: {
extensions: [".html"],
},
},
// second "group": enable react plugin
{
plugins: ["react"],
settings: {
extensions: [".jsx"],
},
},
)
module.exports = eslintConfig
ESLint config | Description |
---|---|
eslintConfigBase | Enable latest js features |
eslintConfigForPrettier | Disable eslint rules already handled by prettier |
eslintConfigToPreferExplicitGlobals | Force explicit code to use global variables like window.event |
The following code is meant to be put into an .eslintrc.cjs file and does the following:
const {
composeEslintConfig,
eslintConfigBase,
eslintConfigForPrettier,
jsenvEslintRules,
jsenvEslintRulesForImport,
} = require("@jsenv/eslint-config")
const eslintConfig = composeEslintConfig(
eslintConfigBase,
{
rules: {
...jsenvEslintRules,
"operator-assignment": ["error", "always"], // override jsenv rules
},
},
eslintConfigForPrettier,
// import plugin
{
plugins: ["import"],
settings: {
"import/resolver": {
["@jsenv/importmap-eslint-resolver"]: {
projectDirectoryUrl: __dirname,
importMapFileRelativeUrl: "./import-map.importmap",
},
},
},
rules: jsenvEslintRulesForImport,
},
// html plugin
{
plugins: ["html"],
settings: {
extensions: [".html"],
},
},
// files are written for browsers by default
{
env: {
browser: true,
},
},
// some files are written for node in ESM
{
overrides: [
{
files: ["**/*.mjs"],
env: {
browser: false,
node: true,
},
globals: {
__filename: "off",
__dirname: "off",
require: "off",
exports: "off",
},
settings: {
"import/resolver": {
[importResolverPath]: {
node: true,
},
},
},
},
],
},
// some files are written for node in CommonJS
{
overrides: [
{
files: ["**/*.cjs"],
env: {
browser: false,
node: true,
},
globals: {
__filename: true,
__dirname: true,
require: true,
exports: true,
},
settings: {
"import/resolver": {
[importResolverPath]: {
node: true,
},
},
},
},
],
},
)
module.exports = eslintConfig
Rules | Description |
---|---|
jsenvEslintRules | jsenv rules for ESLint |
jsenvEslintRulesForImport | jsenv rules for eslint-plugin-import |
jsenvEslintRulesForReact | jsenv rules for project using react and eslint-plugin-react |
It will be supported by default in ESLint 8. Until then you need:
"@babel/eslint-parser"
and "@babel/core"
in your devDependencies"@babel/eslint-parser"
npm install --save-dev @babel/eslint-parser
npm install --save-dev @babel/core
.eslintrc.cjs:
const {
composeEslintConfig,
eslintConfigBase,
} = require("@jsenv/eslint-config")
const eslintConfig = composeEslintConfig(
eslintConfigBase,
// use "@babel/eslint-parser" until top level await is supported by ESLint default parser
{
parser: "@babel/eslint-parser",
parserOptions: {
requireConfigFile: false,
},
},
)
module.exports = eslintConfig
const {
composeEslintConfig,
eslintConfigBase,
jsenvEslintRulesForReact,
} = require("@jsenv/eslint-config")
const eslintConfig = composeEslintConfig(
eslintConfigBase,
// react
{
plugins: ["react"],
settings: {
react: {
version: "detect",
},
},
rules: jsenvEslintRulesForReact,
},
)
module.exports = eslintConfig
"@babel/eslint-parser"
and "@babel/plugin-syntax-jsx"
in your devDependencies@babel/plugin-syntax-jsx
in babel config file"@babel/eslint-parser"
npm install --save-dev @babel/eslint-parser
npm install --save-dev @babel/plugin-syntax-jsx
babel.config.cjs:
const babelPluginSyntaxJSX = require("@babel/plugin-syntax-jsx")
module.exports = {
plugins: [
[
babelPluginSyntaxJSX,
{
pragma: "React.createElement",
pragmaFrag: "React.Fragment",
},
],
],
}
.eslintrc.cjs:
const {
composeEslintConfig,
eslintConfigBase,
jsenvEslintRulesForReact,
} = require("@jsenv/eslint-config")
const eslintConfig = composeEslintConfig(
eslintConfigBase,
// jsx
{
parser: "@babel/eslint-parser",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
settings: {
extensions: [".jsx"],
},
},
)
module.exports = eslintConfig
In ".vscode/settings.json"
file, add
"eslint.validate": ["javascript", "html"]
FAQs
Create ESLint configuration for any project
The npm package @jsenv/eslint-config receives a total of 87 weekly downloads. As such, @jsenv/eslint-config popularity was classified as not popular.
We found that @jsenv/eslint-config demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.