Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
just some code mod things
General usage is like this:
import {someCodemod} from 'kodemods';
/**
* This is the api of a JSCodeshift transform.
*/
export default function(file, api) {
const {jscodeshift} = api;
const root = jscodeshift(file.source);
/**
* Use my codemods within your script like this:
*/
const result = someCodemod(api, root, additionalArguments);
}
This is a helper that will return an array of node paths to classes that extend whatever query is given.
import {findClassesWithSuperClass} from 'kodemods';
// Finds all classes that `extend Foo`
const resultFoo = findClassesWithSuperClass(api, root, {
type: 'Identifier',
name: 'Foo',
});
// Finds all classes that `extend bar()`
const resultBar = findClassesWithSuperClass(api, root, {
type: 'CallExpression',
callee: {
type: 'Identifier',
name: 'bar',
},
});
// Since we have the actual Node paths we can do things with them. This will
// remove all classes that `extend bar()`
resultBar.forEach(path => path.replace());
This helper finds the name of the identifier that corresponds to a particular default import or requires. This returns a string.
import {findNameForDefaultImport} from 'kodemods';
const root = jscodeshift(`
import bar from 'foo';
import baz, {buz} from 'boz';
`);
findNameForDefaultImport(api, root, 'foo'); // bar
findNameForDefaultImport(api, root, 'boz'); // baz
findNameForDefaultImport(api, root, 'baz'); // undefined
The basic idea is that this will enable you to more safely track how something
is used after being imported. It is now easy to identify anything using
NamespaceBaseClass
even though in code it is always just used as BaseClass
:
const BaseClass = require('NamespaceBaseClass');
class Foo extends BaseClass {
// ...
}
FAQs
some codemods
The npm package kodemods receives a total of 0 weekly downloads. As such, kodemods popularity was classified as not popular.
We found that kodemods demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.